@cbrl/design 0.6.0 → 0.6.2
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 +12 -4
- package/dist/components/avatar.d.ts +1 -1
- package/dist/components/avatar.js +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/status-dot.js +3 -3
- package/dist/components/typography.d.ts +1 -1
- package/dist/hooks/use-hash-section.d.ts +1 -1
- package/dist/hooks/use-hash-section.js +8 -4
- package/dist/tokens.css +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,8 +41,10 @@ import { ThemeProvider, Toaster } from '@cbrl/design'
|
|
|
41
41
|
|
|
42
42
|
### Surfaces and elevation
|
|
43
43
|
|
|
44
|
-
Light mode paints the page (`--background`) and the sidebar a soft gray
|
|
45
|
-
|
|
44
|
+
Light mode paints the page (`--background`) and the sidebar a soft gray
|
|
45
|
+
(`oklch(0.985 0 0)`, a step lighter than the `0.97` hover fills `--accent` and
|
|
46
|
+
`--sidebar-accent`, so hover stays visible), and cards and popovers white, so
|
|
47
|
+
content surfaces stand out. In dark mode the
|
|
46
48
|
popover is a step lighter than the card (shadows barely show on dark). Use
|
|
47
49
|
`shadow-popup` for floating surfaces that sit over content (event popups,
|
|
48
50
|
detail cards):
|
|
@@ -81,8 +83,8 @@ or `'?'`.
|
|
|
81
83
|
### Avatar group
|
|
82
84
|
|
|
83
85
|
`AvatarGroup` overlaps its avatars. Pass `max` to show the first N and collapse
|
|
84
|
-
the rest into a "+K" `AvatarGroupCount` (accessible name `"K
|
|
85
|
-
|
|
86
|
+
the rest into a "+K" `AvatarGroupCount` (accessible name `"+K"`, language-neutral;
|
|
87
|
+
pass a localized `overflowLabel`). Without `max` it renders every child, as before.
|
|
86
88
|
|
|
87
89
|
```tsx
|
|
88
90
|
<AvatarGroup max={3} overflowLabel={(n) => `mais ${n} pessoas`}>
|
|
@@ -265,6 +267,12 @@ export function SettingsModal() {
|
|
|
265
267
|
// Anywhere: <a href="#settings/billing">Cobrança</a>
|
|
266
268
|
```
|
|
267
269
|
|
|
270
|
+
Next.js App Router: a fragment-only navigation (plain `<a href="#…">`, a typed
|
|
271
|
+
URL) bypasses the router, whose history sync then rewrites the URL without the
|
|
272
|
+
hash and would close the dialog at once. The hook re-states the URL through
|
|
273
|
+
`history.replaceState` on `hashchange` (keeping `history.state`, also in
|
|
274
|
+
`open`/`close`) so the router adopts it; outside Next this is a no-op.
|
|
275
|
+
|
|
268
276
|
Uncontrolled use: `defaultOpen`/`defaultValue`. Slots: `settings-dialog`,
|
|
269
277
|
`settings-dialog-nav`, `settings-dialog-content`.
|
|
270
278
|
|
|
@@ -12,7 +12,7 @@ type AvatarGroupProps = React.ComponentProps<'div'> & {
|
|
|
12
12
|
* `AvatarGroupCount` reading "+K". Omit to render every child.
|
|
13
13
|
*/
|
|
14
14
|
max?: number;
|
|
15
|
-
/** Accessible name of the "+K" count. Defaults to `"K
|
|
15
|
+
/** Accessible name of the "+K" count. Defaults to `"+K"` (language-neutral); pass a localized label. */
|
|
16
16
|
overflowLabel?: (hidden: number) => string;
|
|
17
17
|
};
|
|
18
18
|
declare function AvatarGroup({ className, max, overflowLabel, children, ...props }: AvatarGroupProps): React.JSX.Element;
|
|
@@ -43,7 +43,7 @@ function AvatarGroup({ className, max, overflowLabel, children, ...props }) {
|
|
|
43
43
|
...props,
|
|
44
44
|
children: [hidden > 0 ? items.slice(0, limit) : children, hidden > 0 ? /* @__PURE__ */ jsxs(AvatarGroupCount, {
|
|
45
45
|
role: "img",
|
|
46
|
-
"aria-label": overflowLabel?.(hidden) ??
|
|
46
|
+
"aria-label": overflowLabel?.(hidden) ?? `+${hidden}`,
|
|
47
47
|
children: ["+", hidden]
|
|
48
48
|
}) : null]
|
|
49
49
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const badgeVariants: (props?: ({
|
|
4
|
-
variant?: "default" | "
|
|
4
|
+
variant?: "default" | "outline" | "secondary" | "ghost" | "destructive" | "link" | "success" | "warning" | "info" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<'span'> & VariantProps<typeof badgeVariants> & {
|
|
7
7
|
asChild?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "default" | "
|
|
4
|
+
variant?: "default" | "outline" | "secondary" | "ghost" | "destructive" | "link" | null | undefined;
|
|
5
5
|
size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
|
|
@@ -6,10 +6,10 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
const statusDotVariants = cva("relative inline-flex shrink-0 rounded-full", {
|
|
7
7
|
variants: {
|
|
8
8
|
tone: {
|
|
9
|
-
success: "bg-emerald-500",
|
|
10
|
-
warning: "bg-amber-500",
|
|
9
|
+
success: "bg-emerald-500 dark:bg-emerald-400",
|
|
10
|
+
warning: "bg-amber-500 dark:bg-amber-400",
|
|
11
11
|
destructive: "bg-destructive",
|
|
12
|
-
info: "bg-sky-500",
|
|
12
|
+
info: "bg-sky-500 dark:bg-sky-400",
|
|
13
13
|
muted: "bg-muted-foreground/50"
|
|
14
14
|
},
|
|
15
15
|
size: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const typographyVariants: (props?: ({
|
|
4
|
-
variant?: "blockquote" | "code" | "h1" | "h2" | "h3" | "h4" | "p" | "small" | "pageTitle" | "lead" | "large" |
|
|
4
|
+
variant?: "muted" | "blockquote" | "code" | "h1" | "h2" | "h3" | "h4" | "p" | "small" | "pageTitle" | "lead" | "large" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
declare function Typography({ variant, as, className, ...props }: VariantProps<typeof typographyVariants> & {
|
|
7
7
|
as?: React.ElementType;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type HashSection<K extends string> = {
|
|
2
2
|
/** Section in `#<prefix>/<section>`, or null when the hash doesn't address one. */
|
|
3
3
|
section: K | null;
|
|
4
|
-
/** Points the hash at a section (replaceState
|
|
4
|
+
/** Points the hash at a section (replaceState keeping `history.state`: no history entry). */
|
|
5
5
|
open: (section: K) => void;
|
|
6
6
|
/** Clears the hash, keeping path and query (replaceState). */
|
|
7
7
|
close: () => void;
|
|
@@ -15,18 +15,22 @@ function useHashSection(prefix, keys) {
|
|
|
15
15
|
React.useEffect(() => {
|
|
16
16
|
const allowed = keysId === void 0 ? void 0 : keysId.split("\0");
|
|
17
17
|
const sync = () => setSection(parse(window.location.hash, prefix, allowed));
|
|
18
|
+
const onHashChange = () => {
|
|
19
|
+
if (window.location.hash.startsWith(`#${prefix}/`)) window.history.replaceState(window.history.state, "", window.location.href);
|
|
20
|
+
sync();
|
|
21
|
+
};
|
|
18
22
|
sync();
|
|
19
|
-
window.addEventListener("hashchange",
|
|
20
|
-
return () => window.removeEventListener("hashchange",
|
|
23
|
+
window.addEventListener("hashchange", onHashChange);
|
|
24
|
+
return () => window.removeEventListener("hashchange", onHashChange);
|
|
21
25
|
}, [prefix, keysId]);
|
|
22
26
|
return {
|
|
23
27
|
section,
|
|
24
28
|
open: React.useCallback((next) => {
|
|
25
|
-
window.history.replaceState(
|
|
29
|
+
window.history.replaceState(window.history.state, "", `#${prefix}/${encodeURIComponent(next)}`);
|
|
26
30
|
setSection(next);
|
|
27
31
|
}, [prefix]),
|
|
28
32
|
close: React.useCallback(() => {
|
|
29
|
-
window.history.replaceState(
|
|
33
|
+
window.history.replaceState(window.history.state, "", window.location.pathname + window.location.search);
|
|
30
34
|
setSection(null);
|
|
31
35
|
}, [])
|
|
32
36
|
};
|
package/dist/tokens.css
CHANGED
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
/*
|
|
20
20
|
* Surfaces (light): the page and the sidebar around it are a soft gray so
|
|
21
21
|
* white cards and popups stand out from it (like shadcn's own site). Card
|
|
22
|
-
* and popover stay white.
|
|
22
|
+
* and popover stay white. Kept a step lighter than `--accent` /
|
|
23
|
+
* `--sidebar-accent` (0.97) so hover and active fills stay visible.
|
|
23
24
|
*/
|
|
24
|
-
--background: oklch(0.
|
|
25
|
+
--background: oklch(0.985 0 0);
|
|
25
26
|
--foreground: oklch(0.145 0 0);
|
|
26
27
|
--card: oklch(1 0 0);
|
|
27
28
|
--card-foreground: oklch(0.145 0 0);
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
--chart-4: oklch(0.371 0 0);
|
|
46
47
|
--chart-5: oklch(0.269 0 0);
|
|
47
48
|
--radius: 0.625rem;
|
|
48
|
-
--sidebar: oklch(0.
|
|
49
|
+
--sidebar: oklch(0.985 0 0);
|
|
49
50
|
--sidebar-foreground: oklch(0.145 0 0);
|
|
50
51
|
--sidebar-primary: oklch(0.205 0 0);
|
|
51
52
|
--sidebar-primary-foreground: oklch(0.985 0 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cbrl/design",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Design system on Radix + Tailwind v4: shadcn-style components, layout shells and design tokens with an overridable brand accent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Kayron Cabral",
|