@blankways/ui 0.1.0-alpha.1 → 0.2.0-alpha.1

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.
Files changed (185) hide show
  1. package/README.md +157 -139
  2. package/dist/cli/cli.options.js +21 -1
  3. package/dist/cli/cli.types.d.ts +1 -0
  4. package/dist/cli.js +2 -1
  5. package/dist/commands/add.command.d.ts +2 -0
  6. package/dist/commands/add.command.js +30 -82
  7. package/dist/commands/dev.command.d.ts +3 -0
  8. package/dist/commands/dev.command.js +76 -0
  9. package/dist/commands/doctor.command.js +12 -1
  10. package/dist/commands/index.d.ts +3 -0
  11. package/dist/commands/index.js +3 -0
  12. package/dist/commands/init.command.js +15 -10
  13. package/dist/commands/install.command.d.ts +2 -0
  14. package/dist/commands/install.command.js +36 -0
  15. package/dist/commands/list.command.js +10 -5
  16. package/dist/commands/registry.command.d.ts +2 -0
  17. package/dist/commands/registry.command.js +69 -0
  18. package/dist/commands/styles.command.d.ts +1 -2
  19. package/dist/commands/styles.command.js +15 -39
  20. package/dist/config/config.helpers.d.ts +4 -1
  21. package/dist/config/config.helpers.js +61 -8
  22. package/dist/constants/cli.constants.d.ts +14 -3
  23. package/dist/constants/cli.constants.js +14 -9
  24. package/dist/doctor/checks/barrels.check.d.ts +1 -0
  25. package/dist/doctor/checks/barrels.check.js +60 -0
  26. package/dist/doctor/checks/contracts.check.d.ts +1 -0
  27. package/dist/doctor/checks/contracts.check.js +45 -0
  28. package/dist/doctor/checks/icons.check.js +8 -3
  29. package/dist/doctor/checks/index.d.ts +3 -0
  30. package/dist/doctor/checks/index.js +3 -0
  31. package/dist/doctor/checks/motion.check.js +2 -2
  32. package/dist/doctor/checks/namespaces.check.d.ts +1 -0
  33. package/dist/doctor/checks/namespaces.check.js +76 -0
  34. package/dist/doctor/checks/themes.check.js +18 -40
  35. package/dist/doctor/doctor.helpers.js +5 -1
  36. package/dist/doctor/doctor.types.d.ts +4 -0
  37. package/dist/helpers/args.helpers.d.ts +2 -0
  38. package/dist/helpers/args.helpers.js +9 -0
  39. package/dist/helpers/barrels.helpers.d.ts +15 -0
  40. package/dist/helpers/barrels.helpers.js +157 -0
  41. package/dist/index.d.ts +12 -9
  42. package/dist/index.js +11 -9
  43. package/dist/registry/index.d.ts +2 -0
  44. package/dist/registry/index.js +2 -0
  45. package/dist/registry/lockfile.d.ts +18 -0
  46. package/dist/registry/lockfile.js +32 -0
  47. package/dist/registry/registry.helpers.d.ts +3 -13
  48. package/dist/registry/registry.helpers.js +30 -116
  49. package/dist/registry/registry.providers.d.ts +13 -0
  50. package/dist/registry/registry.providers.js +159 -0
  51. package/dist/registry/registry.service.d.ts +14 -0
  52. package/dist/registry/registry.service.js +126 -0
  53. package/dist/types/config.types.d.ts +29 -0
  54. package/dist/types/registry.types.d.ts +31 -0
  55. package/dist/types/registry.types.js +2 -0
  56. package/dist/ui-api/index.d.ts +16 -0
  57. package/dist/ui-api/index.js +30 -0
  58. package/dist/ui-api/ui-api.d.ts +18 -0
  59. package/dist/ui-api/ui-api.js +194 -0
  60. package/package.json +7 -5
  61. package/styles.css +16 -0
  62. package/dist/registry-data/README.md +0 -71
  63. package/dist/registry-data/avatar/Avatar.tsx +0 -64
  64. package/dist/registry-data/avatar/component.json +0 -30
  65. package/dist/registry-data/avatar/index.ts +0 -1
  66. package/dist/registry-data/badge/Badge.tsx +0 -76
  67. package/dist/registry-data/badge/component.json +0 -30
  68. package/dist/registry-data/badge/index.ts +0 -1
  69. package/dist/registry-data/brand-logo/BrandLogo.tsx +0 -24
  70. package/dist/registry-data/brand-logo/component.json +0 -26
  71. package/dist/registry-data/brand-logo/index.ts +0 -1
  72. package/dist/registry-data/button/Button.tsx +0 -76
  73. package/dist/registry-data/button/component.json +0 -33
  74. package/dist/registry-data/button/index.ts +0 -1
  75. package/dist/registry-data/button-link/ButtonLink.tsx +0 -83
  76. package/dist/registry-data/button-link/component.json +0 -33
  77. package/dist/registry-data/button-link/index.ts +0 -5
  78. package/dist/registry-data/button-styles/component.json +0 -19
  79. package/dist/registry-data/button-styles/index.ts +0 -45
  80. package/dist/registry-data/cn/cn.ts +0 -6
  81. package/dist/registry-data/cn/component.json +0 -16
  82. package/dist/registry-data/confirm-dialog/ConfirmDialog.tsx +0 -134
  83. package/dist/registry-data/confirm-dialog/component.json +0 -34
  84. package/dist/registry-data/confirm-dialog/index.ts +0 -1
  85. package/dist/registry-data/container/Container.tsx +0 -22
  86. package/dist/registry-data/container/component.json +0 -28
  87. package/dist/registry-data/container/index.ts +0 -1
  88. package/dist/registry-data/cursor-glow/CursorGlow.tsx +0 -29
  89. package/dist/registry-data/cursor-glow/component.json +0 -28
  90. package/dist/registry-data/cursor-glow/index.ts +0 -1
  91. package/dist/registry-data/dropdown-menu/DropdownMenu.tsx +0 -157
  92. package/dist/registry-data/dropdown-menu/component.json +0 -34
  93. package/dist/registry-data/dropdown-menu/index.ts +0 -5
  94. package/dist/registry-data/empty-state/EmptyState.tsx +0 -92
  95. package/dist/registry-data/empty-state/component.json +0 -30
  96. package/dist/registry-data/empty-state/index.ts +0 -5
  97. package/dist/registry-data/eyebrow/Eyebrow.tsx +0 -68
  98. package/dist/registry-data/eyebrow/component.json +0 -30
  99. package/dist/registry-data/eyebrow/index.ts +0 -1
  100. package/dist/registry-data/field-styles/component.json +0 -19
  101. package/dist/registry-data/field-styles/index.ts +0 -42
  102. package/dist/registry-data/form-dialog/FormDialog.tsx +0 -128
  103. package/dist/registry-data/form-dialog/component.json +0 -34
  104. package/dist/registry-data/form-dialog/index.ts +0 -1
  105. package/dist/registry-data/icons/component.json +0 -22
  106. package/dist/registry-data/icons/index.ts +0 -21
  107. package/dist/registry-data/icons-form/component.json +0 -17
  108. package/dist/registry-data/icons-form/index.ts +0 -1
  109. package/dist/registry-data/icons-sidebar/component.json +0 -17
  110. package/dist/registry-data/icons-sidebar/index.ts +0 -1
  111. package/dist/registry-data/icons-theme/component.json +0 -17
  112. package/dist/registry-data/icons-theme/index.ts +0 -1
  113. package/dist/registry-data/icons-toast/component.json +0 -17
  114. package/dist/registry-data/icons-toast/index.ts +0 -1
  115. package/dist/registry-data/info-dialog/InfoDialog.tsx +0 -119
  116. package/dist/registry-data/info-dialog/component.json +0 -36
  117. package/dist/registry-data/info-dialog/index.ts +0 -1
  118. package/dist/registry-data/input/Input.tsx +0 -96
  119. package/dist/registry-data/input/component.json +0 -33
  120. package/dist/registry-data/input/index.ts +0 -1
  121. package/dist/registry-data/multi-combobox/MultiCombobox.tsx +0 -205
  122. package/dist/registry-data/multi-combobox/component.json +0 -35
  123. package/dist/registry-data/multi-combobox/index.ts +0 -5
  124. package/dist/registry-data/remote-provider/RemoteProvider.tsx +0 -8
  125. package/dist/registry-data/remote-provider/component.json +0 -25
  126. package/dist/registry-data/remote-provider/index.ts +0 -3
  127. package/dist/registry-data/reveal/Reveal.tsx +0 -22
  128. package/dist/registry-data/reveal/component.json +0 -30
  129. package/dist/registry-data/reveal/index.ts +0 -1
  130. package/dist/registry-data/section/Section.tsx +0 -80
  131. package/dist/registry-data/section/component.json +0 -30
  132. package/dist/registry-data/section/index.ts +0 -1
  133. package/dist/registry-data/section-heading/SectionHeading.tsx +0 -105
  134. package/dist/registry-data/section-heading/component.json +0 -32
  135. package/dist/registry-data/section-heading/index.ts +0 -1
  136. package/dist/registry-data/select/Select.tsx +0 -197
  137. package/dist/registry-data/select/component.json +0 -34
  138. package/dist/registry-data/select/index.ts +0 -1
  139. package/dist/registry-data/sidebar/Sidebar.tsx +0 -432
  140. package/dist/registry-data/sidebar/SidebarCollapsible.tsx +0 -77
  141. package/dist/registry-data/sidebar/SidebarParts.tsx +0 -373
  142. package/dist/registry-data/sidebar/component.json +0 -47
  143. package/dist/registry-data/sidebar/index.ts +0 -4
  144. package/dist/registry-data/sidebar/useSidebar.ts +0 -29
  145. package/dist/registry-data/styles-base/component.json +0 -19
  146. package/dist/registry-data/styles-base/index.css +0 -67
  147. package/dist/registry-data/styles-components/component.json +0 -19
  148. package/dist/registry-data/styles-components/index.css +0 -30
  149. package/dist/registry-data/styles-motion/component.json +0 -20
  150. package/dist/registry-data/styles-motion/index.css +0 -381
  151. package/dist/registry-data/styles-tokens/component.json +0 -17
  152. package/dist/registry-data/styles-tokens/index.css +0 -77
  153. package/dist/registry-data/styles-utilities/component.json +0 -19
  154. package/dist/registry-data/styles-utilities/index.css +0 -29
  155. package/dist/registry-data/switch/Switch.tsx +0 -91
  156. package/dist/registry-data/switch/component.json +0 -34
  157. package/dist/registry-data/switch/index.ts +0 -1
  158. package/dist/registry-data/tabs/Tabs.tsx +0 -226
  159. package/dist/registry-data/tabs/component.json +0 -32
  160. package/dist/registry-data/tabs/index.ts +0 -1
  161. package/dist/registry-data/textarea/Textarea.tsx +0 -94
  162. package/dist/registry-data/textarea/component.json +0 -33
  163. package/dist/registry-data/textarea/index.ts +0 -1
  164. package/dist/registry-data/theme-core/component.json +0 -17
  165. package/dist/registry-data/theme-core/theme.ts +0 -84
  166. package/dist/registry-data/theme-dark/component.json +0 -19
  167. package/dist/registry-data/theme-dark/index.ts +0 -7
  168. package/dist/registry-data/theme-light/component.json +0 -19
  169. package/dist/registry-data/theme-light/index.ts +0 -7
  170. package/dist/registry-data/theme-provider/ThemeContext.tsx +0 -177
  171. package/dist/registry-data/theme-provider/component.json +0 -30
  172. package/dist/registry-data/theme-provider/index.ts +0 -2
  173. package/dist/registry-data/theme-selector/ThemeSelector.tsx +0 -269
  174. package/dist/registry-data/theme-selector/component.json +0 -35
  175. package/dist/registry-data/theme-selector/selector.ts +0 -1
  176. package/dist/registry-data/theme-system/component.json +0 -19
  177. package/dist/registry-data/theme-system/index.ts +0 -7
  178. package/dist/registry-data/theme-toggle/ThemeToggle.tsx +0 -71
  179. package/dist/registry-data/theme-toggle/component.json +0 -31
  180. package/dist/registry-data/theme-toggle/toggle.ts +0 -1
  181. package/dist/registry-data/toast/Toast.tsx +0 -260
  182. package/dist/registry-data/toast/ToastTypeIcon.tsx +0 -83
  183. package/dist/registry-data/toast/component.json +0 -43
  184. package/dist/registry-data/toast/index.ts +0 -3
  185. package/dist/registry-data/toast/useToast.ts +0 -47
