|
1 | | -# <vcf-toolbar-layout> |
| 1 | +# `<vcf-toolbar-layout>` |
2 | 2 |
|
3 | | -[](https://www.npmjs.com/package/@vaadin-component-factory/vcf-toolbar-layout) |
4 | | - |
5 | | -This is the LitElement based version of `<vcf-toolbar-layout>` Web Component. |
| 3 | +`<vcf-toolbar-layout>` is a LitElement‑based web component that manages overflowing menu items. It automatically moves overflowing items into a dedicated overflow popover, and it supports keyboard navigation, customizable theming, and grouping of items. While it works best with [Vaadin web components](https://vaadin.com/components), it supports any elements you choose to use. |
6 | 4 |
|
7 | 5 | ## Features |
8 | 6 |
|
9 | | -### Reverse collapse |
10 | | -Items collapse from the left side. |
| 7 | +- **Overflow Handling:** |
| 8 | + Automatically moves overflowing menu items into a dedicated popover. |
| 9 | +- **Configurable Collapse Debounce:** |
| 10 | + The `updateDebounceDelay` property sets the debounce delay (in milliseconds) from when a resize event occurs until the overflow items are updated. |
| 11 | +- **Reverse Collapse:** |
| 12 | + When the `reverse-collapse` attribute is set, the component collapses items from the left side instead of the right. |
| 13 | +- **Theming:** |
| 14 | + Two additional themes are provided (applied via the `theme` attribute): |
| 15 | + - **`fixed-width-prefix`** – aligns overflow popover items uniformly regardless of whether they include a prefix icon. |
| 16 | + - **`hide-icons`** – automatically hides icons on items within the overflow popover. |
| 17 | +- **Keyboard Navigation:** |
| 18 | + Complete keyboard support for menu navigation. |
| 19 | +- **Custom Overflow Button:** |
| 20 | + Use a custom overflow button by passing a button element with `slot="overflow-button"`. |
| 21 | +- **Grouping Items:** |
| 22 | + Group items by passing in a layout/container element; grouped items collapse and display together in the overflow popover. |
| 23 | + |
| 24 | +## Installation |
| 25 | + |
| 26 | +Install the component via npm: |
| 27 | + |
| 28 | +```bash |
| 29 | +npm install @vaadin-component-factory/vcf-toolbar-layout |
| 30 | +``` |
| 31 | + |
| 32 | +## Usage |
| 33 | + |
| 34 | +After installing, import the component into your application: |
| 35 | + |
| 36 | +```js |
| 37 | +import '@vaadin-component-factory/vcf-toolbar-layout'; |
| 38 | +``` |
| 39 | + |
| 40 | +### Basic Usage |
| 41 | + |
| 42 | +```html |
| 43 | +<vcf-toolbar-layout> |
| 44 | + <vaadin-button>Button 1</vaadin-button> |
| 45 | + <vaadin-button>Button 2</vaadin-button> |
| 46 | + <vaadin-button>Button 3</vaadin-button> |
| 47 | +</vcf-toolbar-layout> |
| 48 | +``` |
| 49 | + |
| 50 | +### Custom Overflow Button |
| 51 | + |
| 52 | +```html |
| 53 | +<vcf-toolbar-layout> |
| 54 | + <button slot="overflow-button" aria-label="More options">...</button> |
| 55 | + <vaadin-button>Button 1</vaadin-button> |
| 56 | + <vaadin-button>Button 2</vaadin-button> |
| 57 | +</vcf-toolbar-layout> |
| 58 | +``` |
| 59 | + |
| 60 | +### Reverse Collapse and Debounce Delay |
11 | 61 |
|
12 | | -#### HTML |
13 | 62 | ```html |
14 | | -<vcf-toolbar-layout reverse-collapse> |
15 | | - <button>Button 1</button> |
16 | | - <button>Button 2</button> |
| 63 | +<vcf-toolbar-layout reverse-collapse update-debounce-delay="100"> |
| 64 | + <vaadin-button>Left 1</vaadin-button> |
| 65 | + <vaadin-button>Left 2</vaadin-button> |
17 | 66 | </vcf-toolbar-layout> |
18 | 67 | ``` |
19 | 68 |
|
20 | | -#### Javascript |
21 | | -```javascript |
22 | | -document.querySelector('vcf-toolbar-layout').reverseCollapse = true; |
| 69 | +### Grouped Items |
| 70 | + |
| 71 | +```html |
| 72 | +<vcf-toolbar-layout> |
| 73 | + <div> |
| 74 | + <vaadin-button>Grouped A</vaadin-button> |
| 75 | + <vaadin-button>Grouped B</vaadin-button> |
| 76 | + </div> |
| 77 | + <vaadin-button>Solo</vaadin-button> |
| 78 | +</vcf-toolbar-layout> |
| 79 | +``` |
| 80 | + |
| 81 | +### Theming |
| 82 | + |
| 83 | +#### Fixed Width Prefix |
| 84 | + |
| 85 | +```html |
| 86 | +<vcf-toolbar-layout theme="fixed-width-prefix"> |
| 87 | + <vaadin-button theme="icon"> |
| 88 | + <vaadin-icon icon="vaadin:edit" slot="prefix"></vaadin-icon> |
| 89 | + Edit |
| 90 | + </vaadin-button> |
| 91 | + <vaadin-button> |
| 92 | + Save |
| 93 | + </vaadin-button> |
| 94 | +</vcf-toolbar-layout> |
23 | 95 | ``` |
24 | 96 |
|
25 | | -### Overflow update debounce delay |
26 | | -Specify the delay after a resize before the toolbar updates its overflow state. |
| 97 | +#### Hide Icons |
27 | 98 |
|
28 | | -#### HTML |
29 | 99 | ```html |
30 | | -<vcf-toolbar-layout update-debounce-delay="20"> |
31 | | - <button>Button 1</button> |
32 | | - <button>Button 2</button> |
| 100 | +<vcf-toolbar-layout theme="hide-icons"> |
| 101 | + <vaadin-button theme="icon"> |
| 102 | + <vaadin-icon icon="vaadin:trash" slot="prefix"></vaadin-icon> |
| 103 | + Delete |
| 104 | + </vaadin-button> |
| 105 | + <vaadin-button theme="icon"> |
| 106 | + <vaadin-icon icon="vaadin:download" slot="prefix"></vaadin-icon> |
| 107 | + Download |
| 108 | + </vaadin-button> |
33 | 109 | </vcf-toolbar-layout> |
34 | 110 | ``` |
35 | 111 |
|
36 | | -#### Javascript |
37 | | -```javascript |
38 | | -document.querySelector('vcf-toolbar-layout').updateDebounceDelay = 20; |
| 112 | +## Property Details |
| 113 | + |
| 114 | +- **`reverseCollapse` (Boolean):** |
| 115 | + When set (or used as the `reverse-collapse` attribute), the component collapses items from the left side. |
| 116 | + |
| 117 | +- **`updateDebounceDelay` (Number):** |
| 118 | + Sets the debounce delay (in milliseconds) from when a resize event occurs until the overflow items are updated—useful for managing performance during rapid resizes. |
| 119 | + |
| 120 | +## Running the Demo |
| 121 | + |
| 122 | +Clone the repository and install dependencies: |
| 123 | + |
| 124 | +```bash |
| 125 | +npm install |
| 126 | +npm start |
39 | 127 | ``` |
40 | 128 |
|
41 | | -## Running demo |
| 129 | +A demo page will launch in your browser, showcasing how `<vcf-toolbar-layout>` handles overflow, reverse collapse, custom overflow buttons, theming, grouping, and keyboard navigation. |
| 130 | + |
| 131 | +## Contributing |
| 132 | + |
| 133 | +Contributions are welcome! Please review our [contributing guidelines](CONTRIBUTING.md) before submitting pull requests. |
42 | 134 |
|
43 | | -1. Fork the `vcf-toolbar-layout` repository and clone it locally. |
| 135 | +## License |
44 | 136 |
|
45 | | -1. Make sure you have [npm](https://www.npmjs.com/) installed. |
| 137 | +Distributed under the Apache License 2.0. See [LICENSE](LICENSE) for details. |
46 | 138 |
|
47 | | -1. When in the `vcf-toolbar-layout` directory, run `npm install` to install dependencies. |
| 139 | +## Sponsored Development |
48 | 140 |
|
49 | | -1. Run `npm start` to open the demo. |
| 141 | +Major pieces of this component’s development have been sponsored by multiple Vaadin customers. Learn more about our support and pricing at [Vaadin Pricing](https://vaadin.com/pricing). |
0 commit comments