@vvedantb/ui 0.7.0 → 0.7.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.
- package/README.md +83 -2
- package/package.json +1 -1
- package/shell/src/Sidebar.tsx +3 -1
- package/shell/src/SidebarPanel.tsx +38 -2
- package/shell/src/app-shell-classes.ts +38 -6
- package/shell/src/index.ts +3 -0
- package/src/index.ts +3 -0
- package/src/ui/_menu-classes.alt.ts +3 -3
- package/src/ui/_menu-classes.ts +3 -3
- package/src/utils/cn.ts +5 -3
- package/tokens/README.md +3 -3
- package/tokens/src/css/compat-shadcn-rgb.css +14 -0
- package/tokens/src/css/utilities.css +0 -5
- package/tokens/src/tokens.css +16 -0
package/README.md
CHANGED
|
@@ -299,7 +299,7 @@ import {
|
|
|
299
299
|
- `SidebarPanel`: legacy (still supported) `headerTrailing`, `onClose`, `closeLabel` and `closeButtonClassName`; compose `Sidebar.Panel` parts instead. `title`, `headerTrailing`, `onClose` (adds the close button; pass it on the mobile drawer only), `closeLabel`, `closeButtonClassName`, `collapsed` (`md:hidden`), `className`, `children`.
|
|
300
300
|
- `SidebarAccountMenu`: legacy (still supported) `badge`, `triggerProps`, `contentProps` and `stackedLabel`; compose `Sidebar.Account*` parts instead. `name`, `email` (two-line label when set), `stackedLabel` (two-line layout even without `email`, default `false`), `imageUrl` (initials without it), `align` (`"center"`), `side` (`"right"`), `sideOffset` (8), `collisionPadding`, `contentClassName`, `children` (menu items). 0.5.2 adds `badge` (unread dot beside the trigger, in a `relative` wrapper around the menu, so the trigger's dimming and press scale skip it: `true` shows it, `false` fades it out, omitted renders no wrapper and no dot), `triggerProps` (spread onto the trigger `Button` after the defaults; `className` merges last) and `contentProps` (spread onto `DropdownMenuContent`, for example `fitViewport` or `aria-label`; no `className`, use `contentClassName`). `SidebarAccountMenuPlaceholder` is the tile-sized loading box.
|
|
301
301
|
- `SignOutDialog`: legacy (still supported) `question` and `title`; compose `ConfirmDialog` parts with `alert={false}` for other copy. `open`, `onOpenChange` (not called with `false` while `pending`), `pending`, `onConfirm`, `description`, `contentClassName`, `title` (`"Sign out"`), `question` (`"Sign out of your account?"`).
|
|
302
|
-
- Class helpers: `railTileClass`, `railTileStateClass(active)`, `railBadgeClass`, `sidebarNavRowClass(isIconOnly)`, `sidebarNavLinkTextClass(isActive)`, `sidebarSectionLabelClass`.
|
|
302
|
+
- Class helpers: `railTileClass`, `railTileStateClass(active)`, `railBadgeClass`, `sidebarNavRowClass(isIconOnly)`, `sidebarNavLinkTextClass(isActive)`, `sidebarNavItemClass({ active, iconOnly })`, `sidebarNavIconClass(active)`, `sidebarSectionLabelClass`. See [Menu item corners and sidebar nav rows (0.7.1)](#menu-item-corners-and-sidebar-nav-rows-071).
|
|
303
303
|
|
|
304
304
|
### Header actions and account badge (0.5.2)
|
|
305
305
|
|
|
@@ -434,6 +434,7 @@ Convention: compound parts are static members of a namespace object, `<Namespace
|
|
|
434
434
|
| `PanelHeader` | Padded header row for `PanelTitle` and `PanelActions`. |
|
|
435
435
|
| `PanelTitle` / `PanelActions` | The `<h2>` and the trailing actions. |
|
|
436
436
|
| `PanelClose` | Ghost close button. `label` (`"Close navigation"`). Without `onClick` it closes the drawer. |
|
|
437
|
+
| `NavItem` | Panel nav row (`sidebarNavItemClass`). `active` (fill, `font-medium`, `aria-current="page"`), `iconOnly`, `icon` (element; gets `sidebarNavIconClass`), `asChild` for a router link. A `<button type="button">` without `asChild`. |
|
|
437
438
|
| `AccountMenu` | Dropdown root. `badge` adds the unread dot (`AccountBadge`) in a `relative` wrapper. |
|
|
438
439
|
| `AccountTrigger` | Rail-tile-sized avatar button. `userName` (default `title` and `aria-label`, and the initials), `imageUrl`, plus `Button` props; native `name` goes to the button. |
|
|
439
440
|
| `AccountAvatar` | Avatar image or initials. `userName`, `imageUrl`. |
|
|
@@ -618,6 +619,86 @@ import {
|
|
|
618
619
|
- `Badge` `variant="destructive-soft"`: neutral border with a faint danger tint (`border-border bg-danger/10 text-danger`). Resolves to the same classes as a default badge with `className="bg-danger/10 text-danger"`. `variant="success"` already resolves to the same classes as a default badge with `className="border-success/25 bg-success/12 text-success"`.
|
|
619
620
|
- `Kbd` `variant="subtle"`: a plain filled key for inline hints, `rounded bg-surface-secondary px-1.5 py-0.5 text-foreground`. No fixed height, font or size, so it follows the surrounding text.
|
|
620
621
|
|
|
622
|
+
## Menu item corners and sidebar nav rows (0.7.1)
|
|
623
|
+
|
|
624
|
+
Visual change. Values in brackets are at the default `--radius: 1rem` and `--spacing: 0.25rem`.
|
|
625
|
+
|
|
626
|
+
The radius utilities now come with `tokens.css` (and `compat-shadcn-rgb.css`), so an app that imports `@vvedantb/ui/tokens` has them without another import:
|
|
627
|
+
|
|
628
|
+
| Utility | Value | Used by |
|
|
629
|
+
| --- | --- | --- |
|
|
630
|
+
| `rounded-surface` | `clamp(0.75rem, var(--radius), 1rem)` (16px) | Opt-in surfaces (Toaster `toastRadius="surface"`, `SessionsHoverCard`). Was in `utilities.css`. |
|
|
631
|
+
| `rounded-menu-item` | `min(var(--radius), 0.5rem)` (8px) | Menu items and sidebar nav rows. |
|
|
632
|
+
| `rounded-control` | `min(var(--radius), 0.625rem)` (10px) | Apps. |
|
|
633
|
+
|
|
634
|
+
The root `cn` knows these are radius classes, so `cn("rounded-lg", "rounded-menu-item")` keeps only the last one.
|
|
635
|
+
|
|
636
|
+
### Menu items
|
|
637
|
+
|
|
638
|
+
| Piece | Before | From 0.7.1 |
|
|
639
|
+
| --- | --- | --- |
|
|
640
|
+
| `DropdownMenu` and `ContextMenu` item, sub-trigger, checkbox item and radio item | `rounded-md`, `calc(var(--radius) - 2px)` (14px) | `rounded-menu-item` (8px) |
|
|
641
|
+
| Menu surface | `rounded-lg` (16px) | unchanged |
|
|
642
|
+
|
|
643
|
+
### Sidebar panel nav rows
|
|
644
|
+
|
|
645
|
+
Rows in the panel beside the rail. Rail tiles are unchanged.
|
|
646
|
+
|
|
647
|
+
| Piece | Before | From 0.7.1 |
|
|
648
|
+
| --- | --- | --- |
|
|
649
|
+
| Radius | none in the helper (apps added `rounded-lg`, 16px) | `rounded-menu-item` (8px) |
|
|
650
|
+
| Padding | `px-3 py-1.5` (12px / 6px) | `px-4 py-1.5` (16px / 6px) |
|
|
651
|
+
| Icon gap | `gap-3` (12px) | `gap-2` (8px) |
|
|
652
|
+
| Text | none in the helper (apps added `text-sm`, 14px / 20px) | `text-[0.8125rem] leading-[18px] tracking-[0.005em]` (13px / 18px) |
|
|
653
|
+
| Row height | 32px with `text-sm` | 30px |
|
|
654
|
+
| Width | none in the helper | `flex w-full items-center` |
|
|
655
|
+
| Idle text | `text-muted`, `hover:text-foreground` | `font-normal text-foreground/80`, `hover:text-foreground` |
|
|
656
|
+
| Active text | `text-foreground` | `font-medium text-foreground` |
|
|
657
|
+
| Hover and active fill | none in the helper | `hover:bg-surface-tertiary` (idle rows), `bg-surface-tertiary` (active row), same radius |
|
|
658
|
+
| Press | none | `active:scale-[0.99]`, `transition-[scale,background-color,color] duration-150 ease-smooth` |
|
|
659
|
+
| Focus ring | none | `focus-visible:ring-2 focus-visible:ring-foreground/35`, no outline |
|
|
660
|
+
| Icon-only row | `justify-center px-0 py-1.5` | same, plus the radius, text, fill and focus classes above |
|
|
661
|
+
| Icon (`sidebarNavIconClass`) | none (apps used 18px in a 20px box) | `size-[19px] shrink-0`; `text-muted-foreground` idle, `text-foreground` active |
|
|
662
|
+
| Section label | `px-3 py-1 text-[11px]` | `px-4 py-1 text-[11px] leading-4` (16px line). Colour still comes from the app's `.sidebar-section-label` rule. |
|
|
663
|
+
|
|
664
|
+
The hover fill is static: it does not slide between rows. While another row is hovered, the active row keeps its fill.
|
|
665
|
+
|
|
666
|
+
One call per row:
|
|
667
|
+
|
|
668
|
+
```tsx
|
|
669
|
+
<nav className="px-2">
|
|
670
|
+
<p className={sidebarSectionLabelClass}>Library</p>
|
|
671
|
+
<div className="space-y-1">
|
|
672
|
+
<Link to="/home" aria-current={active ? "page" : undefined} className={sidebarNavItemClass({ active, iconOnly })}>
|
|
673
|
+
<IconHome size={19} className={sidebarNavIconClass(active)} />
|
|
674
|
+
{iconOnly ? null : <span className="truncate">Home</span>}
|
|
675
|
+
</Link>
|
|
676
|
+
</div>
|
|
677
|
+
</nav>
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
Or the part, with the router link as the child:
|
|
681
|
+
|
|
682
|
+
```tsx
|
|
683
|
+
<Sidebar.NavItem asChild active={active} iconOnly={iconOnly} icon={<IconHome />}>
|
|
684
|
+
<Link to="/home">{iconOnly ? null : <span className="truncate">Home</span>}</Link>
|
|
685
|
+
</Sidebar.NavItem>
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
- `px-2` on the list is the panel inset: rows are full width inside it. `space-y-1` (4px) separates rows.
|
|
689
|
+
- `sidebarNavRowClass(isIconOnly)` and `sidebarNavLinkTextClass(isActive)` now return the classes above, so existing calls change look. `sidebarNavItemClass` is the two merged.
|
|
690
|
+
- Classes an app added beside the helpers, such as `rounded-lg text-sm font-medium tracking-normal transition-colors duration-200`, are now redundant. Through the root `cn` they lose to the helper when passed before it. Passed after it, or joined without `cn`, they override the new radius, size and weight. Remove them, and remove app-side active fills such as `bg-surface-tertiary`.
|
|
691
|
+
|
|
692
|
+
Colour mapping. The package has no sidebar colour tokens, so the rows use the nearest general token:
|
|
693
|
+
|
|
694
|
+
| Role | Reference look (light / dark, sRGB) | Package token (light / dark, sRGB) |
|
|
695
|
+
| --- | --- | --- |
|
|
696
|
+
| Hover and active fill | 233 234 236 / 28 28 28 | `surface-tertiary`: 234 234 234 / about 39 39 39. Light matches; dark is a step lighter. It is the rail tile's active fill too, so a rail tile and a nav row stay the same. |
|
|
697
|
+
| Active text and icon | 9 9 11 / 250 250 250 | `foreground`: 24 24 24 / 252 252 252 |
|
|
698
|
+
| Idle text (80%) | 24 24 25 / 251 252 253 | `foreground` at 80% |
|
|
699
|
+
| Idle icon | 100 101 103 / 159 160 162 | `muted-foreground` (`--muted`): 114 114 114 / 160 160 160 |
|
|
700
|
+
| Focus ring (35%) | 9 9 11 / 250 250 250 | `foreground` at 35% |
|
|
701
|
+
|
|
621
702
|
## Toaster
|
|
622
703
|
|
|
623
704
|
```tsx
|
|
@@ -643,7 +724,7 @@ Opt-in props (all default to the current look):
|
|
|
643
724
|
|
|
644
725
|
| Prop | Values | Effect |
|
|
645
726
|
| --- | --- | --- |
|
|
646
|
-
| `toastRadius` | `"lg"` (default), `"surface"`, `"control"` | `rounded-lg`, `rounded-surface` (from `tokens
|
|
727
|
+
| `toastRadius` | `"lg"` (default), `"surface"`, `"control"` | `rounded-lg`, `rounded-surface` (from `tokens.css`, or the compat file) or `rounded-field` (the input radius). |
|
|
647
728
|
| `density` | `"default"`, `"compact"` | Current padding and text, or `gap-2 px-3 py-2 text-xs` with `text-xs` descriptions. |
|
|
648
729
|
| `toastIcons` | `"default"`, `"filled24"` | Sonner icons or 24px filled success, info, warning and error icons, a matching loader and a 14px close cross. |
|
|
649
730
|
| `closeButtonStyle` | `"default"`, `"hoverChip"` | Text-style close button or a round chip at the top-right, shown on hover and always on small screens. It turns on `closeButton` unless you set it. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/ui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React 19 UI for web apps: one JavaScript entry (primitives, shell pieces, app helpers, native tokens), design-token CSS, shared Tailwind v4 CSS and a Tailwind preset.",
|
|
6
6
|
"type": "module",
|
package/shell/src/Sidebar.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
AccountSeparator,
|
|
10
10
|
AccountTrigger,
|
|
11
11
|
} from "./SidebarAccountMenu";
|
|
12
|
-
import { Panel, PanelActions, PanelClose, PanelHeader, PanelTitle } from "./SidebarPanel";
|
|
12
|
+
import { NavItem, Panel, PanelActions, PanelClose, PanelHeader, PanelTitle } from "./SidebarPanel";
|
|
13
13
|
import { Rail, RailBody, RailFooter, RailHeader, RailItem, RailSeparator } from "./SidebarRail";
|
|
14
14
|
|
|
15
15
|
export type {
|
|
@@ -36,6 +36,7 @@ export type {
|
|
|
36
36
|
SidebarPanelHeaderProps,
|
|
37
37
|
SidebarPanelRootProps,
|
|
38
38
|
SidebarPanelTitleProps,
|
|
39
|
+
SidebarNavItemProps,
|
|
39
40
|
} from "./SidebarPanel";
|
|
40
41
|
export type {
|
|
41
42
|
SidebarAccountAvatarProps,
|
|
@@ -68,6 +69,7 @@ export const Sidebar = {
|
|
|
68
69
|
PanelTitle,
|
|
69
70
|
PanelActions,
|
|
70
71
|
PanelClose,
|
|
72
|
+
NavItem,
|
|
71
73
|
AccountMenu,
|
|
72
74
|
AccountTrigger,
|
|
73
75
|
AccountAvatar,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactElement, ReactNode } from "react";
|
|
2
|
+
import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
2
3
|
import { IconX } from "@tabler/icons-react";
|
|
3
4
|
import { Button, type ButtonProps } from "../../src/ui/button";
|
|
4
5
|
import { cn } from "../../src/utils/cn";
|
|
5
|
-
import { panelCloseButtonClass, sidebarHeaderRowClass } from "./app-shell-classes";
|
|
6
|
+
import { panelCloseButtonClass, sidebarHeaderRowClass, sidebarNavIconClass, sidebarNavItemClass } from "./app-shell-classes";
|
|
6
7
|
import { useOptionalSidebar } from "./SidebarChrome";
|
|
7
8
|
|
|
8
9
|
export type SidebarPanelProps = {
|
|
@@ -131,3 +132,38 @@ export function PanelClose({ label = "Close navigation", onClick, className, chi
|
|
|
131
132
|
</Button>
|
|
132
133
|
);
|
|
133
134
|
}
|
|
135
|
+
|
|
136
|
+
export type SidebarNavItemProps = ComponentPropsWithoutRef<"button"> & {
|
|
137
|
+
/** Current route: static fill, `font-medium`, `aria-current="page"`. */
|
|
138
|
+
active?: boolean;
|
|
139
|
+
/** Collapsed panel: centred icon, no horizontal padding. */
|
|
140
|
+
iconOnly?: boolean;
|
|
141
|
+
/** Leading icon element; gets `sidebarNavIconClass(active)` merged onto it. */
|
|
142
|
+
icon?: ReactElement;
|
|
143
|
+
/** Render the single child element (for example a router link) as the row. */
|
|
144
|
+
asChild?: boolean;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/** Panel nav row (`sidebarNavItemClass`). Renders a native `<button>`, or its child with `asChild`. */
|
|
148
|
+
export function NavItem({
|
|
149
|
+
active = false,
|
|
150
|
+
iconOnly = false,
|
|
151
|
+
icon,
|
|
152
|
+
asChild = false,
|
|
153
|
+
className,
|
|
154
|
+
children,
|
|
155
|
+
...props
|
|
156
|
+
}: SidebarNavItemProps) {
|
|
157
|
+
const Row = asChild ? Slot : "button";
|
|
158
|
+
return (
|
|
159
|
+
<Row
|
|
160
|
+
type={asChild ? undefined : "button"}
|
|
161
|
+
{...props}
|
|
162
|
+
aria-current={active ? "page" : undefined}
|
|
163
|
+
className={cn(sidebarNavItemClass({ active, iconOnly }), className)}
|
|
164
|
+
>
|
|
165
|
+
{icon ? <Slot className={sidebarNavIconClass(active)}>{icon}</Slot> : null}
|
|
166
|
+
<Slottable>{children}</Slottable>
|
|
167
|
+
</Row>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
@@ -19,18 +19,50 @@ export function railTileStateClass(active: boolean): string {
|
|
|
19
19
|
/** Count badge pinned to the bottom-right of a rail tile. */
|
|
20
20
|
export const railBadgeClass = "absolute -bottom-0.5 -right-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-accent px-1 text-[10px] font-semibold leading-none text-accent-foreground"; // check-tokens-allow: accent
|
|
21
21
|
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Static section label above a group of panel nav rows. `px-4` lines the text
|
|
24
|
+
* up with the nav row icons; the colour comes from the app's
|
|
25
|
+
* `.sidebar-section-label` rule.
|
|
26
|
+
*/
|
|
23
27
|
export const sidebarSectionLabelClass =
|
|
24
|
-
"sidebar-section-label px-
|
|
28
|
+
"sidebar-section-label px-4 py-1 text-[11px] leading-4 font-medium tracking-[-0.01em]";
|
|
25
29
|
|
|
26
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Nav row state: idle rows are `foreground/80` and get the fill on hover;
|
|
32
|
+
* the active row is `font-medium text-foreground` on a static fill.
|
|
33
|
+
*/
|
|
27
34
|
export function sidebarNavLinkTextClass(isActive: boolean): string {
|
|
28
|
-
return
|
|
35
|
+
return isActive
|
|
36
|
+
? "bg-surface-tertiary font-medium text-foreground"
|
|
37
|
+
: "font-normal text-foreground/80 hover:bg-surface-tertiary hover:text-foreground";
|
|
29
38
|
}
|
|
30
39
|
|
|
31
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Panel nav row layout: full width, `rounded-menu-item` (8px), 13px / 18px
|
|
42
|
+
* text, focus ring and press scale. Icon-only rows centre the icon.
|
|
43
|
+
*/
|
|
32
44
|
export function sidebarNavRowClass(isIconOnly: boolean): string {
|
|
33
|
-
return cn(
|
|
45
|
+
return cn(
|
|
46
|
+
"group flex w-full items-center rounded-menu-item py-1.5 text-[0.8125rem] leading-[18px] tracking-[0.005em] transition-[scale,background-color,color] duration-150 ease-smooth active:scale-[0.99] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/35",
|
|
47
|
+
isIconOnly ? "justify-center px-0" : "gap-2 px-4",
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type SidebarNavItemClassOptions = {
|
|
52
|
+
/** Current route. */
|
|
53
|
+
active?: boolean;
|
|
54
|
+
/** Collapsed panel: centred icon, no horizontal padding. */
|
|
55
|
+
iconOnly?: boolean;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** Whole panel nav row: `sidebarNavRowClass` plus `sidebarNavLinkTextClass`. */
|
|
59
|
+
export function sidebarNavItemClass({ active = false, iconOnly = false }: SidebarNavItemClassOptions = {}): string {
|
|
60
|
+
return cn(sidebarNavRowClass(iconOnly), sidebarNavLinkTextClass(active));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Nav row icon (put it on the `<svg>`): 19px, muted until active. */
|
|
64
|
+
export function sidebarNavIconClass(active: boolean): string {
|
|
65
|
+
return cn("size-[19px] shrink-0", active ? "text-foreground" : "text-muted-foreground");
|
|
34
66
|
}
|
|
35
67
|
|
|
36
68
|
/** Sidebar header row: the panel title and its trailing actions. */
|
package/shell/src/index.ts
CHANGED
|
@@ -45,7 +45,10 @@ export {
|
|
|
45
45
|
railBadgeClass,
|
|
46
46
|
railTileClass,
|
|
47
47
|
railTileStateClass,
|
|
48
|
+
sidebarNavIconClass,
|
|
49
|
+
sidebarNavItemClass,
|
|
48
50
|
sidebarNavLinkTextClass,
|
|
49
51
|
sidebarNavRowClass,
|
|
50
52
|
sidebarSectionLabelClass,
|
|
51
53
|
} from "./app-shell-classes.js";
|
|
54
|
+
export type { SidebarNavItemClassOptions } from "./app-shell-classes.js";
|
package/src/index.ts
CHANGED
|
@@ -158,10 +158,13 @@ export {
|
|
|
158
158
|
railBadgeClass,
|
|
159
159
|
railTileClass,
|
|
160
160
|
railTileStateClass,
|
|
161
|
+
sidebarNavIconClass,
|
|
162
|
+
sidebarNavItemClass,
|
|
161
163
|
sidebarNavLinkTextClass,
|
|
162
164
|
sidebarNavRowClass,
|
|
163
165
|
sidebarSectionLabelClass,
|
|
164
166
|
} from "../shell/src/app-shell-classes";
|
|
167
|
+
export type { SidebarNavItemClassOptions } from "../shell/src/app-shell-classes";
|
|
165
168
|
|
|
166
169
|
// App helpers: confirm skip, update watcher, settings chrome, stable auth.
|
|
167
170
|
export * from "../app/src/index";
|
|
@@ -17,13 +17,13 @@ export const menuContentClass = [
|
|
|
17
17
|
].join(" ");
|
|
18
18
|
|
|
19
19
|
export const menuSubTriggerClass =
|
|
20
|
-
"flex cursor-pointer select-none items-center gap-2 rounded-
|
|
20
|
+
"flex cursor-pointer select-none items-center gap-2 rounded-menu-item px-2.5 py-2 text-sm text-foreground outline-hidden transition-[background-color,color,transform] duration-150 ease-out active:scale-[0.99] focus:bg-default focus:text-foreground data-highlighted:bg-default data-highlighted:text-foreground data-[state=open]:bg-default data-disabled:cursor-not-allowed [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";
|
|
21
21
|
|
|
22
22
|
export const menuItemClass =
|
|
23
|
-
"relative flex cursor-pointer select-none items-center gap-2 rounded-
|
|
23
|
+
"relative flex cursor-pointer select-none items-center gap-2 rounded-menu-item px-2.5 py-2 text-sm outline-hidden transition-[background-color,color,transform] duration-150 ease-out active:scale-[0.99] focus:bg-default focus:text-foreground data-highlighted:bg-default data-highlighted:text-foreground data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0 [&_svg]:pointer-events-none";
|
|
24
24
|
|
|
25
25
|
export const menuCheckboxRadioItemClass =
|
|
26
|
-
"relative flex cursor-pointer select-none items-center rounded-
|
|
26
|
+
"relative flex cursor-pointer select-none items-center rounded-menu-item py-2 pl-8 pr-2.5 text-sm outline-hidden transition-[background-color,color,transform] duration-150 ease-out active:scale-[0.99] focus:bg-default focus:text-foreground data-highlighted:bg-default data-highlighted:text-foreground data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50";
|
|
27
27
|
|
|
28
28
|
export const menuLabelClass =
|
|
29
29
|
"px-2.5 py-1.5 text-xs font-semibold uppercase tracking-widest text-muted-foreground";
|
package/src/ui/_menu-classes.ts
CHANGED
|
@@ -14,13 +14,13 @@ export const menuContentClass = [
|
|
|
14
14
|
].join(" ");
|
|
15
15
|
|
|
16
16
|
export const menuSubTriggerClass =
|
|
17
|
-
"flex cursor-pointer select-none items-center gap-2 rounded-
|
|
17
|
+
"flex cursor-pointer select-none items-center gap-2 rounded-menu-item px-2.5 py-2 max-sm:min-h-10 text-sm text-foreground outline-none transition-[background-color,color] focus:bg-default focus:text-foreground data-[highlighted]:bg-default data-[highlighted]:text-foreground data-[state=open]:bg-default data-[disabled]:cursor-not-allowed [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";
|
|
18
18
|
|
|
19
19
|
export const menuItemClass =
|
|
20
|
-
"relative flex cursor-pointer select-none items-center gap-2 rounded-
|
|
20
|
+
"relative flex cursor-pointer select-none items-center gap-2 rounded-menu-item px-2.5 py-2 max-sm:min-h-10 text-sm outline-none transition-[background-color,color] focus:bg-default focus:text-foreground data-[highlighted]:bg-default data-[highlighted]:text-foreground data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0 [&_svg]:pointer-events-none";
|
|
21
21
|
|
|
22
22
|
export const menuCheckboxRadioItemClass =
|
|
23
|
-
"relative flex cursor-pointer select-none items-center rounded-
|
|
23
|
+
"relative flex cursor-pointer select-none items-center rounded-menu-item py-2 max-sm:min-h-10 pl-8 pr-2.5 text-sm outline-none transition-[background-color,color] focus:bg-default focus:text-foreground data-[highlighted]:bg-default data-[highlighted]:text-foreground data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50";
|
|
24
24
|
|
|
25
25
|
export const menuLabelClass =
|
|
26
26
|
"px-2.5 py-1.5 text-xs font-semibold uppercase tracking-widest text-muted-foreground";
|
package/src/utils/cn.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { type ClassValue, clsx } from "clsx";
|
|
2
2
|
import { extendTailwindMerge } from "tailwind-merge";
|
|
3
3
|
|
|
4
|
-
// `rounded-field`
|
|
5
|
-
// `rounded-
|
|
4
|
+
// `rounded-field` and the tokens.css radii (`rounded-surface`,
|
|
5
|
+
// `rounded-menu-item`, `rounded-control`) are custom radius tokens — teach
|
|
6
|
+
// twMerge they conflict with `rounded-none` / `rounded-md` / etc. so the last
|
|
7
|
+
// radius class wins.
|
|
6
8
|
const twMerge = extendTailwindMerge({
|
|
7
9
|
extend: {
|
|
8
10
|
theme: {
|
|
9
|
-
borderRadius: ["field"],
|
|
11
|
+
borderRadius: ["field", "surface", "menu-item", "control"],
|
|
10
12
|
},
|
|
11
13
|
},
|
|
12
14
|
});
|
package/tokens/README.md
CHANGED
|
@@ -6,17 +6,17 @@ Design tokens and shared Tailwind v4 CSS for the vvedantb web apps. The CSS and
|
|
|
6
6
|
|
|
7
7
|
| Export | File | What it is |
|
|
8
8
|
| --- | --- | --- |
|
|
9
|
-
| `@vvedantb/ui/tokens`, `@vvedantb/ui/tokens/tokens.css` | `src/tokens.css` | Colour, radius, shadow, ease and font tokens (`@theme`), light/dark variables, `dark` variant, `*` border and `body` defaults. In 0.2.1 it also defines shadcn-style aliases (`primary`, `muted-foreground`, `secondary`, `destructive`, `card`, `popover`, `input`, `ring`) that point at the same tokens. |
|
|
9
|
+
| `@vvedantb/ui/tokens`, `@vvedantb/ui/tokens/tokens.css` | `src/tokens.css` | Colour, radius, shadow, ease and font tokens (`@theme`), light/dark variables, `dark` variant, the radius utilities `rounded-surface` (`clamp(0.75rem, var(--radius), 1rem)`), `rounded-menu-item` (`min(var(--radius), 0.5rem)`) and `rounded-control` (`min(var(--radius), 0.625rem)`) (0.7.1; `rounded-surface` was in `utilities.css` before), `*` border and `body` defaults. In 0.2.1 it also defines shadcn-style aliases (`primary`, `muted-foreground`, `secondary`, `destructive`, `card`, `popover`, `input`, `ring`) that point at the same tokens. |
|
|
10
10
|
| `tokens` and `Tokens` from `@vvedantb/ui` | `src/native.ts` | JS colours, radii and spacing for React Native. `@vvedantb/native-ui` keeps its own copy in `src/tokens.ts`; a test keeps the two equal. |
|
|
11
11
|
| `@vvedantb/ui/tokens/css/base.css` | `src/css/base.css` | `html` touch/accent, `::selection`, control transitions, pointer cursor, range accent (`@layer base`). |
|
|
12
12
|
| `@vvedantb/ui/tokens/css/dialog.css` | `src/css/dialog.css` | Unlayered `max-width: none` for `@vvedantb/ui` compact (bottom-sheet) dialogs. |
|
|
13
13
|
| `@vvedantb/ui/tokens/css/modal.css` | `src/css/modal.css` | `.t-modal`, `.is-open`, `.is-closing` and `t-modal-presence-wait` (`@layer components`). |
|
|
14
14
|
| `@vvedantb/ui/tokens/css/tabs.css` | `src/css/tabs.css` | `.t-tab`, active colour, `.t-tabs-pill`, small-screen `.t-tabs` scrolling. |
|
|
15
15
|
| `@vvedantb/ui/tokens/css/tabs-pills.css` | `src/css/tabs-pills.css` | `--tabs-*` colour variables, `.t-tabs--segmented`, `.t-tabs--pills` and pill hover / active fills. |
|
|
16
|
-
| `@vvedantb/ui/tokens/css/utilities.css` | `src/css/utilities.css` | `@utility hit-target
|
|
16
|
+
| `@vvedantb/ui/tokens/css/utilities.css` | `src/css/utilities.css` | `@utility hit-target` and `@utility reveal-on-hover`. `rounded-surface` moved to `tokens.css` in 0.7.1. |
|
|
17
17
|
| `@vvedantb/ui/tokens/css/scrollbar-thin.css` | `src/css/scrollbar-thin.css` | `.scrollbar-thin` (`@layer utilities`, always emitted). |
|
|
18
18
|
| `@vvedantb/ui/tokens/css/animations.css` | `src/css/animations.css` | `animate-aurora`, `animate-fade-in-up`, `animate-indeterminate` as `@theme` (CSS-first apps). |
|
|
19
|
-
| `@vvedantb/ui/tokens/css/compat-shadcn-rgb.css`, `@vvedantb/ui/tokens/compat/shadcn-rgb.css` | `src/css/compat-shadcn-rgb.css` | Replaces `tokens.css` for apps with shadcn-style `R G B` channel variables. Defines only the UI-only `--color-*` names as `rgb(var(--x) / alpha)` references, `--radius-field`, `--scrollbar`, `--field-radius` and a `glass-panel-strong` fallback. Import it **or** `tokens.css`, never both. |
|
|
19
|
+
| `@vvedantb/ui/tokens/css/compat-shadcn-rgb.css`, `@vvedantb/ui/tokens/compat/shadcn-rgb.css` | `src/css/compat-shadcn-rgb.css` | Replaces `tokens.css` for apps with shadcn-style `R G B` channel variables. Defines only the UI-only `--color-*` names as `rgb(var(--x) / alpha)` references, `--radius-field`, `--scrollbar`, `--field-radius`, the same three radius utilities as `tokens.css` and a `glass-panel-strong` fallback. Import it **or** `tokens.css`, never both. |
|
|
20
20
|
| `@vvedantb/ui/tokens/css/index.css` | `src/css/index.css` | base + dialog + utilities + scrollbar-thin + animations, for new CSS-first apps. |
|
|
21
21
|
| `@vvedantb/ui/tokens/tailwind-preset` | `src/tailwind-preset.mjs` (+ `.d.mts`) | Tailwind preset for apps that load a JS config with `@config`. |
|
|
22
22
|
|
|
@@ -65,6 +65,20 @@
|
|
|
65
65
|
--radius-field: min(calc(var(--radius) + 0.25rem), 1.25rem);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
/* The radius utilities from tokens.css, which this file replaces. They read
|
|
69
|
+
the app's `--radius`. */
|
|
70
|
+
@utility rounded-surface {
|
|
71
|
+
border-radius: clamp(0.75rem, var(--radius), 1rem);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@utility rounded-menu-item {
|
|
75
|
+
border-radius: min(var(--radius), 0.5rem);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@utility rounded-control {
|
|
79
|
+
border-radius: min(var(--radius), 0.625rem);
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
:root {
|
|
69
83
|
--scrollbar: rgb(var(--muted-foreground) / 0.35);
|
|
70
84
|
--field-radius: min(calc(var(--radius) + 0.25rem), 1.25rem);
|
package/tokens/src/tokens.css
CHANGED
|
@@ -94,6 +94,22 @@
|
|
|
94
94
|
--font-instrumentSans: "Instrument Sans", system-ui, sans-serif;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/* Radius utilities that follow the theme `--radius` (values at the default
|
|
98
|
+
1rem in brackets). Surfaces: kept between 0.75rem and 1rem (16px). Menu
|
|
99
|
+
items and sidebar nav rows: capped at 0.5rem (8px) so they sit inside the
|
|
100
|
+
surface corner. Controls: capped at 0.625rem (10px). */
|
|
101
|
+
@utility rounded-surface {
|
|
102
|
+
border-radius: clamp(0.75rem, var(--radius), 1rem);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@utility rounded-menu-item {
|
|
106
|
+
border-radius: min(var(--radius), 0.5rem);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@utility rounded-control {
|
|
110
|
+
border-radius: min(var(--radius), 0.625rem);
|
|
111
|
+
}
|
|
112
|
+
|
|
97
113
|
@layer base {
|
|
98
114
|
:root,
|
|
99
115
|
.light,
|