Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aframe-material-snickell

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aframe-material-snickell

Material design (inputs, keyboards, checkbox, radio button) for A-Frame (https://aframe.io).

  • 0.1.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

A-Frame Material Kit 👽

This is real! WebVR is getting even better! Inputs, keyboard, buttons, checkboxes, radio buttons, switches, forms, toasts and more - following the Google Material design guideline for A-Frame. It is perfect for room-scale webVR apps. 👌

Demo

👉👉 Live demo 😎 👈👈

Looks surreal if you have a headset! :)

Getting Started

Here is the code from the demo. That is it. Pure html!

<a-entity laser-controls="hand: right"></a-entity>

<!-- BEGIN INPUTS/KEYBOARD -->
<a-keyboard></a-keyboard>
<a-input position="-0.7 1 -2.5" placeholder="Username" color="black" width="1"></a-input>
<a-input position="-0.7 0.8 -2.5" type="password" placeholder="Password" color="black" width="1"></a-input>
<!-- END INPUTS/KEYBOARD -->

<!-- BEGIN FORM -->
<a-rounded position="0.5 0.5 -2.5" width="4" height="3.1" radius="0.05" rotation="0 -20 0" scale="0.3 0.3 0.3">
  <a-form>
    <a-switch position="0.2 2.7 0" enabled="true"></a-switch>
    <a-radio position="0.2 2.4 0" width="3" name="food" label="Burger with fries and pizza" value="pizza"></a-radio>
    <a-radio position="0.2 2.1 0" width="3" name="food" label="Veggies" checked="true" disabled="true"></a-radio>
    <a-radio position="0.2 1.8 0" width="3" name="food" label="Ice cream"></a-radio>
    <a-checkbox position="0.2 1.5 0" width="3" name="stuff" label="I am a checkbox" checked="true"></a-checkbox>
    <a-checkbox position="0.2 1.2 0" width="3" name="stuff" label="And I am another one" checked="true" disabled="true"></a-checkbox>
    <a-button position="0.2 0.8 0" name="stuff" value="Click me" type="raised"></a-button>
    <a-button position="0.2 0.35 0" width="3" name="stuff" value="You cannot click me" disabled="true"></a-button>
  </a-form>
</a-rounded>
<!-- END FORM -->

<!-- BEGIN TOAST -->
<a-toast message="This is a toast" action="Got it"></a-toast>
<!-- END TOAST -->

👉👉 Install 👈👈

Option 1:

Download the boilerplate and follow the readme (super easy).

Option 2:

Since this kit is using assets (icons and sounds) you need to download the git project and copy the assets folder to the location of your choice and specify the path in the head of the html page.

<head>
  <!--  
    ... MORE HEAD STUFF ...
  -->
  <script src="https://aframe.io/releases/0.6.1/aframe.min.js"></script>
  <script src="./js/aframe-material.js"></script>
  <script type="text/javascript">
    AFRAME.ASSETS_PATH = "./assets";
  </script>
</head>

Documentation 🙌

👉👉 a-keyboard ⌨️🤤

Create a virtual keyboard that works with inputs out of the box.

<a-keyboard></a-keyboard>

Attributes

NameDescriptionTypeDefault
is-openWhether or not the keyboard should be openbooleanfalse
physical-keyboardWhether or not the physical keyboard should be respond to key press. (Great for debugging)booleanfalse

Methods

NameDescription
show()Display the keyboard without any animations.
hide()Hide the keyboard without any animations.
open()Open the keyboard smoothly.
dismiss()Close the keyboard smoothly.
destroy()Remove the keyboard from the scene.

Events

NameDescription
didopenTriggered when the keyboard did open.
diddismissTriggered when the keyboard did close.
inputTriggered when a key is pressed.
backspaceTriggered when the backspace key is pressed.
enterTriggered when the enter is pressed.

Custom example (just in case 😉)

let keyboard = document.querySelector("a-keyboard");
keyboard.open();
keyboard.addEventListener('input', (e)=>{
  str += e.detail;
  console.log(str);
});
keyboard.addEventListener('enter', (e)=>{
  console.log("Enter key pressed!")
})
keyboard.addEventListener('dismiss', (e)=>{
  console.log("Dismiss: ", e);
  keyboard.dismiss();
});
keyboard.addEventListener('backspace', (e)=>{
  str = str.slice(0, -1);
  console.log(str);
});

👉👉 a-input

Create a single line text input that work with the <a-keyboard>.

<a-input position="-1.25 2.1 -5" placeholder="Username" color="black" scale="2 2 2" width="1"></a-input>

Attributes

NameDescriptionTypeDefault
valueValue of the field.string""
nameName of the field.string""
disabledWhether or not the input should be disabled.booleanfalse
colorText color.color"#000"
fontText fontstring."default"
opacityInput opacity.number1
placeholderValue of the placeholder.string""
placeholder-colorText color of the placeholder.color"#AAA"
max-lengthLimit the number of characters.int0 (Infinite)
typeCan be either "text" or "password".string"text"
widthWidth of the input.number1
cursor-widthWidth of the cursor.number0.01
cursor-heightHeight of the cursor.number0.08
cursor-colorColor of the cursor.color"#007AFF"
background-colorColor of the field.color"#FFF"
background-opacityOpacity of the field background only.number1

Methods

NameDescription
focus()Focus the input.
blur()Blur the input.

Events

NameDescription
focusTriggered when the input is focused.
blurTriggered when the input is blurred.
changeTriggered when the value of the input changed.

👉👉 a-button

Create a button (can be raised of flat).

<a-button position="0 0.8 2" value="Click me" type="raised"></a-button>

Attributes

NameDescriptionTypeDefault
valueValue of the button.string"Button"
nameName of the button.string""
disabledWhether or not the button should be disabled.booleanfalse
typeCan be either "raised" or "flat".string"raised"
colorText color.color"#FFF"
button-colorColor of the button.color"#4076fd"
fontText fontstring."default"
opacityInput opacity.number1
widthWidth of the input.number1

Events

NameDescription
change:widthTriggered when the width of the button changed.

a-form

Create a form to get the same html <form> behaviors with <a-input>, <a-radio>, <a-button>, <a-switch>, <a-checkbox>.

<a-form></a-form>

👉👉 a-radio

Create a radio button.

<a-radio position="0 0.8 2" width="3" name="food" label="Burger with fries and pizza" value="pizza"></a-radio>

Attributes

NameDescriptionTypeDefault
checkedWhether or not the radio button should be checked.booleanfalse
valueValue of the radio button.string""
nameName of the radio button.string""
disabledWhether or not the button should be disabled.booleanfalse
labelText following the radio button (totally optional).string""
colorText color of the label.color"#757575"
radio-buttonColor of the radio button when unchecked.color"#757575"
radio-color-checkedColor of the radio button when checked.color"#4076fd"
fontText fontstring."default"
opacityInput opacity.number1
widthWidth of the input.number1

Events

NameDescription
changeTriggered when the value of the radio button changed.

👉👉 a-checkbox

Create a checkbox.

<a-checkbox position="0 0.8 2" width="3" name="stuff" label="I am a checkbox" checked="true"></a-checkbox>

Attributes

NameDescriptionTypeDefault
checkedWhether or not the checkbox should be checked.booleanfalse
valueValue of the checkbox.string""
nameName of the checkbox.string""
disabledWhether or not the checkbox should be disabled.booleanfalse
labelText following the checkbox (totally optional).string""
colorText color of the label.color"#757575"
radio-buttonColor of the checkbox when unchecked.color"#757575"
radio-color-checkedColor of the checkbox when checked.color"#4076fd"
fontText fontstring."default"
opacityInput opacity.number1
widthWidth of the input.number1

Events

NameDescription
changeTriggered when the value of the checkbox changed.

👉👉 a-switch

Create a switch button that can be toggle on/off.

<a-switch position="0 0.8 2" enabled="true"></a-switch>

Attributes

NameDescriptionTypeDefault
enabledWhether or not the switch should be enabled.booleanfalse
nameName of the checkbox.string""
disabledWhether or not the switch should be disabled.booleanfalse
fill-colorColor of the fill when off.color"#bababa"
knob-colorColor of the knob when off.color"#f5f5f5"
fill-color-enabledColor of the fill when on.color"#80a8ff"
knob-color-enabledColor of the knob when on.color"#4076fd"
fill-color-disabledColor of the fill when disabled.color"#939393"
knob-color-disabledColor of the knob when disabled.color"#a2a2a2"

Events

NameDescription
changeTriggered when the switch is toggled.

👉👉 a-toast

Create a toast to alert the user of something.

<a-toast message="This is a toast" action="Got it"></a-toast>

Attributes

NameDescriptionTypeDefault
messageText shown by the toast.string"You are cool"
actionText of the button (optional).string""
colorText color.color"#FFF"
background-colorColor of the toast.color"#4076fd"
fontText fontstring."default"
widthWidth of the input.number1
durationDuration of the toastnumber2000 (2sec)
autoshowWhether the toast should show right away.booleantrue

Events

NameDescription
actionclickTriggered when the action is clicked.

Custom example (just in case 😉)

let button = document.querySelector('a-button');
let toast = document.querySelector('a-toast');
toast.addEventListener('actionclick', ()=>{
  toast.hide();
})
button.addEventListener('click', ()=> {
  toast.show();
})

👉👉 a-rounded

Create a rounded rectangle, useful to create beautiful interfaces 😁.

👉 github.com/etiennepinchon/aframe-rounded


Change log

0.1.1

  • Added enter keyboard event.
  • Added physical keyboard interaction using the physical-keyboard property.

Want to make some changes to it?

Installation

First make sure you have Node installed.

On Mac OS X, it's recommended to use Homebrew to install Node + npm:

brew install node

To install the Node dependencies:

npm install

Local Development

To serve the site from a simple Node development server:

npm start

Then launch the site from your favorite browser:

http://localhost:3333/

License

Distributed under an MIT License.

Made by Etienne Pinchon (@etiennepinchon) - September 2017.

Keywords

FAQs

Package last updated on 31 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc