@umituz/web-design-system 1.9.1 → 1.9.3
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/package.json +1 -1
- package/src/presentation/atoms/Button.tsx +42 -44
- package/src/presentation/hooks/useLocalStorage.ts +1 -1
- package/src/presentation/organisms/AlertDialog.tsx +20 -1
- package/src/presentation/templates/Form.tsx +1 -1
- package/src/presentation/templates/List.tsx +1 -1
- package/src/presentation/templates/PageLayout.tsx +1 -1
- package/src/presentation/templates/ResponsiveContainer.tsx +5 -11
- package/src/presentation/templates/Section.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,54 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Button Component (Atom)
|
|
3
|
-
* @description Interactive button element
|
|
2
|
+
* Button Component (Atom) - Shadcn/ui format
|
|
3
|
+
* @description Interactive button element using class-variance-authority
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
8
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
variant?: ColorVariant;
|
|
12
|
-
size?: SizeVariant;
|
|
13
|
-
fullWidth?: boolean;
|
|
14
|
-
}
|
|
10
|
+
import { cn } from '../../infrastructure/utils';
|
|
15
11
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
const buttonVariants = cva(
|
|
13
|
+
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
|
14
|
+
{
|
|
15
|
+
variants: {
|
|
16
|
+
variant: {
|
|
17
|
+
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
18
|
+
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
|
|
19
|
+
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
|
20
|
+
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
21
|
+
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
22
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
default: 'h-10 px-4 py-2',
|
|
26
|
+
sm: 'h-9 rounded-md px-3',
|
|
27
|
+
lg: 'h-11 rounded-md px-8',
|
|
28
|
+
icon: 'h-10 w-10',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
variant: 'default',
|
|
33
|
+
size: 'default',
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
);
|
|
23
37
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
xl: 'h-11 px-6 text-lg',
|
|
30
|
-
};
|
|
38
|
+
export interface ButtonProps
|
|
39
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
40
|
+
VariantProps<typeof buttonVariants> {
|
|
41
|
+
asChild?: boolean;
|
|
42
|
+
}
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
({ className, variant
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
ref={ref}
|
|
37
|
-
type={type}
|
|
38
|
-
disabled={disabled}
|
|
39
|
-
className={cn(
|
|
40
|
-
'inline-flex items-center justify-center rounded-md font-medium transition-colors',
|
|
41
|
-
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
42
|
-
'disabled:pointer-events-none disabled:opacity-50',
|
|
43
|
-
variantStyles[variant],
|
|
44
|
-
sizeStyles[size],
|
|
45
|
-
fullWidth && 'w-full',
|
|
46
|
-
className
|
|
47
|
-
)}
|
|
48
|
-
{...props}
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
44
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
45
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
46
|
+
const Comp = asChild ? Slot : 'button';
|
|
47
|
+
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
|
|
51
48
|
}
|
|
52
49
|
);
|
|
53
|
-
|
|
54
50
|
Button.displayName = 'Button';
|
|
51
|
+
|
|
52
|
+
export { Button, buttonVariants };
|
|
@@ -25,7 +25,26 @@ import * as React from "react";
|
|
|
25
25
|
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
26
26
|
|
|
27
27
|
import { cn } from "../../infrastructure/utils";
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
// Import buttonVariants from the atoms folder
|
|
30
|
+
// We need to define it here since Button uses cva
|
|
31
|
+
import { cva } from "class-variance-authority";
|
|
32
|
+
|
|
33
|
+
const buttonVariants = cva(
|
|
34
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
35
|
+
{
|
|
36
|
+
variants: {
|
|
37
|
+
variant: {
|
|
38
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
39
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
40
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
41
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
42
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
43
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
);
|
|
29
48
|
|
|
30
49
|
const AlertDialog = AlertDialogPrimitive.Root;
|
|
31
50
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { forwardRef, type FormHTMLAttributes, type HTMLAttributes } from 'react';
|
|
7
7
|
import { cn } from '../../infrastructure/utils';
|
|
8
|
-
import type { BaseProps
|
|
8
|
+
import type { BaseProps } from '../../domain/types';
|
|
9
9
|
|
|
10
10
|
export interface FormProps extends FormHTMLAttributes<HTMLFormElement>, BaseProps {
|
|
11
11
|
onSubmit?: (e: React.FormEvent<HTMLFormElement>) => void;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { forwardRef, type HTMLAttributes } from 'react';
|
|
7
7
|
import { cn } from '../../infrastructure/utils';
|
|
8
|
-
import type { BaseProps
|
|
8
|
+
import type { BaseProps } from '../../domain/types';
|
|
9
9
|
|
|
10
10
|
export interface ListProps extends HTMLAttributes<HTMLUListElement>, BaseProps {
|
|
11
11
|
variant?: 'default' | 'bordered' | 'spaced';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { forwardRef, type HTMLAttributes } from 'react';
|
|
7
7
|
import { cn } from '../../infrastructure/utils';
|
|
8
|
-
import type { BaseProps
|
|
8
|
+
import type { BaseProps } from '../../domain/types';
|
|
9
9
|
|
|
10
10
|
export type MaxWidth = '4xl' | '7xl' | 'full';
|
|
11
11
|
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* @description Responsive wrapper with mobile/desktop optimizations
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { forwardRef, type HTMLAttributes } from 'react';
|
|
6
|
+
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
7
7
|
import { cn } from '../../infrastructure/utils';
|
|
8
8
|
import { useBreakpoint } from '../hooks/useMediaQuery';
|
|
9
|
-
import type { BaseProps
|
|
9
|
+
import type { BaseProps } from '../../domain/types';
|
|
10
10
|
|
|
11
11
|
export type ResponsiveSize = 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
12
12
|
|
|
13
13
|
export interface ResponsiveContainerProps
|
|
14
|
-
extends HTMLAttributes<HTMLDivElement>,
|
|
15
|
-
BaseProps
|
|
16
|
-
|
|
14
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'children'>,
|
|
15
|
+
BaseProps {
|
|
16
|
+
children?: ReactNode;
|
|
17
17
|
/**
|
|
18
18
|
* Maximum width on mobile devices
|
|
19
19
|
* @default 'full'
|
|
@@ -77,12 +77,6 @@ const maxWidthClasses: Record<ResponsiveSize, string> = {
|
|
|
77
77
|
full: 'max-w-full',
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
const sizeBreakpointMap: Record<string, ResponsiveSize> = {
|
|
81
|
-
sm: 'mobileMaxWidth',
|
|
82
|
-
md: 'tabletMaxWidth',
|
|
83
|
-
lg: 'desktopMaxWidth',
|
|
84
|
-
};
|
|
85
|
-
|
|
86
80
|
export const ResponsiveContainer = forwardRef<
|
|
87
81
|
HTMLDivElement,
|
|
88
82
|
ResponsiveContainerProps
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { forwardRef, type HTMLAttributes } from 'react';
|
|
7
7
|
import { cn } from '../../infrastructure/utils';
|
|
8
|
-
import type { BaseProps
|
|
8
|
+
import type { BaseProps } from '../../domain/types';
|
|
9
9
|
|
|
10
10
|
export interface SectionProps extends HTMLAttributes<HTMLElement>, BaseProps {
|
|
11
11
|
title?: string;
|