1.0.3 • Published 3 years ago

morph-dropdown v1.0.3

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

morph-dropdown

LitElement container that morphs between different dropdown items

Inspired by this

This package could use some refactoring, so pull requests are welcome.

Usage


import "morph-dropdown/morph-dropdown.js";
import "morph-dropdown/morph-dropdown-item.js";

While not required, This package works great with <mwc-button> and <mwc-list>

<morph-dropdown>

    <mwc-button>Non Dropdown Button</mwc-button>
    <morph-dropdown-item>
        <mwc-button slot="button">Non Dropdown Button</mwc-button>

        <mwc-list slot="dropdown">
            <mwc-list-item>First Dropdown</mwc-list-item>
            <mwc-list-item>Second Dropdown</mwc-list-item>
            <mwc-list-item>Third Dropdown</mwc-list-item>
        </mwc-list>
    </morph-dropdown-item>

</morph-dropdown>

Notes:

  • This package does not support nested dropdowns.

API


Slots

<morph-dropdown>

NameDescription
defaultAny elements can go here, but all <morph-dropdown-item> elements will share a morph material when nested in the same <morph-dropdown>

<morph-dropdown-item>

NameDescription
buttonWhen this element is hovered over, the dropdown slot will come into view
dropdownThe list of items to morph the background material to and fade in.
defaultNot supported

Properties/Attributes

<morph-dropdown>

NameTypeDefaultDescription
columnbooleanfalseChanges the css flex-direction of the item container from a row to a column

<morph-dropdown-item>

NameTypeDefaultDescription
centeredbooleanfalseWill justify-content: center; the :host{}
activebooleanfalseFades in the content. Used internally

CSS Custom Properties

<morph-dropdown>

NameDefaultDescription
--morph-dropdown-background#fffChanges the background of the morph material.