0.1.1 • Published 3 years ago

@evergreen-wc/eve-dropdown v0.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

eve-dropdown

An Evergreen Dropdown Web Component

Demo

Install

npm i @evergreen-wc/eve-dropdown

Usage

import { html, LitElement } from 'lit';
import '@evergreen-wc/eve-dropdown';

const options = [
  { value: 'value1', label: 'label1'},
  { value: 'value2', label: 'label2'},
  { value: 'value3', label: 'label3'},
];

class MyComponent extends LitElement {
  handleSelection(value, idx) {
    console.log('selected', value);
    console.log('index', idx);
  }

  render() {
    return html`
      <eve-dropdown label="Options..." .options='${options}' .optionSelectedCallback="${this.handleSelection.bind(this)}" ></eve-dropdown>
    `;
  }
}
customElements.define('my-component', MyComponent);

Props

PropertyDescription
labelThe initial text displayed for the dropdown and at the top of the expanded dropdown.
optionsAn array of objects containing value and label properties to display in dropdown.
optionSelectedCallbackA callback function for when an option is selected. Will be return the value and index of the selected item to the callback function.

Styling

/* Example style */
--primary-color: #41a6ef;
--secondary-color: #fff;
--dropdown-color: var(--primary-color);
--dropdown-border-color: var(--primary-color);
--dropdown-text-color: var(--secondary-color);
--dropdown-text-size: 1rem;
--dropdown-text-hover-color: var(--secondary-color);
--dropdown-text-expanded-color: var(--primary-color);
--dropdown-text-background-hover: var(--primary-color);
--dropdown-timing: .3s;
0.1.0

3 years ago

0.1.1

3 years ago

0.0.9

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago