@sniptide/ui 0.3.0 → 0.5.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/README.md +1 -1
- package/package.json +2 -2
- package/src/components/checkbox.tsx +15 -5
- package/src/components/table.tsx +3 -2
- package/src/styles/globals.css +0 -6
- package/src/components/stripes.tsx +0 -75
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @sniptide/ui
|
|
2
2
|
|
|
3
|
-
Sniptide's shared React components (shadcn on Base UI), brand
|
|
3
|
+
Sniptide's shared React components (shadcn on Base UI), the brand `Logo` and the
|
|
4
4
|
Tailwind v4 theme. The Sniptide app uses it from this monorepo; the website installs it from npm.
|
|
5
5
|
|
|
6
6
|
The package ships TypeScript source, so the consuming Next.js app compiles it.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sniptide/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"gitHead": "32a2b8c1eca3d578844a1f3718fac6fe33e38f4d",
|
|
5
5
|
"description": "Sniptide's shared React components and Tailwind theme, used by the app and the website.",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
7
7
|
"homepage": "https://sniptide.com",
|
|
@@ -2,21 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox"
|
|
4
4
|
import { cn } from "cn"
|
|
5
|
-
import { CheckIcon } from "lucide-react"
|
|
5
|
+
import { CheckIcon, MinusIcon } from "lucide-react"
|
|
6
6
|
|
|
7
7
|
function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
|
|
8
8
|
return (
|
|
9
9
|
<CheckboxPrimitive.Root
|
|
10
10
|
data-slot="checkbox"
|
|
11
11
|
className={cn(
|
|
12
|
-
"flex size-4 shrink-0 items-center justify-center rounded-sm border border-input bg-background text-primary-foreground outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/30 data-checked:border-primary data-checked:bg-primary data-disabled:border-border data-disabled:bg-muted",
|
|
12
|
+
"flex size-4 shrink-0 items-center justify-center rounded-sm border border-input bg-background text-primary-foreground outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/30 data-checked:border-primary data-checked:bg-primary data-indeterminate:border-primary data-indeterminate:bg-primary data-disabled:border-border data-disabled:bg-muted",
|
|
13
13
|
className,
|
|
14
14
|
)}
|
|
15
15
|
{...props}
|
|
16
16
|
>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
{/* A select-all box shows a dash while only some of its rows are checked. */}
|
|
18
|
+
<CheckboxPrimitive.Indicator
|
|
19
|
+
className="flex items-center justify-center"
|
|
20
|
+
render={(indicatorProps, state) => (
|
|
21
|
+
<span {...indicatorProps}>
|
|
22
|
+
{state.indeterminate ? (
|
|
23
|
+
<MinusIcon className="size-3" strokeWidth={3} />
|
|
24
|
+
) : (
|
|
25
|
+
<CheckIcon className="size-3" strokeWidth={3} />
|
|
26
|
+
)}
|
|
27
|
+
</span>
|
|
28
|
+
)}
|
|
29
|
+
/>
|
|
20
30
|
</CheckboxPrimitive.Root>
|
|
21
31
|
)
|
|
22
32
|
}
|
package/src/components/table.tsx
CHANGED
|
@@ -50,7 +50,7 @@ function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
|
50
50
|
return (
|
|
51
51
|
<tr
|
|
52
52
|
className={cn(
|
|
53
|
-
"group/row border-b border-border/70 transition-colors hover:bg-muted/40",
|
|
53
|
+
"group/row border-b border-border/70 transition-colors hover:bg-muted/40 data-[selected=true]:bg-muted/70",
|
|
54
54
|
className,
|
|
55
55
|
)}
|
|
56
56
|
{...props}
|
|
@@ -74,11 +74,12 @@ function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
|
|
74
74
|
return <td className={cn("h-16 px-5 align-middle whitespace-nowrap", className)} {...props} />
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
// A checked row (`data-selected`) takes a deeper tint than hover, so a selection reads at a glance.
|
|
77
78
|
// The actions column stays at the right edge while the other columns scroll under it. It paints an
|
|
78
79
|
// opaque fill, so the row's hover tint is mixed into it rather than layered on top. A short fade on
|
|
79
80
|
// its left edge shows that more columns sit behind it.
|
|
80
81
|
const pinned =
|
|
81
|
-
"sticky right-0 bg-background before:pointer-events-none before:absolute before:inset-y-0 before:right-full before:w-8 before:bg-linear-to-l before:from-background before:to-transparent before:transition-opacity group-data-[at-end=true]/scroll:before:opacity-0 group-hover/row:bg-[color-mix(in_oklab,var(--background),var(--muted)_40%)] group-hover/row:before:from-[color-mix(in_oklab,var(--background),var(--muted)_40%)]"
|
|
82
|
+
"sticky right-0 bg-background before:pointer-events-none before:absolute before:inset-y-0 before:right-full before:w-8 before:bg-linear-to-l before:from-background before:to-transparent before:transition-opacity group-data-[at-end=true]/scroll:before:opacity-0 group-hover/row:bg-[color-mix(in_oklab,var(--background),var(--muted)_40%)] group-hover/row:before:from-[color-mix(in_oklab,var(--background),var(--muted)_40%)] group-data-[selected=true]/row:bg-[color-mix(in_oklab,var(--background),var(--muted)_70%)] group-data-[selected=true]/row:before:from-[color-mix(in_oklab,var(--background),var(--muted)_70%)]"
|
|
82
83
|
|
|
83
84
|
function TablePinnedHead({ className, ...props }: React.ComponentProps<"th">) {
|
|
84
85
|
return (
|
package/src/styles/globals.css
CHANGED
|
@@ -45,8 +45,6 @@
|
|
|
45
45
|
--float-shadow: 0 1px 2px rgb(27 25 25 / 0.06), 0 8px 24px -6px rgb(27 25 25 / 0.14);
|
|
46
46
|
--dialog-shadow: 0 2px 4px rgb(27 25 25 / 0.06), 0 24px 48px -12px rgb(27 25 25 / 0.22);
|
|
47
47
|
--logo-primary: #2a26ec;
|
|
48
|
-
--logo-ink: #1b1919;
|
|
49
|
-
--logo-hatch: #000000;
|
|
50
48
|
--link: #2a26ec;
|
|
51
49
|
/* Pink is the second brand colour. It marks what stands out without being an action: search
|
|
52
50
|
matches, stars, the peak of a chart. --pink is the surface with --pink-foreground on it;
|
|
@@ -107,8 +105,6 @@
|
|
|
107
105
|
/* The inverse logo from the Paper brand page: its own deep blue, light grey blocks and dim
|
|
108
106
|
hatching. */
|
|
109
107
|
--logo-primary: #1b17c6;
|
|
110
|
-
--logo-ink: #dfdfdf;
|
|
111
|
-
--logo-hatch: #535151;
|
|
112
108
|
/* One blue, two weights. Tide Blue fills buttons and chart bars in both themes (white on it is
|
|
113
109
|
8.1:1) but is too dark to read as text on these surfaces (2.3:1), so links, focus rings,
|
|
114
110
|
code keywords and blue collection icons use its light tint, the same one the landing uses
|
|
@@ -170,8 +166,6 @@
|
|
|
170
166
|
--color-sidebar-border: var(--sidebar-border);
|
|
171
167
|
--color-sidebar-ring: var(--sidebar-ring);
|
|
172
168
|
--color-logo-primary: var(--logo-primary);
|
|
173
|
-
--color-logo-ink: var(--logo-ink);
|
|
174
|
-
--color-logo-hatch: var(--logo-hatch);
|
|
175
169
|
--color-link: var(--link);
|
|
176
170
|
--color-pink: var(--pink);
|
|
177
171
|
--color-pink-foreground: var(--pink-foreground);
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { cn } from "@sniptide/ui/lib/utils"
|
|
2
|
-
|
|
3
|
-
type Bar = [number, number, number?, number?]
|
|
4
|
-
|
|
5
|
-
// Barcode stripes from the Paper auth screens' brand panel (720×900 artboard units).
|
|
6
|
-
const ink: Bar[] = [
|
|
7
|
-
[0, 1],
|
|
8
|
-
[5, 2],
|
|
9
|
-
[11, 3],
|
|
10
|
-
[18, 4],
|
|
11
|
-
[32, 36],
|
|
12
|
-
[140, 1],
|
|
13
|
-
[145, 2],
|
|
14
|
-
[151, 3],
|
|
15
|
-
[158, 4],
|
|
16
|
-
[172, 72],
|
|
17
|
-
[244, 1],
|
|
18
|
-
[249, 2],
|
|
19
|
-
[255, 3],
|
|
20
|
-
[262, 4],
|
|
21
|
-
[276, 1],
|
|
22
|
-
[281, 2],
|
|
23
|
-
[287, 3],
|
|
24
|
-
[294, 4],
|
|
25
|
-
[308, 1],
|
|
26
|
-
[313, 2],
|
|
27
|
-
[319, 3],
|
|
28
|
-
[326, 4],
|
|
29
|
-
[340, 48],
|
|
30
|
-
[388, 16, 280, 620],
|
|
31
|
-
[420, 36],
|
|
32
|
-
[456, 1],
|
|
33
|
-
[461, 2],
|
|
34
|
-
[467, 3],
|
|
35
|
-
[474, 4],
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
const accent: Bar[] = [
|
|
39
|
-
[68, 72, 420, 480],
|
|
40
|
-
[404, 16],
|
|
41
|
-
[488, 24],
|
|
42
|
-
[584, 48],
|
|
43
|
-
[668, 48],
|
|
44
|
-
]
|
|
45
|
-
|
|
46
|
-
// Hairlines are the thin 1-4 unit bars, blocks the wide ones. Dark mode dims the hairlines and
|
|
47
|
-
// lightens the blocks the way the brand's inverse logo does.
|
|
48
|
-
const hairlines = ink.filter(([, width]) => width <= 4)
|
|
49
|
-
const blocks = ink.filter(([, width]) => width > 4)
|
|
50
|
-
|
|
51
|
-
function Bars({ bars, className }: { bars: Bar[]; className: string }) {
|
|
52
|
-
return (
|
|
53
|
-
<g className={className}>
|
|
54
|
-
{bars.map(([x, width, y = 0, height = 900]) => (
|
|
55
|
-
<rect key={x} x={x} y={y} width={width} height={height} />
|
|
56
|
-
))}
|
|
57
|
-
</g>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function Stripes({ className }: { className?: string }) {
|
|
62
|
-
return (
|
|
63
|
-
<svg
|
|
64
|
-
viewBox="0 0 720 900"
|
|
65
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
66
|
-
aria-hidden="true"
|
|
67
|
-
preserveAspectRatio="xMinYMid slice"
|
|
68
|
-
className={cn("absolute", className)}
|
|
69
|
-
>
|
|
70
|
-
<Bars bars={hairlines} className="fill-logo-hatch" />
|
|
71
|
-
<Bars bars={blocks} className="fill-logo-ink" />
|
|
72
|
-
<Bars bars={accent} className="fill-primary" />
|
|
73
|
-
</svg>
|
|
74
|
-
)
|
|
75
|
-
}
|