@aurodesignsystem-dev/auro-layover
v0.0.0-pr4.0
Published
auro-layover HTML custom element
Readme
Layover
<auro-layover> is an HTML custom element that combines the functionality of html popover spec and floating-ui's js library into one utility.
UI development browser support
For the most up to date information on UI development browser support
Install
$ npm i @aurodesignsystem/auro-layoverDesign Token CSS Custom Property dependency
The use of any Auro custom element has a dependency on the Auro Design Tokens.
Define dependency in project component
Defining the component dependency within each component that is using the <auro-layover> component.
import "@aurodesignsystem/auro-layover";Reference component in HTML
<p>existing support example</p>
<button type="button" onclick="document.querySelector('auro-layover[behavior=dialog]').toggle()">Click Me For Dialog</button>
<auro-layover behavior="dialog">
<p>I am a dialog popover. I should be positioned fixed over the top of the page.</p>
</auro-layover>
<p> </p>
<p>dialog example</p>
<auro-layover behavior="dialog">
<button type="button" slot="trigger">Open Dialog</button>
<p>I am a dialog popover. I should be positioned fixed over the top of the page.</p>
<auro-layover>
<button type="button" slot="trigger">Open Nested Layover</button>
<p>This is a layover in a layover, it shouldn't close at the same time as the parent one.</p>
<auro-layover>
<button type="button" slot="trigger">Open 3rd Level Nested Layover</button>
<p>This is a 3rd level nested layover, it shouldn't close at the same time as the parent ones.</p>
</auro-layover>
</auro-layover>
</auro-layover>
<p> </p>
<p>dropdown example</p>
<auro-layover behavior="dropdown">
<button type="button" slot="trigger">Open Dropdown</button>
<p>I am a dropdown popover. I should be positioned next to my parent element/trigger.</p>
<input type="text" placeholder="I am an input inside a dropdown popover" />
<textarea placeholder="I am a textarea inside a dropdown popover"></textarea>
<button type="button" onclick="document.querySelector('auro-layover[behavior=dropdown]').hide()">Close Dropdown</button>
<auro-button>Auro Button Is Here</auro-button>
<button type="button" onclick="document.querySelector('auro-layover[behavior=dropdown]').hide()">Close Dropdown</button>
<input type="text" placeholder="I am an input inside a dropdown popover" />
<textarea placeholder="I am a textarea inside a dropdown popover"></textarea>
<p>Paragraph test</p>
<span>Span test</span>
</auro-layover>
<p> </p>
<p>tooltip (hover) example</p>
<auro-layover behavior="tooltip" placement="bottom">
<button type="button" slot="trigger">Hover For Tooltip</button>
<p>I am a tooltip popover. I open when the trigger is hovered.</p>
</auro-layover>
<p> </p>
<p>default input example</p>
<auro-layover behavior="input">
<auro-input slot="trigger" placeholder="Click to open input popover"></auro-input>
<auro-menu>
<auro-menuoption value="Apples" id="option-0">Apples</auro-menuoption>
<auro-menuoption value="Oranges" id="option-1">Oranges</auro-menuoption>
<auro-menuoption value="Peaches" id="option-2">Peaches</auro-menuoption>
<auro-menuoption value="Grapes" id="option-3">Grapes</auro-menuoption>
<auro-menuoption value="Cherries" id="option-4">Cherries</auro-menuoption>
</auro-menu>
</auro-layover>
<p> </p>
<p>input popover with minInputLength</p>
<auro-layover behavior="input" minInputLength="3">
<auro-input slot="trigger" placeholder="Click to open input popover"></auro-input>
<auro-menu>
<auro-menuoption value="Apples" id="option-0">Apples</auro-menuoption>
<auro-menuoption value="Oranges" id="option-1">Oranges</auro-menuoption>
<auro-menuoption value="Peaches" id="option-2">Peaches</auro-menuoption>
<auro-menuoption value="Grapes" id="option-3">Grapes</auro-menuoption>
<auro-menuoption value="Cherries" id="option-4">Cherries</auro-menuoption>
</auro-menu>
</auro-layover>
<p> </p>
<p>input popover with showOnFocus=false</p>
<auro-layover behavior="input" minInputLength="3" showOnFocus="false">
<auro-input slot="trigger" placeholder="Click to open input popover"></auro-input>
<auro-menu>
<auro-menuoption value="Apples" id="option-0">Apples</auro-menuoption>
<auro-menuoption value="Oranges" id="option-1">Oranges</auro-menuoption>
<auro-menuoption value="Peaches" id="option-2">Peaches</auro-menuoption>
<auro-menuoption value="Grapes" id="option-3">Grapes</auro-menuoption>
<auro-menuoption value="Cherries" id="option-4">Cherries</auro-menuoption>
</auro-menu>
</auro-layover>Use CDN
In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-layover@latest/+esm"></script>auro-layover use cases
The <auro-layover> element should be used in situations where users:
- Your example use case here
- Another condition where this component is useful
API Code Examples
Default auro-layover
<p>existing support example</p>
<button type="button" onclick="document.querySelector('auro-layover[behavior=dialog]').toggle()">Click Me For Dialog</button>
<auro-layover behavior="dialog">
<p>I am a dialog popover. I should be positioned fixed over the top of the page.</p>
</auro-layover>
<p> </p>
<p>dialog example</p>
<auro-layover behavior="dialog">
<button type="button" slot="trigger">Open Dialog</button>
<p>I am a dialog popover. I should be positioned fixed over the top of the page.</p>
<auro-layover>
<button type="button" slot="trigger">Open Nested Layover</button>
<p>This is a layover in a layover, it shouldn't close at the same time as the parent one.</p>
<auro-layover>
<button type="button" slot="trigger">Open 3rd Level Nested Layover</button>
<p>This is a 3rd level nested layover, it shouldn't close at the same time as the parent ones.</p>
</auro-layover>
</auro-layover>
</auro-layover>
<p> </p>
<p>dropdown example</p>
<auro-layover behavior="dropdown">
<button type="button" slot="trigger">Open Dropdown</button>
<p>I am a dropdown popover. I should be positioned next to my parent element/trigger.</p>
<input type="text" placeholder="I am an input inside a dropdown popover" />
<textarea placeholder="I am a textarea inside a dropdown popover"></textarea>
<button type="button" onclick="document.querySelector('auro-layover[behavior=dropdown]').hide()">Close Dropdown</button>
<auro-button>Auro Button Is Here</auro-button>
<button type="button" onclick="document.querySelector('auro-layover[behavior=dropdown]').hide()">Close Dropdown</button>
<input type="text" placeholder="I am an input inside a dropdown popover" />
<textarea placeholder="I am a textarea inside a dropdown popover"></textarea>
<p>Paragraph test</p>
<span>Span test</span>
</auro-layover>
<p> </p>
<p>tooltip (hover) example</p>
<auro-layover behavior="tooltip" placement="bottom">
<button type="button" slot="trigger">Hover For Tooltip</button>
<p>I am a tooltip popover. I open when the trigger is hovered.</p>
</auro-layover>
<p> </p>
<p>default input example</p>
<auro-layover behavior="input">
<auro-input slot="trigger" placeholder="Click to open input popover"></auro-input>
<auro-menu>
<auro-menuoption value="Apples" id="option-0">Apples</auro-menuoption>
<auro-menuoption value="Oranges" id="option-1">Oranges</auro-menuoption>
<auro-menuoption value="Peaches" id="option-2">Peaches</auro-menuoption>
<auro-menuoption value="Grapes" id="option-3">Grapes</auro-menuoption>
<auro-menuoption value="Cherries" id="option-4">Cherries</auro-menuoption>
</auro-menu>
</auro-layover>
<p> </p>
<p>input popover with minInputLength</p>
<auro-layover behavior="input" minInputLength="3">
<auro-input slot="trigger" placeholder="Click to open input popover"></auro-input>
<auro-menu>
<auro-menuoption value="Apples" id="option-0">Apples</auro-menuoption>
<auro-menuoption value="Oranges" id="option-1">Oranges</auro-menuoption>
<auro-menuoption value="Peaches" id="option-2">Peaches</auro-menuoption>
<auro-menuoption value="Grapes" id="option-3">Grapes</auro-menuoption>
<auro-menuoption value="Cherries" id="option-4">Cherries</auro-menuoption>
</auro-menu>
</auro-layover>
<p> </p>
<p>input popover with showOnFocus=false</p>
<auro-layover behavior="input" minInputLength="3" showOnFocus="false">
<auro-input slot="trigger" placeholder="Click to open input popover"></auro-input>
<auro-menu>
<auro-menuoption value="Apples" id="option-0">Apples</auro-menuoption>
<auro-menuoption value="Oranges" id="option-1">Oranges</auro-menuoption>
<auro-menuoption value="Peaches" id="option-2">Peaches</auro-menuoption>
<auro-menuoption value="Grapes" id="option-3">Grapes</auro-menuoption>
<auro-menuoption value="Cherries" id="option-4">Cherries</auro-menuoption>
</auro-menu>
</auro-layover>Development
In order to develop against this project, if you are not part of the core team, you will be required to fork the project prior to submitting a pull request.
Please be sure to review the contribution guidelines for this project. Please make sure to pay special attention to the conventional commits section of the document.
Start development environment
Once the project has been cloned to your local resource and you have installed all the dependencies you will need to open a shell session to run the dev server.
$ npm run devOpen localhost:8000
Testing
Automated tests are required for every Auro component. See .\test\auro-layover.test.js for the tests for this component. Run npm run test to run the tests and check code coverage. Tests must pass and meet a certain coverage threshold to commit. See the testing documentation for more details.
