@otfdashkit/ui 0.1.3 → 0.1.4
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 +4 -4
- package/dist/index.js +907 -546
- package/dist/index.mjs +774 -415
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/primitives/Button/Button.tsx +2 -131
- package/src/primitives/button.tsx +52 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@otfdashkit/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "OTF UI — production-quality React component library. 98 primitives + blocks + layouts + charts on Radix + Tailwind v4. Cross-platform parity API with @otfdashkit/ui-native.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"otfdashkit",
|
package/src/index.ts
CHANGED
|
@@ -167,7 +167,8 @@ export * from './text'
|
|
|
167
167
|
export * from './backgrounds'
|
|
168
168
|
export * from './headers'
|
|
169
169
|
export * from './motion'
|
|
170
|
-
//
|
|
170
|
+
// './data' is not star-exported: its DataGrid name collides with components/data-grid.
|
|
171
|
+
export { DataGrid as AdvancedDataGrid, type DataGridProps as AdvancedDataGridProps } from './data/DataGrid'
|
|
171
172
|
export * from './data/DataList'
|
|
172
173
|
export * from './data/EventCalendar'
|
|
173
174
|
export * from './data/GridList'
|
|
@@ -1,131 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { cva, type VariantProps } from 'class-variance-authority'
|
|
4
|
-
import { cn } from '../utils/cn'
|
|
5
|
-
|
|
6
|
-
const buttonVariants = cva(
|
|
7
|
-
[
|
|
8
|
-
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium font-sans',
|
|
9
|
-
'transition-colors duration-[var(--duration-fast,100ms)]',
|
|
10
|
-
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
11
|
-
'disabled:pointer-events-none disabled:opacity-50',
|
|
12
|
-
'select-none',
|
|
13
|
-
].join(' '),
|
|
14
|
-
{
|
|
15
|
-
variants: {
|
|
16
|
-
variant: {
|
|
17
|
-
default:
|
|
18
|
-
'bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80',
|
|
19
|
-
secondary:
|
|
20
|
-
'bg-secondary text-secondary-foreground hover:bg-secondary/80 active:bg-secondary/70',
|
|
21
|
-
outline:
|
|
22
|
-
'border border-border bg-transparent hover:bg-accent hover:text-accent-foreground active:bg-accent/70',
|
|
23
|
-
ghost:
|
|
24
|
-
'hover:bg-accent hover:text-accent-foreground active:bg-accent/70',
|
|
25
|
-
destructive:
|
|
26
|
-
'bg-destructive text-destructive-foreground hover:bg-destructive/90 active:bg-destructive/80',
|
|
27
|
-
link:
|
|
28
|
-
'text-primary underline-offset-4 hover:underline',
|
|
29
|
-
/** Gradient stack — premium variant */
|
|
30
|
-
gradient: [
|
|
31
|
-
'bg-gradient-to-b from-primary to-[hsl(var(--primary)/0.8)]',
|
|
32
|
-
'text-primary-foreground',
|
|
33
|
-
'shadow-[0_1px_0_0_rgba(255,255,255,0.1)_inset,0_-1px_0_0_rgba(0,0,0,0.25)_inset]',
|
|
34
|
-
'hover:from-[hsl(var(--primary)/0.9)] hover:to-[hsl(var(--primary)/0.7)]',
|
|
35
|
-
'active:from-[hsl(var(--primary)/0.8)] active:to-[hsl(var(--primary)/0.6)]',
|
|
36
|
-
].join(' '),
|
|
37
|
-
/** Texture — nested ring surface as a button */
|
|
38
|
-
texture: [
|
|
39
|
-
'relative border border-border/40',
|
|
40
|
-
'bg-gradient-to-b from-card to-[hsl(var(--card)/0.9)]',
|
|
41
|
-
'text-foreground',
|
|
42
|
-
'shadow-[0_0_0_1px_hsl(var(--border)/0.2)_inset]',
|
|
43
|
-
'hover:border-border/60 hover:bg-accent',
|
|
44
|
-
'active:shadow-none',
|
|
45
|
-
].join(' '),
|
|
46
|
-
/** Shimmer — animated conic gradient sweep with a hover highlight.
|
|
47
|
-
* Loud + premium; reserve for primary CTAs and pricing pages, not
|
|
48
|
-
* for in-product UI (gets tiring fast). Cross-platform parity with
|
|
49
|
-
* @otfdashkit/ui-native via the same `shimmer` variant key. */
|
|
50
|
-
shimmer: [
|
|
51
|
-
'relative isolate overflow-hidden',
|
|
52
|
-
'bg-primary text-primary-foreground',
|
|
53
|
-
'shadow-[0_1px_0_rgba(255,255,255,0.18)_inset,0_-1px_0_rgba(0,0,0,0.25)_inset]',
|
|
54
|
-
'hover:bg-primary/95',
|
|
55
|
-
// Continuous conic-gradient sweep behind the surface.
|
|
56
|
-
'before:absolute before:inset-[-1px] before:rounded-[inherit] before:-z-10',
|
|
57
|
-
'before:bg-[conic-gradient(from_0deg,transparent_0deg,transparent_70deg,rgba(255,255,255,0.55)_90deg,transparent_110deg,transparent_360deg)]',
|
|
58
|
-
'before:animate-[shimmer-rotate_2.6s_linear_infinite]',
|
|
59
|
-
// Diagonal gloss that sweeps on hover.
|
|
60
|
-
'after:absolute after:inset-0 after:rounded-[inherit] after:pointer-events-none',
|
|
61
|
-
'after:bg-[linear-gradient(115deg,transparent_30%,rgba(255,255,255,0.22)_50%,transparent_70%)]',
|
|
62
|
-
'after:translate-x-[-120%] hover:after:translate-x-[120%] after:transition-transform after:duration-[900ms] after:ease-out',
|
|
63
|
-
].join(' '),
|
|
64
|
-
},
|
|
65
|
-
size: {
|
|
66
|
-
sm: 'h-8 px-3 text-xs rounded-md',
|
|
67
|
-
default: 'h-9 px-4 py-2',
|
|
68
|
-
lg: 'h-11 px-6 text-base',
|
|
69
|
-
xl: 'h-12 px-8 text-base',
|
|
70
|
-
icon: 'h-9 w-9 p-0',
|
|
71
|
-
'icon-sm': 'h-7 w-7 p-0 text-xs',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
defaultVariants: { variant: 'default', size: 'default' },
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
export interface ButtonProps
|
|
79
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
80
|
-
VariantProps<typeof buttonVariants> {
|
|
81
|
-
asChild?: boolean
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
85
|
-
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
86
|
-
const Comp = asChild ? Slot : 'button'
|
|
87
|
-
return (
|
|
88
|
-
<Comp
|
|
89
|
-
data-slot="button"
|
|
90
|
-
className={cn(buttonVariants({ variant, size }), className)}
|
|
91
|
-
ref={ref}
|
|
92
|
-
{...props}
|
|
93
|
-
/>
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
Button.displayName = 'Button'
|
|
98
|
-
|
|
99
|
-
export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
100
|
-
icon: React.ReactNode
|
|
101
|
-
label: string
|
|
102
|
-
size?: 'sm' | 'default' | 'lg'
|
|
103
|
-
variant?: VariantProps<typeof buttonVariants>['variant']
|
|
104
|
-
asChild?: boolean
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
108
|
-
({ icon, label, size = 'default', variant = 'ghost', className, asChild = false, ...props }, ref) => {
|
|
109
|
-
const Comp = asChild ? Slot : 'button'
|
|
110
|
-
const sizeClass = size === 'sm' ? 'h-7 w-7' : size === 'lg' ? 'h-10 w-10' : 'h-9 w-9'
|
|
111
|
-
return (
|
|
112
|
-
<Comp
|
|
113
|
-
ref={ref}
|
|
114
|
-
aria-label={label}
|
|
115
|
-
data-slot="icon-button"
|
|
116
|
-
className={cn(
|
|
117
|
-
buttonVariants({ variant }),
|
|
118
|
-
sizeClass,
|
|
119
|
-
'p-0 shrink-0',
|
|
120
|
-
className
|
|
121
|
-
)}
|
|
122
|
-
{...props}
|
|
123
|
-
>
|
|
124
|
-
{icon}
|
|
125
|
-
</Comp>
|
|
126
|
-
)
|
|
127
|
-
}
|
|
128
|
-
)
|
|
129
|
-
IconButton.displayName = 'IconButton'
|
|
130
|
-
|
|
131
|
-
export { buttonVariants }
|
|
1
|
+
// Single source of truth lives in ../button; this path stays so existing imports keep working.
|
|
2
|
+
export * from '../button'
|
|
@@ -14,12 +14,42 @@ const buttonVariants = cva(
|
|
|
14
14
|
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
15
15
|
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
|
|
16
16
|
link: 'text-primary underline-offset-4 hover:underline',
|
|
17
|
+
gradient: [
|
|
18
|
+
'bg-gradient-to-b from-primary to-[hsl(var(--primary)/0.8)]',
|
|
19
|
+
'text-primary-foreground',
|
|
20
|
+
'shadow-[0_1px_0_0_rgba(255,255,255,0.1)_inset,0_-1px_0_0_rgba(0,0,0,0.25)_inset]',
|
|
21
|
+
'hover:from-[hsl(var(--primary)/0.9)] hover:to-[hsl(var(--primary)/0.7)]',
|
|
22
|
+
'active:from-[hsl(var(--primary)/0.8)] active:to-[hsl(var(--primary)/0.6)]',
|
|
23
|
+
].join(' '),
|
|
24
|
+
texture: [
|
|
25
|
+
'relative border border-border/40',
|
|
26
|
+
'bg-gradient-to-b from-card to-[hsl(var(--card)/0.9)]',
|
|
27
|
+
'text-foreground',
|
|
28
|
+
'shadow-[0_0_0_1px_hsl(var(--border)/0.2)_inset]',
|
|
29
|
+
'hover:border-border/60 hover:bg-accent',
|
|
30
|
+
'active:shadow-none',
|
|
31
|
+
].join(' '),
|
|
32
|
+
// Loud by design: keep for primary CTAs. The sweep keyframe ships in themes/base.css.
|
|
33
|
+
shimmer: [
|
|
34
|
+
'relative isolate overflow-hidden',
|
|
35
|
+
'bg-primary text-primary-foreground',
|
|
36
|
+
'shadow-[0_1px_0_rgba(255,255,255,0.18)_inset,0_-1px_0_rgba(0,0,0,0.25)_inset]',
|
|
37
|
+
'hover:bg-primary/95',
|
|
38
|
+
'before:absolute before:inset-[-1px] before:rounded-[inherit] before:-z-10',
|
|
39
|
+
'before:bg-[conic-gradient(from_0deg,transparent_0deg,transparent_70deg,rgba(255,255,255,0.55)_90deg,transparent_110deg,transparent_360deg)]',
|
|
40
|
+
'before:animate-[shimmer-rotate_2.6s_linear_infinite] motion-reduce:before:animate-none',
|
|
41
|
+
'after:absolute after:inset-0 after:rounded-[inherit] after:pointer-events-none',
|
|
42
|
+
'after:bg-[linear-gradient(115deg,transparent_30%,rgba(255,255,255,0.22)_50%,transparent_70%)]',
|
|
43
|
+
'after:translate-x-[-120%] hover:after:translate-x-[120%] after:transition-transform after:duration-[900ms] after:ease-out',
|
|
44
|
+
].join(' '),
|
|
17
45
|
},
|
|
18
46
|
size: {
|
|
19
47
|
sm: 'h-8 px-3 text-xs',
|
|
20
48
|
default: 'h-9 px-4 py-2',
|
|
21
49
|
lg: 'h-11 px-6 text-base',
|
|
50
|
+
xl: 'h-12 px-8 text-base',
|
|
22
51
|
icon: 'h-9 w-9',
|
|
52
|
+
'icon-sm': 'h-7 w-7 p-0 text-xs',
|
|
23
53
|
},
|
|
24
54
|
},
|
|
25
55
|
defaultVariants: { variant: 'default', size: 'default' },
|
|
@@ -40,4 +70,26 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
40
70
|
)
|
|
41
71
|
Button.displayName = 'Button'
|
|
42
72
|
|
|
73
|
+
export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
74
|
+
icon: React.ReactNode
|
|
75
|
+
/** Accessible name; an icon-only button has no visible text. */
|
|
76
|
+
label: string
|
|
77
|
+
size?: 'sm' | 'default' | 'lg'
|
|
78
|
+
variant?: VariantProps<typeof buttonVariants>['variant']
|
|
79
|
+
asChild?: boolean
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
83
|
+
({ icon, label, size = 'default', variant = 'ghost', className, asChild = false, ...props }, ref) => {
|
|
84
|
+
const Comp = asChild ? Slot : 'button'
|
|
85
|
+
const sizeClass = size === 'sm' ? 'h-7 w-7' : size === 'lg' ? 'h-10 w-10' : 'h-9 w-9'
|
|
86
|
+
return (
|
|
87
|
+
<Comp ref={ref} aria-label={label} className={cn(buttonVariants({ variant }), sizeClass, 'p-0 shrink-0', className)} {...props}>
|
|
88
|
+
{icon}
|
|
89
|
+
</Comp>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
IconButton.displayName = 'IconButton'
|
|
94
|
+
|
|
43
95
|
export { buttonVariants }
|