0.1.2 • Published 7 years ago

ember-input-spark v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

{{input-spark}}

A replacement for \<input>

http://www.ember-sparks.com/


Installation and usage

Install the Ember Sparks addon (this components is part of the standard library)

ember install ember-sparks

Now restart your Ember app and drop the component in there!

{{input-spark
  placeholder="Start typing"
}}

Properties

NameTypeDefaultDescription
valuestringnullThe predefined value of the input.
placeholderstringnullThe text to be displayed before the user enters a value.
prefixstringnullThe prefix to be displayed before the user's input. This comes in handy if you want to show a domain name in front of a username input for example.
labelboolean/stringtrueThe label to show on top of the input, when the placeholder is no longer visible. If set to true, it will have the same value as placeholder.
maxlengthnumberunlimitedThe maximum number of characters that the user can type.
disabledbooleanfalseDetermines whether the input should be disabled or not.
errorstringnullSpecifies an error with the input. If it's set, an error message will appear underneath.
errorComponentstringinput-spark/error-sparkThe name of the component to render for error messages. You can overwrite the default one, as long as you make sure it accepts the error property.
scrollOnErrorbooleanfalseDetermines whether the page should scroll to the input when error is set. This is handy if your page is long, and you want the user to automatically be taken to whichever input is faulty.

Actions

NameDescription
onKeyUpTriggers when the user releases a key.
onKeyDownTriggers when the user presses down a key.
onEnterTriggers when the user pressed the enter key.
onFocusTriggers when the user focuses on the input.
onBlurTriggers when the user blurs (stops focusing) on the input.
onInputTriggers when the user changes the value of the input.
onFinishTypingTriggers when the user hasn't typed anything new for 1 second.
onChangeTriggers when the user has changed the value of the input and then focuses out of it.

Block version

If you use the blocking version of the component, you can set an icon at the beginning of the input. This can be done through inline SVG (recommended), an icon font or an img-tag.

{{#input-spark}}
  <svg role="img">
    <use xlink:href="/assets/icons.svg#user"></use>
  </svg>
{{/input-spark}}

Theming

To see these examples in action, check out the interactive documentation.

Important! All classes are local in order to avoid naming collisions and unintended CSS side effects. To understand how to style them, check out the Ember Sparks documentation.

  • .container

    Set some default settings here, such as width, font-size... etc.

    Example:

    .container {
      font-size: 11px;
    }
  • .input

    The (virtual) input box that the user interacts in. If the input is focused, the class .focused is appended to it. If the input is disabled, the class .disabled is appended to it. If the error bubble is showing, the class .has-error is appended to it.

    Example:

    .input {
      background-color: #ffd9d5;
    }
  • .prefix

    Style the prefix at the beginning of the input.

    Example:

    .prefix {
      color: blue;
    }
  • .icon

    Style the icon container that contains the eventual SVG icon. Block mode only.

  • .label

    Style the floating label above the input.

    Example:

    .label {
      color: red;
    }
  • .error

    Style the default error box.

    Example:

    .prefix {
      background-color: #ffdc30;
      color: #af7c38;
    }

Contributing

Check out the guidelines at http://ember-sparks.com/docs#contribute