velocis 1.2.0 → 1.3.0
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/docs/dropdown1.md +87 -4
- package/package.json +6 -6
package/docs/dropdown1.md
CHANGED
|
@@ -58,7 +58,7 @@ const { open, setOpen, dropdownProps } = useDropdown1();
|
|
|
58
58
|
|
|
59
59
|
## Styling — coordinated colors
|
|
60
60
|
|
|
61
|
-
Every layer uses **bg + text + hover** pairs from `dropdown1Styles` (Velocis tokens by default). Override any layer via the `styles` prop
|
|
61
|
+
Every layer uses **bg + text + hover** pairs from `dropdown1Styles` (Velocis tokens by default). Override any layer via the `styles` prop. `subMenuContent` has its own default and does **not** inherit `content` unless you set both to the same classes.
|
|
62
62
|
|
|
63
63
|
```tsx
|
|
64
64
|
import { Dropdown1, dropdown1Styles } from 'velocis/dropdown1';
|
|
@@ -75,6 +75,7 @@ import { Dropdown1, dropdown1Styles } from 'velocis/dropdown1';
|
|
|
75
75
|
content: 'bg-slate-900 text-white border-slate-700 shadow-xl ring-1 ring-slate-700/50',
|
|
76
76
|
item: 'text-slate-100 hover:bg-slate-800 hover:text-white',
|
|
77
77
|
subMenuTrigger: 'text-slate-100 hover:bg-slate-800 hover:text-white',
|
|
78
|
+
subMenuContent: 'bg-indigo-950 text-indigo-100 border-indigo-800 shadow-xl',
|
|
78
79
|
subMenuIcon: 'text-slate-400',
|
|
79
80
|
}}
|
|
80
81
|
>
|
|
@@ -94,11 +95,91 @@ import { Dropdown1, dropdown1Styles } from 'velocis/dropdown1';
|
|
|
94
95
|
| `content` | `bg-velocis-background text-velocis-foreground …` | Main menu panel |
|
|
95
96
|
| `item` | `text-velocis-foreground hover:bg-velocis-border/40` | `Dropdown1.Item` |
|
|
96
97
|
| `subMenuTrigger` | same as `item` | Sub-menu row |
|
|
97
|
-
| `subMenuContent` |
|
|
98
|
+
| `subMenuContent` | independent panel default | Sub-menu panel |
|
|
98
99
|
| `subMenuIcon` | `text-velocis-muted` | Sub-menu chevron |
|
|
99
100
|
|
|
100
101
|
Export `dropdown1Styles` and `resolveDropdown1Styles` for app-wide presets.
|
|
101
102
|
|
|
103
|
+
## SubMenu placement
|
|
104
|
+
|
|
105
|
+
Control where the sub-menu panel opens relative to the **main menu panel** with the `placement` prop on `Dropdown1.SubMenu`.
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
left right (auto in LTR)
|
|
109
|
+
┌─────────┐ ┌─────────┐
|
|
110
|
+
│ SubMenu │◄── gap ──► │ Main │── gap ──► ┌─────────┐
|
|
111
|
+
└─────────┘ │ panel │ │ SubMenu │
|
|
112
|
+
└─────────┘ └─────────┘
|
|
113
|
+
|
|
114
|
+
center
|
|
115
|
+
┌─────────┐
|
|
116
|
+
│ Main │
|
|
117
|
+
│ panel │
|
|
118
|
+
└────┬────┘
|
|
119
|
+
▼
|
|
120
|
+
┌─────────┐
|
|
121
|
+
│ SubMenu │ (horizontally centered below panel)
|
|
122
|
+
└─────────┘
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
| `placement` | Position |
|
|
126
|
+
|-------------|----------|
|
|
127
|
+
| `'auto'` (default) | **RTL** → left of main panel — **LTR** → right of main panel |
|
|
128
|
+
| `'left'` | Always to the physical left of the main panel edge |
|
|
129
|
+
| `'right'` | Always to the physical right of the main panel edge |
|
|
130
|
+
| `'center'` | Below the main panel, horizontally centered |
|
|
131
|
+
|
|
132
|
+
Vertical alignment for `left` / `right` / `auto`: aligned with the sub-menu trigger row (natural cascade). For `center`: `top = panel.bottom + gap`.
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
// auto — follows DirectionProvider (RTL=left, LTR=right)
|
|
136
|
+
<Dropdown1.SubMenu trigger="More">...</Dropdown1.SubMenu>
|
|
137
|
+
|
|
138
|
+
// force physical sides
|
|
139
|
+
<Dropdown1.SubMenu placement="left" trigger="More">...</Dropdown1.SubMenu>
|
|
140
|
+
<Dropdown1.SubMenu placement="right" trigger="More">...</Dropdown1.SubMenu>
|
|
141
|
+
|
|
142
|
+
// below main panel, centered
|
|
143
|
+
<Dropdown1.SubMenu placement="center" trigger="More">...</Dropdown1.SubMenu>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## SubMenu background (independent from main panel)
|
|
147
|
+
|
|
148
|
+
The sub-menu panel can use a **different background** than the main menu:
|
|
149
|
+
|
|
150
|
+
| Method | Use when |
|
|
151
|
+
|--------|----------|
|
|
152
|
+
| `styles={{ subMenuContent: '…' }}` on root or `SubMenu` | Tailwind class override |
|
|
153
|
+
| `surface={{ background, tokens }}` on `Dropdown1.SubMenu` | Velocis surface API (same as root `surface`) |
|
|
154
|
+
| Root `styles.content` only | Main panel — does **not** change sub-menu unless you also set `subMenuContent` |
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
// White main menu + dark sub-menu via styles
|
|
158
|
+
<Dropdown1 trigger={<span>Menu</span>}>
|
|
159
|
+
<Dropdown1.Item>Item</Dropdown1.Item>
|
|
160
|
+
<Dropdown1.SubMenu
|
|
161
|
+
trigger="More"
|
|
162
|
+
styles={{
|
|
163
|
+
subMenuContent:
|
|
164
|
+
'bg-indigo-950 text-indigo-100 border border-indigo-800 shadow-xl',
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
<Dropdown1.Item>Sub item</Dropdown1.Item>
|
|
168
|
+
</Dropdown1.SubMenu>
|
|
169
|
+
</Dropdown1>
|
|
170
|
+
|
|
171
|
+
// Or surface on SubMenu only
|
|
172
|
+
<Dropdown1.SubMenu
|
|
173
|
+
trigger="More"
|
|
174
|
+
surface={{
|
|
175
|
+
background: '#1e1b4b',
|
|
176
|
+
tokens: { foreground: '#e0e7ff' },
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
...
|
|
180
|
+
</Dropdown1.SubMenu>
|
|
181
|
+
```
|
|
182
|
+
|
|
102
183
|
## Props — `Dropdown1`
|
|
103
184
|
|
|
104
185
|
| Prop | Default | Description |
|
|
@@ -131,13 +212,15 @@ Export `dropdown1Styles` and `resolveDropdown1Styles` for app-wide presets.
|
|
|
131
212
|
|------|---------|-------------|
|
|
132
213
|
| `trigger` | required | Sub-menu label |
|
|
133
214
|
| `children` | required | Nested `Dropdown1.Item` elements |
|
|
215
|
+
| `placement` | `'auto'` | `'auto' \| 'left' \| 'right' \| 'center'` — see [SubMenu placement](#submenu-placement) |
|
|
134
216
|
| `contentWidth` | `w-48` | Sub-menu panel width |
|
|
135
|
-
| `styles` | root sub-menu styles | Override
|
|
217
|
+
| `styles` | root sub-menu styles | Override `subMenuTrigger` / `subMenuContent` / `subMenuIcon` |
|
|
218
|
+
| `surface` | — | Independent panel surface (background, tokens) |
|
|
136
219
|
| `className` | — | Extra CSS on sub-menu panel |
|
|
137
220
|
|
|
138
221
|
## RTL / LTR
|
|
139
222
|
|
|
140
|
-
Dropdown1 respects `DirectionProvider` from `velocis/theme`. Sub-
|
|
223
|
+
Dropdown1 respects `DirectionProvider` from `velocis/theme`. Main panel alignment follows direction. Sub-menu `placement="auto"` opens toward inline-start in RTL (left of panel) and inline-end in LTR (right of panel). Use `placement="left"` or `"right"` for fixed physical sides.
|
|
141
224
|
|
|
142
225
|
## Accessibility
|
|
143
226
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "velocis",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Extremely dynamic RTL/LTR React UI component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -101,18 +101,18 @@
|
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@velocis/card": "0.2.0",
|
|
105
104
|
"@velocis/core": "0.1.0",
|
|
105
|
+
"@velocis/card": "0.2.0",
|
|
106
106
|
"@velocis/forms": "0.1.0",
|
|
107
107
|
"@velocis/feedback": "0.1.2",
|
|
108
108
|
"@velocis/navigation": "0.1.2",
|
|
109
|
-
"@velocis/hero": "0.1.0",
|
|
110
109
|
"@velocis/list": "0.1.2",
|
|
110
|
+
"@velocis/table": "0.1.2",
|
|
111
|
+
"@velocis/hero": "0.1.0",
|
|
111
112
|
"@velocis/table2": "0.2.2",
|
|
113
|
+
"@velocis/dropdown1": "0.4.0",
|
|
112
114
|
"@velocis/dialog1": "0.3.0",
|
|
113
|
-
"@velocis/theme": "0.2.0"
|
|
114
|
-
"@velocis/dropdown1": "0.3.0",
|
|
115
|
-
"@velocis/table": "0.1.2"
|
|
115
|
+
"@velocis/theme": "0.2.0"
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|
|
118
118
|
"tsup": "^8.3.5",
|