@brightlocal/ui-components 2.24.1 → 2.25.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 +2 -1
- package/component-meta.json +93 -79
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +2 -2
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.js +17 -17
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +9 -9
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +43 -46
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.js +14 -14
- package/dist/brand-illustration-motif.cjs +1 -1
- package/dist/brand-illustration-motif.js +11 -11
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +10 -10
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.js +12 -12
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +7 -7
- package/dist/chip.cjs +1 -1
- package/dist/chip.js +7 -7
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.js +1 -1
- package/dist/data-table.d.ts +29 -0
- package/dist/data-table.d.ts.map +1 -1
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +61 -61
- package/dist/field.cjs +1 -1
- package/dist/field.js +1 -1
- package/dist/height-transition.cjs +1 -0
- package/dist/height-transition.d.ts +44 -0
- package/dist/height-transition.d.ts.map +1 -0
- package/dist/height-transition.js +63 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +326 -324
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.js +2 -2
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +15 -15
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +1 -1
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/lib/motion.cjs +1 -0
- package/dist/lib/motion.d.ts +70 -0
- package/dist/lib/motion.d.ts.map +1 -0
- package/dist/lib/motion.js +25 -0
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +12 -4
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +17 -16
- package/dist/list.cjs +1 -1
- package/dist/list.js +10 -10
- package/dist/loading.cjs +1 -1
- package/dist/loading.d.ts.map +1 -1
- package/dist/loading.js +45 -47
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +2 -2
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.js +5 -5
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.js +13 -13
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.js +1 -1
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +21 -25
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +12 -12
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.js +11 -11
- package/dist/select.cjs +1 -1
- package/dist/select.js +12 -12
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +54 -50
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +13 -13
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +4 -4
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +5 -5
- package/dist/table.cjs +1 -1
- package/dist/table.js +2 -2
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/text-reveal-motion.js +77 -79
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +11 -11
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +5 -5
- package/package.json +13 -4
- package/src/blocks/input-list.tsx +3 -6
- package/src/blocks/sidebar.tsx +14 -14
- package/src/components/accordion.tsx +2 -2
- package/src/components/alert-dialog.tsx +2 -2
- package/src/components/badge.tsx +1 -1
- package/src/components/brand-illustration-motif.tsx +1 -1
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +2 -2
- package/src/components/card.tsx +1 -1
- package/src/components/carousel.tsx +1 -1
- package/src/components/checkbox.tsx +1 -1
- package/src/components/chip.tsx +2 -2
- package/src/components/combobox.tsx +1 -1
- package/src/components/data-table.tsx +29 -0
- package/src/components/dialog.tsx +3 -3
- package/src/components/field.tsx +1 -1
- package/src/components/height-transition.tsx +164 -0
- package/src/components/input-chip.tsx +2 -2
- package/src/components/input-group.tsx +2 -2
- package/src/components/input-otp.tsx +1 -1
- package/src/components/input.tsx +1 -1
- package/src/components/link.tsx +4 -3
- package/src/components/list.tsx +1 -1
- package/src/components/loading.tsx +2 -15
- package/src/components/map.tsx +3 -2
- package/src/components/menubar.tsx +5 -5
- package/src/components/navigation-menu.tsx +6 -6
- package/src/components/pagination.tsx +1 -1
- package/src/components/progress.tsx +2 -10
- package/src/components/radio-group.tsx +1 -1
- package/src/components/scroll-area.tsx +2 -2
- package/src/components/select.tsx +1 -1
- package/src/components/sheet.tsx +9 -5
- package/src/components/slider.tsx +1 -1
- package/src/components/stepper.tsx +4 -4
- package/src/components/switch.tsx +2 -2
- package/src/components/table.tsx +2 -2
- package/src/components/tabs.tsx +1 -1
- package/src/components/text-reveal-motion.tsx +3 -8
- package/src/components/textarea.tsx +1 -1
- package/src/components/toggle.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/lib/motion.ts +75 -0
- package/src/lib/utils.ts +14 -2
|
@@ -6,6 +6,7 @@ import { motion } from "framer-motion";
|
|
|
6
6
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
import { usePrefersReducedMotion } from "@brightlocal/ui-components/hooks/use-prefers-reduced-motion";
|
|
9
|
+
import { SPRING_GENTLE } from "../lib/motion";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Brand color for the progress indicator, drawn from the shared brand palette.
|
|
@@ -195,16 +196,7 @@ const Progress = React.forwardRef<
|
|
|
195
196
|
)}
|
|
196
197
|
data-slot="progress-indicator"
|
|
197
198
|
initial={false}
|
|
198
|
-
transition={
|
|
199
|
-
prefersReducedMotion
|
|
200
|
-
? { duration: 0 }
|
|
201
|
-
: {
|
|
202
|
-
type: "spring",
|
|
203
|
-
stiffness: 80,
|
|
204
|
-
damping: 20,
|
|
205
|
-
mass: 1,
|
|
206
|
-
}
|
|
207
|
-
}
|
|
199
|
+
transition={prefersReducedMotion ? { duration: 0 } : SPRING_GENTLE}
|
|
208
200
|
/>
|
|
209
201
|
</ProgressPrimitive.Indicator>
|
|
210
202
|
</ProgressPrimitive.Root>
|
|
@@ -41,7 +41,7 @@ const radioGroupItemVariants = cva(
|
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
const radioCircleVariants = cva(
|
|
44
|
-
"relative aspect-square size-4 shrink-0 rounded-full border transition-[border-color,border-width,box-shadow,background-color]",
|
|
44
|
+
"relative aspect-square size-4 shrink-0 rounded-full border transition-[border-color,border-width,box-shadow,background-color] duration-fast ease-out",
|
|
45
45
|
{
|
|
46
46
|
variants: {
|
|
47
47
|
variant: {
|
|
@@ -60,7 +60,7 @@ const ScrollArea = React.forwardRef<
|
|
|
60
60
|
{...props}
|
|
61
61
|
>
|
|
62
62
|
<ScrollAreaPrimitive.Viewport
|
|
63
|
-
className="focus-visible:shadow-default size-full rounded-[inherit] p-1 transition-[color,box-shadow] outline-none"
|
|
63
|
+
className="focus-visible:shadow-default duration-fast size-full rounded-[inherit] p-1 transition-[color,box-shadow] ease-out outline-none"
|
|
64
64
|
data-slot="scroll-area-viewport"
|
|
65
65
|
tabIndex={0}
|
|
66
66
|
>
|
|
@@ -123,7 +123,7 @@ const ScrollBar = React.forwardRef<
|
|
|
123
123
|
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
|
124
124
|
ref={ref}
|
|
125
125
|
className={cn(
|
|
126
|
-
"flex touch-none p-px transition-colors select-none",
|
|
126
|
+
"duration-fast flex touch-none p-px transition-colors ease-out select-none",
|
|
127
127
|
orientation === "vertical" &&
|
|
128
128
|
"h-full w-2.5 border-l border-l-transparent",
|
|
129
129
|
orientation === "horizontal" &&
|
|
@@ -180,7 +180,7 @@ const selectTriggerVariants = cva([
|
|
|
180
180
|
"px-3 py-2",
|
|
181
181
|
|
|
182
182
|
// Base appearance
|
|
183
|
-
"border border-border rounded-sm outline-none transition-[border-color,box-shadow,background-color]",
|
|
183
|
+
"border border-border rounded-sm outline-none transition-[border-color,box-shadow,background-color] duration-fast ease-out",
|
|
184
184
|
"bg-neutral-50 border-neutral-300",
|
|
185
185
|
"dark:bg-white/5 dark:border-white/15",
|
|
186
186
|
|
package/src/components/sheet.tsx
CHANGED
|
@@ -29,10 +29,14 @@ const sheetContentVariants = cva(
|
|
|
29
29
|
"gap-4",
|
|
30
30
|
"p-6",
|
|
31
31
|
"shadow-lg",
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
// Large-surface timing (DS-806): enter at duration-slow (300ms), exit ~20%
|
|
33
|
+
// faster — users asked for the thing to go away. Enter decelerates
|
|
34
|
+
// (ease-out), exit accelerates away (ease-in); these time the tw-animate
|
|
35
|
+
// enter/exit keyframes via --tw-duration/--tw-ease.
|
|
36
|
+
"ease-out",
|
|
37
|
+
"data-[state=closed]:ease-in",
|
|
38
|
+
"data-[state=open]:duration-slow",
|
|
39
|
+
"data-[state=closed]:duration-250",
|
|
36
40
|
],
|
|
37
41
|
{
|
|
38
42
|
variants: {
|
|
@@ -230,7 +234,7 @@ const SheetContent = React.forwardRef<
|
|
|
230
234
|
{...props}
|
|
231
235
|
>
|
|
232
236
|
{children}
|
|
233
|
-
<SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2
|
|
237
|
+
<SheetPrimitive.Close className="ring-offset-background focus-visible:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground duration-fast absolute top-4 right-4 rounded-xs opacity-70 outline-hidden transition-opacity ease-out hover:opacity-100 focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0">
|
|
234
238
|
<X />
|
|
235
239
|
<span className="sr-only">{closeLabel ?? "Close"}</span>
|
|
236
240
|
</SheetPrimitive.Close>
|
|
@@ -169,7 +169,7 @@ const Slider = React.forwardRef<
|
|
|
169
169
|
<SliderPrimitive.Thumb
|
|
170
170
|
key={index}
|
|
171
171
|
aria-label={getThumbLabel(index)}
|
|
172
|
-
className="border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
172
|
+
className="border-primary bg-background ring-ring/50 duration-fast block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] ease-out hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
173
173
|
data-slot="slider-thumb"
|
|
174
174
|
/>
|
|
175
175
|
))}
|
|
@@ -446,9 +446,9 @@ StepperTrigger.displayName = "StepperTrigger";
|
|
|
446
446
|
const stepperIndicatorStyles = cva(
|
|
447
447
|
[
|
|
448
448
|
"relative flex size-8 shrink-0 items-center justify-center rounded-full text-xs font-medium",
|
|
449
|
-
"transition-colors duration-
|
|
449
|
+
"transition-colors duration-fast ease-out",
|
|
450
450
|
// Hover overlay (only visible when wrapped by an interactive trigger).
|
|
451
|
-
"after:pointer-events-none after:absolute after:inset-0 after:rounded-full after:bg-white/10 after:opacity-0 after:transition-opacity after:duration-
|
|
451
|
+
"after:pointer-events-none after:absolute after:inset-0 after:rounded-full after:bg-white/10 after:opacity-0 after:transition-opacity after:duration-fast after:ease-out",
|
|
452
452
|
"group-hover/trigger:after:opacity-100",
|
|
453
453
|
// Focus ring is rendered here (around the circle) when the trigger is
|
|
454
454
|
// keyboard-focused, rather than around the whole trigger.
|
|
@@ -552,7 +552,7 @@ const StepperIndicator = React.forwardRef<
|
|
|
552
552
|
<>
|
|
553
553
|
<span
|
|
554
554
|
className={cn(
|
|
555
|
-
"transition-opacity
|
|
555
|
+
"duration-fast transition-opacity ease-out",
|
|
556
556
|
(state === "completed" || state === "error" || isLoading) &&
|
|
557
557
|
"opacity-0"
|
|
558
558
|
)}
|
|
@@ -608,7 +608,7 @@ const StepperSeparator = React.forwardRef<
|
|
|
608
608
|
ref={ref}
|
|
609
609
|
aria-hidden="true"
|
|
610
610
|
className={cn(
|
|
611
|
-
"bg-border shrink-0 rounded-full transition-colors
|
|
611
|
+
"bg-border duration-fast shrink-0 rounded-full transition-colors ease-out",
|
|
612
612
|
"group-data-[state=completed]/step:bg-primary",
|
|
613
613
|
"group-data-[disabled=true]/step:opacity-50",
|
|
614
614
|
// Horizontal + labels below: absolute connector spanning this indicator
|
|
@@ -26,7 +26,7 @@ const Switch = React.forwardRef<
|
|
|
26
26
|
ref={ref}
|
|
27
27
|
className={cn(
|
|
28
28
|
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring dark:data-[state=unchecked]:bg-input/80 dark:focus-visible:border-neutral-500",
|
|
29
|
-
"focus-visible:shadow-default inline-flex h-5 w-9 shrink-0 items-center rounded-full border-1 border-transparent shadow-xs transition-[background-color,border-color,box-shadow] outline-none",
|
|
29
|
+
"focus-visible:shadow-default duration-fast inline-flex h-5 w-9 shrink-0 items-center rounded-full border-1 border-transparent shadow-xs transition-[background-color,border-color,box-shadow] ease-out outline-none",
|
|
30
30
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
31
31
|
"pl-[1px]",
|
|
32
32
|
className
|
|
@@ -40,7 +40,7 @@ const Switch = React.forwardRef<
|
|
|
40
40
|
<SwitchPrimitive.Thumb
|
|
41
41
|
className={cn(
|
|
42
42
|
"bg-background",
|
|
43
|
-
"pointer-events-none block size-4 rounded-full ring-0 transition-transform",
|
|
43
|
+
"duration-base pointer-events-none block size-4 rounded-full ring-0 transition-transform ease-in-out",
|
|
44
44
|
"data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
|
45
45
|
)}
|
|
46
46
|
data-slot="switch-thumb"
|
package/src/components/table.tsx
CHANGED
|
@@ -32,7 +32,7 @@ const tableCellVariants = cva(
|
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const tableHeadVariants = cva(
|
|
35
|
-
"h-12 p-2 align-middle text-muted-foreground text-sm font-medium leading-normal break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-
|
|
35
|
+
"h-12 p-2 align-middle text-muted-foreground text-sm font-medium leading-normal break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-fast ease-out",
|
|
36
36
|
{
|
|
37
37
|
variants: {
|
|
38
38
|
align: {
|
|
@@ -233,7 +233,7 @@ const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(
|
|
|
233
233
|
<tr
|
|
234
234
|
ref={ref}
|
|
235
235
|
className={cn(
|
|
236
|
-
"data-[state=selected]:bg-muted transition-colors
|
|
236
|
+
"data-[state=selected]:bg-muted duration-fast transition-colors ease-out",
|
|
237
237
|
className
|
|
238
238
|
)}
|
|
239
239
|
data-hook={dataHook}
|
package/src/components/tabs.tsx
CHANGED
|
@@ -207,7 +207,7 @@ function TabsTriggerInner<T extends string = string>(
|
|
|
207
207
|
// Text color
|
|
208
208
|
"text-foreground",
|
|
209
209
|
// Transition with explicit duration and easing
|
|
210
|
-
"transition-[color,box-shadow]
|
|
210
|
+
"duration-fast transition-[color,box-shadow] ease-out",
|
|
211
211
|
// Active state
|
|
212
212
|
"data-[state=active]:bg-background data-[state=active]:shadow-sm",
|
|
213
213
|
// Focus state - use compound selector for active+focused to override shadow-sm with shadow-default
|
|
@@ -13,7 +13,7 @@ import { animate } from "framer-motion";
|
|
|
13
13
|
|
|
14
14
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
15
15
|
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion";
|
|
16
|
-
import { SETTLE_REST_DELTA } from "../lib/
|
|
16
|
+
import { SETTLE_REST_DELTA, SPRING_SETTLE, SPRING_SMOOTH } from "../lib/motion";
|
|
17
17
|
|
|
18
18
|
// ---------------------------------------------------------------------------
|
|
19
19
|
// Shape paths (500×500 viewBox)
|
|
@@ -229,9 +229,7 @@ const TextRevealMotion = React.forwardRef<
|
|
|
229
229
|
// Internal animation defaults matching the Loading story tuning
|
|
230
230
|
const shapes = DEFAULT_SHAPES;
|
|
231
231
|
const rollSpeed = 0.8;
|
|
232
|
-
const stiffness =
|
|
233
|
-
const damping = 24;
|
|
234
|
-
const mass = 1;
|
|
232
|
+
const { stiffness, damping, mass } = SPRING_SMOOTH;
|
|
235
233
|
|
|
236
234
|
const reducedMotion = usePrefersReducedMotion();
|
|
237
235
|
const rawId = useId();
|
|
@@ -531,10 +529,7 @@ const TextRevealMotion = React.forwardRef<
|
|
|
531
529
|
return;
|
|
532
530
|
}
|
|
533
531
|
const controls = animate(0, 1 + SETTLE_REST_DELTA, {
|
|
534
|
-
|
|
535
|
-
stiffness: 30,
|
|
536
|
-
damping: 9,
|
|
537
|
-
mass: 0.5,
|
|
532
|
+
...SPRING_SETTLE,
|
|
538
533
|
restDelta: SETTLE_REST_DELTA,
|
|
539
534
|
onUpdate: (v: number) => {
|
|
540
535
|
if (signal.cancelled) {
|
|
@@ -8,7 +8,7 @@ const textareaVariants = cva([
|
|
|
8
8
|
"flex w-full",
|
|
9
9
|
// Appearance - Explicit background with isolation for contrast calculation
|
|
10
10
|
"border border-input bg-background rounded-md",
|
|
11
|
-
"outline-none transition-[border-color,background-color,box-shadow]",
|
|
11
|
+
"outline-none transition-[border-color,background-color,box-shadow] duration-fast ease-out",
|
|
12
12
|
// Typography
|
|
13
13
|
"text-base leading-normal font-sans",
|
|
14
14
|
"text-foreground",
|
|
@@ -7,7 +7,7 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
|
|
9
9
|
const toggleVariants = cva(
|
|
10
|
-
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-
|
|
10
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-fast ease-out whitespace-nowrap",
|
|
11
11
|
{
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from "./components/dropdown-menu";
|
|
|
29
29
|
export * from "./components/field";
|
|
30
30
|
export * from "./components/global-layout";
|
|
31
31
|
export * from "./components/header";
|
|
32
|
+
export * from "./components/height-transition";
|
|
32
33
|
export * from "./components/hover-card";
|
|
33
34
|
export * from "./components/input";
|
|
34
35
|
export * from "./components/input-chip";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared motion values for JS-driven (framer-motion) animation — the JS-side
|
|
3
|
+
* counterpart of the CSS motion token scale (`--ds-motion-*` in
|
|
4
|
+
* `@brightlocal/tokens`).
|
|
5
|
+
*
|
|
6
|
+
* Engine policy (DS-806): CSS is the default for predetermined state
|
|
7
|
+
* transitions and preset keyframes. framer-motion is allowed when animation
|
|
8
|
+
* behaviour requires runtime orchestration — progress-driven or
|
|
9
|
+
* gesture-interruptible motion, spring physics, layout measurement, or
|
|
10
|
+
* sequencing tied to React state — and every framer component must consume
|
|
11
|
+
* `usePrefersReducedMotion()` (the global CSS kill-switch cannot see
|
|
12
|
+
* JS-driven values).
|
|
13
|
+
*
|
|
14
|
+
* New framer code must use one of these presets. Introducing a new spring
|
|
15
|
+
* config means adding it here, which keeps drift reviewable.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export { SETTLE_REST_DELTA } from "./spring-settle";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Duration scale in milliseconds — mirrors --ds-motion-duration-fast/base/slow.
|
|
22
|
+
* fast: state changes (hover/focus color, shadow, opacity) + exits;
|
|
23
|
+
* press feedback is faster still (instant or ≤100ms)
|
|
24
|
+
* base: standard reveals + on-screen movement
|
|
25
|
+
* slow: large surfaces; the productive-motion ceiling
|
|
26
|
+
*/
|
|
27
|
+
export const MOTION_DURATION_FAST_MS = 150;
|
|
28
|
+
export const MOTION_DURATION_BASE_MS = 200;
|
|
29
|
+
export const MOTION_DURATION_SLOW_MS = 300;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Quick and controlled, no overshoot — list reorders and other
|
|
33
|
+
* small-element layout moves.
|
|
34
|
+
*
|
|
35
|
+
* Damping 45 keeps it at/above critical damping (2 × √500 ≈ 44.7, mass 1),
|
|
36
|
+
* so the "no overshoot" description physically holds — at the previous 35
|
|
37
|
+
* the spring was underdamped (ζ ≈ 0.78) and could overshoot.
|
|
38
|
+
*/
|
|
39
|
+
export const SPRING_SNAPPY = {
|
|
40
|
+
type: "spring",
|
|
41
|
+
stiffness: 500,
|
|
42
|
+
damping: 45,
|
|
43
|
+
} as const;
|
|
44
|
+
|
|
45
|
+
/** Balanced — text and content reveals. */
|
|
46
|
+
export const SPRING_SMOOTH = {
|
|
47
|
+
type: "spring",
|
|
48
|
+
stiffness: 180,
|
|
49
|
+
damping: 24,
|
|
50
|
+
mass: 1,
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
/** Soft and value-tracking — progress bars and gauges. */
|
|
54
|
+
export const SPRING_GENTLE = {
|
|
55
|
+
type: "spring",
|
|
56
|
+
stiffness: 80,
|
|
57
|
+
damping: 20,
|
|
58
|
+
mass: 1,
|
|
59
|
+
} as const;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Slow, non-overshooting morph driver for shape-progress springs (Loading,
|
|
63
|
+
* TextRevealMotion). Always pair with `SETTLE_REST_DELTA` (aim the spring at
|
|
64
|
+
* `1 + SETTLE_REST_DELTA` with `restDelta: SETTLE_REST_DELTA`) so the
|
|
65
|
+
* terminal snap lands off-screen.
|
|
66
|
+
*
|
|
67
|
+
* Precondition for the settle trick: damping ≥ 2 × √(stiffness × mass)
|
|
68
|
+
* (9 ≥ 2 × √(30 × 0.5) ≈ 7.75) — the spring must never overshoot.
|
|
69
|
+
*/
|
|
70
|
+
export const SPRING_SETTLE = {
|
|
71
|
+
type: "spring",
|
|
72
|
+
stiffness: 30,
|
|
73
|
+
damping: 9,
|
|
74
|
+
mass: 0.5,
|
|
75
|
+
} as const;
|
package/src/lib/utils.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { clsx, type ClassValue } from "clsx";
|
|
2
|
-
import {
|
|
2
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
3
|
+
|
|
4
|
+
// The motion scale adds named duration/ease utilities (tailwind-preset.css)
|
|
5
|
+
// that stock twMerge does not recognize — without registering them, a
|
|
6
|
+
// consumer's `duration-300` would not replace a baked-in `duration-fast`.
|
|
7
|
+
const twMerge = extendTailwindMerge({
|
|
8
|
+
extend: {
|
|
9
|
+
classGroups: {
|
|
10
|
+
duration: [{ duration: ["fast", "base", "slow"] }],
|
|
11
|
+
ease: [{ ease: ["emphasized", "overshoot"] }],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
3
15
|
|
|
4
16
|
export function cn(...inputs: ClassValue[]) {
|
|
5
17
|
return twMerge(clsx(inputs));
|
|
6
18
|
}
|
|
7
19
|
|
|
8
20
|
export const FLOATING_CONTENT_ANIMATION =
|
|
9
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";
|
|
21
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 duration-base ease-out data-[state=closed]:duration-fast data-[state=closed]:ease-in";
|