@@ -1,373 +0,0 @@
1
- import { State, type StateId } from '@blankways/state'
2
- import {
3
- Show,
4
- useAttributes,
5
- useCompute,
6
- useMatch,
7
- useState,
8
- } from '@blankways/state-react'
9
- import {
10
- useEffect,
11
- type ComponentProps,
12
- type ComponentPropsWithoutRef,
13
- type ReactNode,
14
- } from 'react'
15
- import { cn } from '../../internals/cn.js'
16
- import { useSidebar, type SidebarState } from './useSidebar.js'
17
-
18
- // Module-level, stable cases for `useMatch`.
19
- const ACTIVE_CASES = [true, false] as const
20
-
21
- /** Accepts either a plain boolean or a reactive boolean StateId. */
22
- function useBooleanState(value: boolean | StateId<boolean> | undefined) {
23
- const fallback = useState<boolean>(
24
- typeof value === 'number' ? State.get(value) : value === true,
25
- )
26
- useEffect(() => {
27
- if (typeof value === 'boolean') State.set(fallback, value)
28
- }, [fallback, value])
29
- return typeof value === 'number' ? value : fallback
30
- }
31
-
32
- export function SidebarHeader({ className, ...props }: ComponentProps<'div'>) {
33
- return (
34
- <div
35
- data-slot="sidebar-header"
36
- data-sidebar="header"
37
- className={cn('flex flex-col gap-2 p-[0.5625rem]', className)}
38
- {...props}
39
- />
40
- )
41
- }
42
-
43
- export function SidebarFooter({ className, ...props }: ComponentProps<'div'>) {
44
- return (
45
- <div
46
- data-slot="sidebar-footer"
47
- data-sidebar="footer"
48
- className={cn('flex flex-col gap-2 p-[0.5625rem]', className)}
49
- {...props}
50
- />
51
- )
52
- }
53
-
54
- export function SidebarSeparator({
55
- className,
56
- ...props
57
- }: ComponentProps<'div'>) {
58
- return (
59
- <div
60
- role="separator"
61
- data-slot="sidebar-separator"
62
- className={cn('mx-3 h-px bg-sidebar-border', className)}
63
- {...props}
64
- />
65
- )
66
- }
67
-
68
- export function SidebarContent({ className, ...props }: ComponentProps<'div'>) {
69
- return (
70
- <div
71
- data-slot="sidebar-content"
72
- data-sidebar="content"
73
- className={cn(
74
- 'flex min-h-0 flex-1 flex-col overflow-auto group-data-[collapsible=icon]:overflow-hidden',
75
- className,
76
- )}
77
- {...props}
78
- />
79
- )
80
- }
81
-
82
- export function SidebarGroup({ className, ...props }: ComponentProps<'div'>) {
83
- return (
84
- <div
85
- data-slot="sidebar-group"
86
- data-sidebar="group"
87
- className={cn('relative flex w-full min-w-0 flex-col p-[0.5625rem]', className)}
88
- {...props}
89
- />
90
- )
91
- }
92
-
93
- export function SidebarGroupLabel({
94
- className,
95
- ...props
96
- }: ComponentProps<'div'>) {
97
- return (
98
- <div
99
- data-slot="sidebar-group-label"
100
- data-sidebar="group-label"
101
- className={cn(
102
- 'sidebar-label flex h-8 shrink-0 items-center rounded-2xl px-1.5 text-xs font-semibold tracking-[0.12em] text-sidebar-foreground/60 uppercase outline-hidden group-data-[collapsible=icon]:opacity-0',
103
- className,
104
- )}
105
- {...props}
106
- />
107
- )
108
- }
109
-
110
- /** Small action button placed next to a group label. */
111
- export function SidebarGroupAction({
112
- className,
113
- label = 'Group action',
114
- ...props
115
- }: ComponentProps<'button'> & { label?: string }) {
116
- return (
117
- <button
118
- type="button"
119
- aria-label={label}
120
- data-slot="sidebar-group-action"
121
- data-sidebar="group-action"
122
- className={cn(
123
- 'absolute top-1 right-3 flex size-7 items-center justify-center rounded-2xl text-sidebar-foreground/60 outline-hidden motion-color hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring [&_svg]:size-4',
124
- className,
125
- )}
126
- {...props}
127
- />
128
- )
129
- }
130
-
131
- export function SidebarGroupContent({
132
- className,
133
- ...props
134
- }: ComponentProps<'div'>) {
135
- return (
136
- <div
137
- data-slot="sidebar-group-content"
138
- data-sidebar="group-content"
139
- className={cn('w-full text-sm', className)}
140
- {...props}
141
- />
142
- )
143
- }
144
-
145
- export function SidebarMenu({ className, ...props }: ComponentProps<'ul'>) {
146
- return (
147
- <ul
148
- data-slot="sidebar-menu"
149
- data-sidebar="menu"
150
- className={cn('flex w-full min-w-0 flex-col gap-1', className)}
151
- {...props}
152
- />
153
- )
154
- }
155
-
156
- export function SidebarMenuItem({ className, ...props }: ComponentProps<'li'>) {
157
- return (
158
- <li
159
- data-slot="sidebar-menu-item"
160
- data-sidebar="menu-item"
161
- className={cn('group/menu-item relative', className)}
162
- {...props}
163
- />
164
- )
165
- }
166
-
167
- const MENU_BUTTON =
168
- 'sidebar-highlight peer/menu-button group/menu-button flex w-full items-center gap-3 overflow-hidden rounded-2xl text-left text-sm font-medium text-sidebar-foreground/80 outline-hidden motion-color ' +
169
- 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground ' +
170
- 'focus-visible:ring-2 focus-visible:ring-sidebar-ring ' +
171
- 'data-[active=true]:bg-sidebar-active data-[active=true]:text-sidebar-foreground data-[active=true]:[&_svg]:text-brand-500 ' +
172
- 'disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 ' +
173
- 'group-data-[collapsible=icon]:size-9! ' +
174
- '[&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate'
175
-
176
- const MENU_BUTTON_SIZE = {
177
- default: 'p-[0.469rem] group-data-[collapsible=icon]:p-[0.469rem]!',
178
- lg: 'h-12 p-1.5 group-data-[collapsible=icon]:p-[0.094rem]!',
179
- } as const
180
-
181
- type SidebarMenuButtonProps = ComponentPropsWithoutRef<'button'> & {
182
- /** Marks the current page. Accepts a boolean or a reactive boolean. */
183
- isActive?: boolean | StateId<boolean>
184
- /** `lg` fits an avatar and two lines of text. */
185
- size?: keyof typeof MENU_BUTTON_SIZE
186
- /** Label shown beside the icon when the sidebar is collapsed. */
187
- tooltip?: ReactNode
188
- /** Close the mobile drawer on tap. Turn off for buttons that open a popup. */
189
- closeOnClick?: boolean
190
- }
191
-
192
- /**
193
- * One entry of the menu. Closing the drawer and showing the collapsed tooltip
194
- * are handled here; active styling is reactive through `useMatch`.
195
- */
196
- export function SidebarMenuButton({
197
- isActive,
198
- size = 'default',
199
- tooltip,
200
- closeOnClick = true,
201
- className,
202
- onClick,
203
- children,
204
- ...props
205
- }: SidebarMenuButtonProps) {
206
- const { state, isMobile, openMobile } = useSidebar()
207
- const activeState = useBooleanState(isActive)
208
- const [active] = useMatch(activeState, ACTIVE_CASES)
209
- const showTooltip = useCompute<[StateId<SidebarState>, StateId<boolean>], boolean>(
210
- [state, isMobile],
211
- ([current, mobile]) =>
212
- current === 'collapsed' && !mobile && tooltip !== undefined,
213
- )
214
- const bind = useAttributes<HTMLButtonElement>({ 'data-active': active })
215
-
216
- const button = (
217
- <button
218
- ref={bind}
219
- type="button"
220
- data-slot="sidebar-menu-button"
221
- data-sidebar="menu-button"
222
- onClick={(event) => {
223
- onClick?.(event)
224
- if (closeOnClick && State.get(openMobile)) {
225
- State.set(openMobile, false)
226
- }
227
- }}
228
- className={cn(MENU_BUTTON, MENU_BUTTON_SIZE[size], className)}
229
- {...props}
230
- >
231
- {children}
232
- </button>
233
- )
234
-
235
- if (!tooltip) return button
236
-
237
- return (
238
- <div className="group/menu-button relative flex w-full">
239
- {button}
240
- <Show when={showTooltip}>
241
- <span className="pointer-events-none absolute top-1/2 left-full z-50 ml-2 -translate-y-1/2 rounded-2xl bg-contrast px-[0.469rem] py-1.5 text-xs font-medium text-on-contrast opacity-0 shadow-lg motion-fade group-hover/menu-button:opacity-100 group-focus-within/menu-button:opacity-100">
242
- {tooltip}
243
- </span>
244
- </Show>
245
- </div>
246
- )
247
- }
248
-
249
- /** Trailing action of a menu row, e.g. a “more” button. */
250
- export function SidebarMenuAction({
251
- className,
252
- ...props
253
- }: ComponentProps<'button'>) {
254
- return (
255
- <button
256
- type="button"
257
- data-slot="sidebar-menu-action"
258
- data-sidebar="menu-action"
259
- className={cn(
260
- 'absolute top-1/2 right-1 flex size-6 -translate-y-1/2 items-center justify-center rounded-2xl text-sidebar-foreground/60 outline-hidden motion-color hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring [&_svg]:size-3.5',
261
- className,
262
- )}
263
- {...props}
264
- />
265
- )
266
- }
267
-
268
- /** Count or shortcut badge shown at the end of a menu row. */
269
- export function SidebarMenuBadge({ className, ...props }: ComponentProps<'div'>) {
270
- return (
271
- <div
272
- data-slot="sidebar-menu-badge"
273
- data-sidebar="menu-badge"
274
- className={cn(
275
- 'ml-auto flex h-5 min-w-5 items-center justify-center rounded-2xl px-[0.188rem] text-xs font-medium text-sidebar-foreground/60 tabular-nums',
276
- className,
277
- )}
278
- {...props}
279
- />
280
- )
281
- }
282
-
283
- /** Loading placeholder for a menu row. */
284
- export function SidebarMenuSkeleton({
285
- showIcon = false,
286
- className,
287
- ...props
288
- }: ComponentProps<'div'> & { showIcon?: boolean }) {
289
- return (
290
- <div
291
- data-slot="sidebar-menu-skeleton"
292
- data-sidebar="menu-skeleton"
293
- className={cn('flex h-9 items-center gap-3 rounded-2xl px-[0.469rem]', className)}
294
- {...props}
295
- >
296
- {showIcon ? (
297
- <span className="shimmer size-4 shrink-0 rounded-2xl bg-sidebar-accent" />
298
- ) : null}
299
- <span className="shimmer h-3 w-24 rounded-2xl bg-sidebar-accent" />
300
- </div>
301
- )
302
- }
303
-
304
- /** Shared classes so `Show` can toggle a native submenu element directly. */
305
- export const SIDEBAR_MENU_SUB_CLASS =
306
- 'ml-5 flex min-w-0 flex-col gap-1 border-l border-sidebar-border py-[0.188rem] pl-[0.5625rem] group-data-[collapsible=icon]:hidden'
307
-
308
- /** Nested list under a menu entry, drawn with a guide line. */
309
- export function SidebarMenuSub({ className, ...props }: ComponentProps<'ul'>) {
310
- return (
311
- <ul
312
- data-slot="sidebar-menu-sub"
313
- data-sidebar="menu-sub"
314
- className={cn(SIDEBAR_MENU_SUB_CLASS, className)}
315
- {...props}
316
- />
317
- )
318
- }
319
-
320
- export function SidebarMenuSubItem({
321
- className,
322
- ...props
323
- }: ComponentProps<'li'>) {
324
- return (
325
- <li
326
- data-slot="sidebar-menu-sub-item"
327
- data-sidebar="menu-sub-item"
328
- className={cn('relative', className)}
329
- {...props}
330
- />
331
- )
332
- }
333
-
334
- type SidebarMenuSubButtonProps = ComponentPropsWithoutRef<'a'> & {
335
- isActive?: boolean | StateId<boolean>
336
- }
337
-
338
- /** One entry of a nested list. */
339
- export function SidebarMenuSubButton({
340
- isActive,
341
- className,
342
- onClick,
343
- children,
344
- ...props
345
- }: SidebarMenuSubButtonProps) {
346
- const { isMobile, openMobile } = useSidebar()
347
- const activeState = useBooleanState(isActive)
348
- const [active] = useMatch(activeState, ACTIVE_CASES)
349
- const bind = useAttributes<HTMLAnchorElement>({ 'data-active': active })
350
-
351
- return (
352
- <a
353
- ref={bind}
354
- data-slot="sidebar-menu-sub-button"
355
- data-sidebar="menu-sub-button"
356
- onClick={(event) => {
357
- onClick?.(event)
358
- if (State.get(openMobile) && State.get(isMobile)) {
359
- State.set(openMobile, false)
360
- }
361
- }}
362
- className={cn(
363
- 'flex h-8 w-full items-center gap-2 rounded-2xl px-[0.469rem] text-sm text-sidebar-foreground/70 outline-hidden motion-color',
364
- 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring',
365
- 'data-[active=true]:bg-sidebar-active data-[active=true]:font-medium data-[active=true]:text-sidebar-foreground',
366
- className,
367
- )}
368
- {...props}
369
- >
370
- {children}
371
- </a>
372
- )
373
- }
@@ -1,47 +0,0 @@
1
- {
2
- "name": "sidebar",
3
- "kind": "component",
4
- "framework": "react",
5
- "description": "Native React sidebar with a responsive drawer, collapsible states and keyboard shortcut.",
6
- "dependencies": [
7
- "cn",
8
- "icons-sidebar",
9
- "styles-motion"
10
- ],
11
- "peers": [
12
- "@blankways/state",
13
- "@blankways/state-react@0.1.0-alpha.1",
14
- "lucide-react",
15
- "react",
16
- "react-dom"
17
- ],
18
- "suggestions": [
19
- "styles-tokens",
20
- "styles-base",
21
- "styles-components",
22
- "styles-utilities",
23
- "styles-motion"
24
- ],
25
- "files": [
26
- {
27
- "source": "Sidebar.tsx",
28
- "target": "components/sidebar/Sidebar.tsx"
29
- },
30
- {
31
- "source": "SidebarParts.tsx",
32
- "target": "components/sidebar/SidebarParts.tsx"
33
- },
34
- {
35
- "source": "SidebarCollapsible.tsx",
36
- "target": "components/sidebar/SidebarCollapsible.tsx"
37
- },
38
- {
39
- "source": "useSidebar.ts",
40
- "target": "components/sidebar/useSidebar.ts"
41
- },
42
- {
43
- "source": "index.ts",
44
- "target": "components/sidebar/index.ts"
45
- }
46
- ]
47
- }
@@ -1,4 +0,0 @@
1
- export * from './Sidebar.js'
2
- export * from './SidebarCollapsible.js'
3
- export * from './SidebarParts.js'
4
- export * from './useSidebar.js'
@@ -1,29 +0,0 @@
1
- import type { StateId } from '@blankways/state'
2
- import { createContext, useContext } from 'react'
3
-
4
- export type SidebarState = 'expanded' | 'collapsed'
5
-
6
- /** State and controls shared by every sidebar part. */
7
- export type SidebarContextValue = {
8
- open: StateId<boolean>
9
- openMobile: StateId<boolean>
10
- isMobile: StateId<boolean>
11
- state: StateId<SidebarState>
12
- collapsed: StateId<boolean>
13
- /** React mirror of `isMobile`, used to pick the drawer layout. */
14
- isMobileView: boolean
15
- setOpen: (open: boolean) => void
16
- setOpenMobile: (open: boolean) => void
17
- toggleSidebar: () => void
18
- }
19
-
20
- export const SidebarContext = createContext<SidebarContextValue | null>(null)
21
-
22
- /** Reads the state and controls of the closest `SidebarProvider`. */
23
- export function useSidebar(): SidebarContextValue {
24
- const context = useContext(SidebarContext)
25
- if (!context) {
26
- throw new Error('useSidebar must be used within a SidebarProvider')
27
- }
28
- return context
29
- }
@@ -1,19 +0,0 @@
1
- {
2
- "name": "styles-base",
3
- "kind": "style",
4
- "framework": "react",
5
- "description": "Base element styles: typography, selection, focus and reduced motion.",
6
- "dependencies": [],
7
- "peers": [
8
- "tailwindcss"
9
- ],
10
- "suggestions": [
11
- "styles-tokens"
12
- ],
13
- "files": [
14
- {
15
- "source": "index.css",
16
- "target": "styles/base.css"
17
- }
18
- ]
19
- }
@@ -1,67 +0,0 @@
1
- @layer base {
2
- html {
3
- -webkit-font-smoothing: antialiased;
4
- -moz-osx-font-smoothing: grayscale;
5
- }
6
-
7
- body {
8
- background-color: var(--color-paper);
9
- color: var(--color-ink);
10
- font-family: var(--font-sans);
11
- text-rendering: optimizeLegibility;
12
- }
13
-
14
- ::selection {
15
- background-color: color-mix(in srgb, var(--color-ink) 14%, transparent);
16
- color: inherit;
17
- }
18
-
19
- :where(
20
- a,
21
- button,
22
- input,
23
- textarea,
24
- select,
25
- summary,
26
- [tabindex]
27
- ):focus-visible {
28
- outline: 2px solid var(--color-brand-500);
29
- outline-offset: 3px;
30
- }
31
-
32
- h1,
33
- h2,
34
- h3,
35
- h4 {
36
- text-wrap: balance;
37
- }
38
-
39
- p {
40
- text-wrap: pretty;
41
- }
42
-
43
- @media (prefers-reduced-motion: reduce) {
44
- html {
45
- scroll-behavior: auto;
46
- }
47
-
48
- *,
49
- *::before,
50
- *::after {
51
- animation-duration: 0.01ms !important;
52
- animation-delay: 0ms !important;
53
- animation-iteration-count: 1 !important;
54
- transition-duration: 0.01ms !important;
55
- transition-delay: 0ms !important;
56
- }
57
-
58
- .motion-lift:hover,
59
- .motion-press:active,
60
- .sidebar-chevron[data-open='true'],
61
- .sidebar-highlight::before,
62
- .tabs-indicator,
63
- .sidebar-panel[data-collapsible='offcanvas'][data-state='collapsed'] {
64
- transform: none !important;
65
- }
66
- }
67
- }
@@ -1,19 +0,0 @@
1
- {
2
- "name": "styles-components",
3
- "kind": "style",
4
- "framework": "react",
5
- "description": "Reusable layout classes for page containers and section rhythm.",
6
- "dependencies": [],
7
- "peers": [
8
- "tailwindcss"
9
- ],
10
- "suggestions": [
11
- "styles-tokens"
12
- ],
13
- "files": [
14
- {
15
- "source": "index.css",
16
- "target": "styles/components.css"
17
- }
18
- ]
19
- }
@@ -1,30 +0,0 @@
1
- @layer components {
2
- .container-page {
3
- margin-inline: auto;
4
- width: 100%;
5
- max-width: 80rem;
6
- padding-inline: 1.25rem;
7
- }
8
-
9
- @media (min-width: 640px) {
10
- .container-page {
11
- padding-inline: 2rem;
12
- }
13
- }
14
-
15
- @media (min-width: 1024px) {
16
- .container-page {
17
- padding-inline: 2.5rem;
18
- }
19
- }
20
-
21
- .section-padding {
22
- padding-block: 5rem;
23
- }
24
-
25
- @media (min-width: 768px) {
26
- .section-padding {
27
- padding-block: 7rem;
28
- }
29
- }
30
- }
@@ -1,20 +0,0 @@
1
- {
2
- "name": "styles-motion",
3
- "kind": "style",
4
- "framework": "react",
5
- "description": "Centralized motion tokens, keyframes and state-driven animation utilities.",
6
- "dependencies": [],
7
- "peers": [
8
- "tailwindcss"
9
- ],
10
- "suggestions": [
11
- "styles-tokens",
12
- "styles-base"
13
- ],
14
- "files": [
15
- {
16
- "source": "index.css",
17
- "target": "styles/motion.css"
18
- }
19
- ]
20
- }