Git Product home page Git Product logo

ember-select-box's Introduction

@zestia/ember-select-box

Select box solutions are rarely perfect for what you want.

They come with a myriad of options to configure every possible situation, and they make too many assumptions about how your select-box should behave.

This addon does less, and gives you the primitives to easily compose your own.

Installation

ember install @zestia/ember-select-box

Demo

https://zestia.github.io/ember-select-box

Features

  • Native select box (that supports complex values) ✔︎
  • Faux select box (mimics a native select box, but easily stylable) ✔︎
  • Navigatable options and groups ✔︎
  • ARIA Attributes ✔︎
  • Supports promises ✔︎
  • Any HTML you want ✔︎
  • Will never come with built-in styles ✔︎
  • Ember Data friendly ✔︎
  • Full control at all times with the API ✔︎
  • Native-like typeahead behaviour ✔︎
  • Very few issues over many years of Ember! ✔︎
  • Easily create an autocompleter ✔︎
  • Easily create a dropdown menu ✔︎

Example

To create your own select box, make a new component that renders a select box:

{{! foo-select.hbs }}
<SelectBox
  class="foo"
  @value={{@value}}
  @onSelect={{@onSelect}} as |sb|
>
  <sb.SelectedOption {{on "click" sb.toggle}}>
    {{sb.value.name}}
  </sb.SelectedOption>
  <sb.Options>
    {{yield sb}}
  </sb.Options>
</SelectBox>

...and then use it like this:

{{! application.hbs }}
<FooSelect
  @value={{this.foo1}}
  @onSelect={{this.handleSelectFoo}} as |sb|
>
  {{#each this.foos as |foo|}}
    <sb.Option @value={{foo}}>{{foo.name}}</sb.Option>
  {{/each}}
</FooSelect>

...which will render...

<div class="select-box foo">
  <div class="select-box__selected-option">Foo 1</div>
  <div class="select-box__options">
    <div class="select-box__option">Foo 1</div>
    <div class="select-box__option">Foo 2</div>
    <div class="select-box__option">Foo 3</div>
  </div>
</div>

...as you can see, apart from being able to select a value - this addon does very little out of the box! It's up to you to add the layer of behaviour that you require using the API.

Docs

ember-select-box's People

Contributors

amk221 avatar ctjhoa avatar grayt0r avatar krasnoukhov avatar philliphaines avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.