jattac.libs.web.overflow-menu 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -181
- package/dist/Data/IOverflowMenuItem.d.ts +1 -0
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,209 +1,54 @@
|
|
|
1
1
|
# Jattac Overflow Menu
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A high-performance, accessible, and customizable React overflow menu component designed for modern web applications.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The Jattac Overflow Menu provides a robust solution for managing secondary actions in compact UI areas such as table rows, headers, and toolbars. Built on top of Radix UI primitives and animated with Framer Motion, it offers a refined user experience with full WAI-ARIA compliance and a modern frosted-glass aesthetic.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Key Features
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
- [Installation](#installation)
|
|
15
|
-
- [Getting Started](#getting-started)
|
|
16
|
-
- [API and Props](#api-and-props)
|
|
17
|
-
- [`OverflowMenu` Component](#overflowmenu-component)
|
|
18
|
-
- [`IOverflowMenuItem` Interface](#ioverflowmenuitem-interface)
|
|
19
|
-
- [Recipes: From Zero to Expert](#recipes-from-zero-to-expert)
|
|
20
|
-
- [Custom Trigger Icon](#custom-trigger-icon)
|
|
21
|
-
- [Rich Item Content](#rich-item-content)
|
|
22
|
-
- [Using a Portal](#using-a-portal)
|
|
23
|
-
- [Styling and Customization](#styling-and-customization)
|
|
24
|
-
- [Accessibility](#accessibility)
|
|
25
|
-
- [License](#license)
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## Why Jattac Overflow Menu?
|
|
30
|
-
|
|
31
|
-
This component is designed to be the last overflow menu you'll ever need. Here's the philosophy:
|
|
32
|
-
|
|
33
|
-
- **Headless at the Core:** We leverage the power of Radix UI to handle all the complex logic for state management, positioning, and accessibility. This means you get a battle-tested foundation that just works.
|
|
34
|
-
- **You Own the UI:** While we provide a default modern look and feel, you have 100% control over the rendering. Use our styles, or override them completely. It's your choice.
|
|
35
|
-
- **Animations Included:** We use Framer Motion to provide smooth, delightful animations out of the box.
|
|
36
|
-
- **Developer Experience First:** Our goal is to provide a component that is easy to learn, a joy to use, and powerful enough for advanced use cases.
|
|
9
|
+
- **Multi-Level Support:** Seamlessly handle nested submenus with recursive rendering and consistent animations.
|
|
10
|
+
- **Accessibility First:** Fully compliant with WAI-ARIA Menu Button patterns, including complete keyboard navigation and focus management.
|
|
11
|
+
- **Advanced Animations:** Smooth, spring-based interactions and staggered entry effects for a professional feel.
|
|
12
|
+
- **Portal Rendering:** Optional DOM portal support to resolve z-index and overflow clipping issues in complex layouts.
|
|
13
|
+
- **Developer-Centric:** Built with TypeScript for strict type safety and a flexible API that supports rich React nodes as menu content.
|
|
37
14
|
|
|
38
15
|
## Installation
|
|
39
16
|
|
|
40
|
-
Install the package
|
|
17
|
+
Install the package along with its required peer dependencies:
|
|
41
18
|
|
|
42
19
|
```bash
|
|
43
20
|
npm install jattac.libs.web.overflow-menu react react-dom framer-motion @radix-ui/react-dropdown-menu
|
|
44
21
|
```
|
|
45
22
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## Getting Started
|
|
23
|
+
## Quick Start
|
|
49
24
|
|
|
50
|
-
|
|
25
|
+
The following example demonstrates a basic implementation with three items.
|
|
51
26
|
|
|
52
|
-
```
|
|
27
|
+
```tsx
|
|
53
28
|
import React from 'react';
|
|
54
29
|
import OverflowMenu, { IOverflowMenuItem } from 'jattac.libs.web.overflow-menu';
|
|
55
|
-
import 'jattac.libs.web.overflow-menu/dist/index.css';
|
|
30
|
+
import 'jattac.libs.web.overflow-menu/dist/index.css';
|
|
56
31
|
|
|
57
32
|
const App = () => {
|
|
58
|
-
const
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
content: 'View Settings',
|
|
65
|
-
onClick: () => alert('Viewing Settings!'),
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
content: 'Log Out',
|
|
69
|
-
onClick: () => alert('Logging Out!'),
|
|
70
|
-
},
|
|
33
|
+
const items: IOverflowMenuItem[] = [
|
|
34
|
+
{ content: 'Edit', onClick: () => console.log('Edit') },
|
|
35
|
+
{ content: 'Settings', onClick: () => console.log('Settings') },
|
|
36
|
+
{ content: 'Delete', onClick: () => console.log('Delete') },
|
|
71
37
|
];
|
|
72
38
|
|
|
73
|
-
return
|
|
74
|
-
<div style={{ display: 'flex', justifyContent: 'flex-end', padding: '2rem' }}>
|
|
75
|
-
<OverflowMenu items={menuItems} />
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
39
|
+
return <OverflowMenu items={items} />;
|
|
78
40
|
};
|
|
79
|
-
|
|
80
|
-
export default App;
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## API and Props
|
|
84
|
-
|
|
85
|
-
### `OverflowMenu` Component
|
|
86
|
-
|
|
87
|
-
The `OverflowMenu` component accepts the following props:
|
|
88
|
-
|
|
89
|
-
| Prop | Type | Required | Default | Description |
|
|
90
|
-
|-------------|-----------------------|----------|-------------|------------------------------------------------------------------------------------------------------------|
|
|
91
|
-
| `items` | `IOverflowMenuItem[]` | Yes | - | An array of objects that define the menu items. |
|
|
92
|
-
| `icon` | `ReactNode` | No | `DefaultIcon` | A custom trigger icon to open the menu. |
|
|
93
|
-
| `className` | `string` | No | `''` | A CSS class to apply to the trigger button for custom styling. |
|
|
94
|
-
| `portal` | `HTMLElement` | No | `null` | A DOM element to render the menu into. Use this to prevent z-index issues with parent containers. |
|
|
95
|
-
|
|
96
|
-
### `IOverflowMenuItem` Interface
|
|
97
|
-
|
|
98
|
-
Each item in the `items` array must conform to this interface:
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
interface IOverflowMenuItem {
|
|
102
|
-
content: React.ReactNode; // The content to display for the item.
|
|
103
|
-
onClick?: () => void; // Function to call when the item is clicked.
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## Recipes: From Zero to Expert
|
|
110
|
-
|
|
111
|
-
Here are some common use cases to help you get the most out of the component.
|
|
112
|
-
|
|
113
|
-
### Custom Trigger Icon
|
|
114
|
-
|
|
115
|
-
You can provide any `ReactNode` as the trigger icon. This is great for using a custom SVG or an icon from a library like `react-icons`.
|
|
116
|
-
|
|
117
|
-
```jsx
|
|
118
|
-
import { BsThreeDotsVertical } from 'react-icons/bs';
|
|
119
|
-
// ...
|
|
120
|
-
<OverflowMenu items={menuItems} icon={<BsThreeDotsVertical size={24} />} />
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Rich Item Content
|
|
124
|
-
|
|
125
|
-
The `content` property of a menu item can be any valid `ReactNode`. This allows you to create rich menu items with icons, styled text, and more.
|
|
126
|
-
|
|
127
|
-
```jsx
|
|
128
|
-
import { FiEdit, FiLogOut } from 'react-icons/fi';
|
|
129
|
-
|
|
130
|
-
const richMenuItems: IOverflowMenuItem[] = [
|
|
131
|
-
{
|
|
132
|
-
content: (
|
|
133
|
-
<span style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
134
|
-
<FiEdit /> Edit Profile
|
|
135
|
-
</span>
|
|
136
|
-
),
|
|
137
|
-
onClick: () => alert('Editing Profile!'),
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
content: (
|
|
141
|
-
<span style={{ display: 'flex', alignItems: 'center', gap: '8px', color: 'red' }}>
|
|
142
|
-
<FiLogOut /> Log Out
|
|
143
|
-
</span>
|
|
144
|
-
),
|
|
145
|
-
onClick: () => alert('Logging Out!'),
|
|
146
|
-
},
|
|
147
|
-
];
|
|
148
|
-
|
|
149
|
-
// ...
|
|
150
|
-
<OverflowMenu items={richMenuItems} />
|
|
151
41
|
```
|
|
152
42
|
|
|
153
|
-
|
|
43
|
+
## Documentation Index
|
|
154
44
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return (
|
|
162
|
-
<div>
|
|
163
|
-
<OverflowMenu items={menuItems} portal={portalContainer} />
|
|
164
|
-
{/* ... other content ... */}
|
|
165
|
-
<div id="portal-container" />
|
|
166
|
-
</div>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
> **Best Practice:** Using a portal is highly recommended for menus that might be rendered inside complex layouts, such as tables, modals, or other components with their own stacking context.
|
|
45
|
+
1. [Cookbook: Practical Examples](./docs/examples.md) - **Start here** to learn through real-world scenarios.
|
|
46
|
+
2. [Feature Showcase](./docs/features.md) - A high-level overview of available capabilities.
|
|
47
|
+
3. [API Reference](./docs/api.md) - Detailed technical specifications for components and types.
|
|
48
|
+
4. [Configuration Guide](./docs/configuration.md) - Customization, styling, and global settings.
|
|
49
|
+
5. [Development Guide](./docs/development.md) - Instructions for contributors and local setup.
|
|
50
|
+
6. [Migration Guide](./docs/breaking-changes.md) - Handling updates and breaking changes.
|
|
172
51
|
|
|
173
52
|
---
|
|
174
53
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
The component is styled using CSS Modules, but it's designed to be easily customized. The underlying Radix UI components expose `data-` attributes that you can use to target specific states and parts of the menu.
|
|
178
|
-
|
|
179
|
-
Here are some of the most common selectors:
|
|
180
|
-
|
|
181
|
-
| Selector | Description |
|
|
182
|
-
|----------------------------------------|-------------------------------------------|
|
|
183
|
-
| `[data-state="open"]` | Applied to the trigger when the menu is open. |
|
|
184
|
-
| `[data-state="closed"]` | Applied to the trigger when the menu is closed. |
|
|
185
|
-
| `.jattac-overflow-menu-content` | The menu content container. |
|
|
186
|
-
| `.jattac-overflow-menu-item` | An individual menu item. |
|
|
187
|
-
| `[data-highlighted]` | Applied to a menu item when it is highlighted (e.g., on hover or with keyboard navigation). |
|
|
188
|
-
|
|
189
|
-
**Example: Overriding the background color of a highlighted item**
|
|
190
|
-
|
|
191
|
-
```css
|
|
192
|
-
/* In your application's global CSS file */
|
|
193
|
-
.jattac-overflow-menu-item[data-highlighted] {
|
|
194
|
-
background-color: #f0f0f0;
|
|
195
|
-
color: #333;
|
|
196
|
-
}
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Accessibility
|
|
200
|
-
|
|
201
|
-
This component is built on top of Radix UI's Dropdown Menu, which is fully accessible and follows the [WAI-ARIA Menu Button design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/menubutton/).
|
|
202
|
-
|
|
203
|
-
- **Keyboard Navigation:** Full keyboard support for opening, closing, and navigating the menu.
|
|
204
|
-
- **Focus Management:** Focus is automatically managed, moving to the menu when it opens and returning to the trigger when it closes.
|
|
205
|
-
- **ARIA Attributes:** All necessary ARIA attributes are automatically applied.
|
|
206
|
-
|
|
207
|
-
## License
|
|
208
|
-
|
|
209
|
-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
54
|
+
[Next: Cookbook](./docs/examples.md)
|