create-swift-rust 0.8.2 → 0.9.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/dist/index.js +204 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/default/package.json +5 -5
- package/templates/ui/accordion.tsx +215 -0
- package/templates/ui/alert.tsx +134 -0
- package/templates/ui/avatar.tsx +89 -0
- package/templates/ui/button.tsx +133 -0
- package/templates/ui/card.tsx +124 -0
- package/templates/ui/input.tsx +87 -0
- package/templates/ui/label.tsx +49 -0
- package/templates/ui/utils.ts +6 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* swift-rust ui · Input
|
|
6
|
+
*
|
|
7
|
+
* variant — default, outline, secondary, ghost, destructive
|
|
8
|
+
* size — xs, sm, default, md, lg (the native `size` attribute is dropped)
|
|
9
|
+
* design — flat, soft, 3d, glass, neo, brutal, gradient
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export type InputVariant = "default" | "outline" | "secondary" | "ghost" | "destructive";
|
|
13
|
+
export type InputSize = "default" | "xs" | "sm" | "md" | "lg";
|
|
14
|
+
export type InputDesign = "flat" | "soft" | "3d" | "glass" | "neo" | "brutal" | "gradient";
|
|
15
|
+
|
|
16
|
+
const VARIANTS: Record<InputVariant, string> = {
|
|
17
|
+
default: "border border-input bg-background",
|
|
18
|
+
outline: "border-2 border-input bg-transparent",
|
|
19
|
+
secondary: "border border-transparent bg-secondary",
|
|
20
|
+
ghost: "border border-transparent bg-transparent hover:bg-secondary/50",
|
|
21
|
+
destructive:
|
|
22
|
+
"border border-destructive text-destructive placeholder:text-destructive/60 focus-visible:ring-destructive/40",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const SIZES: Record<InputSize, string> = {
|
|
26
|
+
default: "h-9 px-3 py-1 text-sm",
|
|
27
|
+
xs: "h-7 rounded-md px-2 text-xs",
|
|
28
|
+
sm: "h-8 px-2.5 text-xs",
|
|
29
|
+
md: "h-9 px-3 py-1 text-sm",
|
|
30
|
+
lg: "h-10 px-4 text-base",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const DESIGNS: Record<InputDesign, string> = {
|
|
34
|
+
flat: "shadow-xs",
|
|
35
|
+
soft: "rounded-xl border-transparent bg-secondary shadow-none",
|
|
36
|
+
// A field reads "deep" when it looks recessed: a darker top edge + a top→down
|
|
37
|
+
// shading gradient sink the surface in (no inset shadow).
|
|
38
|
+
"3d": "border-t-2 border-t-black/15 bg-linear-to-b from-black/[0.06] to-transparent dark:border-t-black/40",
|
|
39
|
+
// Liquid glass field: blur + saturation, translucent sheen, bright rim.
|
|
40
|
+
glass:
|
|
41
|
+
"border-white/40 bg-white/15 backdrop-blur-xl backdrop-saturate-200 placeholder:text-foreground/50 " +
|
|
42
|
+
"bg-linear-to-br from-white/30 to-white/5 " +
|
|
43
|
+
"dark:border-white/20 dark:bg-white/10 dark:from-white/15 dark:to-transparent",
|
|
44
|
+
neo:
|
|
45
|
+
"border-transparent bg-background " +
|
|
46
|
+
"shadow-[inset_3px_3px_6px_rgba(0,0,0,0.12),inset_-3px_-3px_6px_rgba(255,255,255,0.7)] " +
|
|
47
|
+
"dark:shadow-[inset_3px_3px_6px_rgba(0,0,0,0.6),inset_-3px_-3px_6px_rgba(255,255,255,0.05)]",
|
|
48
|
+
brutal:
|
|
49
|
+
"rounded-none border-2 border-foreground shadow-[3px_3px_0_0_var(--color-foreground)] " +
|
|
50
|
+
"focus-visible:shadow-[1px_1px_0_0_var(--color-foreground)] focus-visible:ring-0",
|
|
51
|
+
gradient:
|
|
52
|
+
"border-2 border-transparent " +
|
|
53
|
+
"[background:linear-gradient(var(--color-background),var(--color-background))_padding-box," +
|
|
54
|
+
"linear-gradient(135deg,#8b5cf6,#d946ef,#fb923c)_border-box]",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export interface InputProps
|
|
58
|
+
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
59
|
+
variant?: InputVariant;
|
|
60
|
+
size?: InputSize;
|
|
61
|
+
design?: InputDesign;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
65
|
+
(
|
|
66
|
+
{ className, type = "text", variant = "default", size = "default", design = "flat", ...props },
|
|
67
|
+
ref,
|
|
68
|
+
) => (
|
|
69
|
+
<input
|
|
70
|
+
type={type}
|
|
71
|
+
ref={ref}
|
|
72
|
+
className={cn(
|
|
73
|
+
"flex w-full min-w-0 rounded-lg text-foreground transition-[color,box-shadow,background-color]",
|
|
74
|
+
"placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground",
|
|
75
|
+
"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring/50",
|
|
76
|
+
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
77
|
+
"file:inline-flex file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground",
|
|
78
|
+
VARIANTS[variant],
|
|
79
|
+
SIZES[size],
|
|
80
|
+
DESIGNS[design],
|
|
81
|
+
className,
|
|
82
|
+
)}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
),
|
|
86
|
+
);
|
|
87
|
+
Input.displayName = "Input";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* swift-rust ui · Label
|
|
6
|
+
*
|
|
7
|
+
* variant — default, secondary (muted), destructive (error)
|
|
8
|
+
* size — xs, sm, default, md, lg
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type LabelVariant = "default" | "secondary" | "destructive";
|
|
12
|
+
export type LabelSize = "default" | "xs" | "sm" | "md" | "lg";
|
|
13
|
+
|
|
14
|
+
const VARIANTS: Record<LabelVariant, string> = {
|
|
15
|
+
default: "text-foreground",
|
|
16
|
+
secondary: "text-muted-foreground",
|
|
17
|
+
destructive: "text-destructive",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const SIZES: Record<LabelSize, string> = {
|
|
21
|
+
default: "text-sm",
|
|
22
|
+
xs: "text-xs",
|
|
23
|
+
sm: "text-xs",
|
|
24
|
+
md: "text-sm",
|
|
25
|
+
lg: "text-base",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
29
|
+
variant?: LabelVariant;
|
|
30
|
+
size?: LabelSize;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const Label = React.forwardRef<HTMLLabelElement, LabelProps>(
|
|
34
|
+
({ className, variant = "default", size = "default", ...props }, ref) => (
|
|
35
|
+
<label
|
|
36
|
+
ref={ref}
|
|
37
|
+
className={cn(
|
|
38
|
+
"flex select-none items-center gap-2 font-medium leading-none",
|
|
39
|
+
"peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
40
|
+
"group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50",
|
|
41
|
+
VARIANTS[variant],
|
|
42
|
+
SIZES[size],
|
|
43
|
+
className,
|
|
44
|
+
)}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
Label.displayName = "Label";
|