@fabio.caffarello/react-design-system 1.6.0 → 1.7.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/dist/index.cjs +29 -4
- package/dist/index.js +1866 -716
- package/dist/ui/atoms/Button/Button.d.ts +28 -5
- package/dist/ui/atoms/Button/Button.stories.d.ts +11 -3
- package/dist/ui/atoms/Checkbox/Checkbox.d.ts +24 -0
- package/dist/ui/atoms/Checkbox/Checkbox.stories.d.ts +10 -0
- package/dist/ui/atoms/Checkbox/Checkbox.test.d.ts +1 -0
- package/dist/ui/atoms/Collapsible/Collapsible.d.ts +29 -0
- package/dist/ui/atoms/Collapsible/Collapsible.stories.d.ts +9 -0
- package/dist/ui/atoms/Collapsible/Collapsible.test.d.ts +1 -0
- package/dist/ui/atoms/Input/Input.d.ts +28 -4
- package/dist/ui/atoms/Input/Input.stories.d.ts +8 -3
- package/dist/ui/atoms/Radio/Radio.d.ts +26 -0
- package/dist/ui/atoms/Radio/Radio.stories.d.ts +10 -0
- package/dist/ui/atoms/Radio/Radio.test.d.ts +1 -0
- package/dist/ui/atoms/SidebarItem/SidebarItem.d.ts +3 -1
- package/dist/ui/atoms/SidebarItem/SidebarItem.stories.d.ts +3 -0
- package/dist/ui/atoms/index.d.ts +7 -0
- package/dist/ui/hooks/useCollapsible.d.ts +27 -0
- package/dist/ui/index.d.ts +13 -0
- package/dist/ui/molecules/InputWithLabel/InputWithLabel.d.ts +4 -2
- package/dist/ui/molecules/SidebarGroup/SidebarGroup.d.ts +8 -1
- package/dist/ui/molecules/SidebarGroup/SidebarGroup.stories.d.ts +11 -0
- package/dist/ui/molecules/SidebarGroup/SidebarGroup.test.d.ts +1 -0
- package/dist/ui/providers/ThemeProvider.d.ts +34 -0
- package/dist/ui/tokens/breakpoints.d.ts +36 -0
- package/dist/ui/tokens/colors.d.ts +89 -0
- package/dist/ui/tokens/sidebar.d.ts +48 -0
- package/dist/ui/tokens/spacing.d.ts +53 -0
- package/dist/ui/tokens/themes/dark.d.ts +38 -0
- package/dist/ui/tokens/themes/light.d.ts +38 -0
- package/dist/ui/tokens/tokens.factory.d.ts +57 -0
- package/dist/ui/tokens/typography.d.ts +90 -0
- package/package.json +3 -2
- package/src/ui/atoms/Button/Button.stories.tsx +77 -7
- package/src/ui/atoms/Button/Button.tsx +176 -28
- package/src/ui/atoms/Checkbox/Checkbox.stories.tsx +61 -0
- package/src/ui/atoms/Checkbox/Checkbox.test.tsx +32 -0
- package/src/ui/atoms/Checkbox/Checkbox.tsx +103 -0
- package/src/ui/atoms/Collapsible/Collapsible.tsx +2 -2
- package/src/ui/atoms/Input/Input.stories.tsx +67 -6
- package/src/ui/atoms/Input/Input.tsx +117 -14
- package/src/ui/atoms/Radio/Radio.stories.tsx +72 -0
- package/src/ui/atoms/Radio/Radio.test.tsx +32 -0
- package/src/ui/atoms/Radio/Radio.tsx +104 -0
- package/src/ui/atoms/index.ts +7 -0
- package/src/ui/index.ts +14 -0
- package/src/ui/molecules/InputWithLabel/InputWithLabel.tsx +5 -4
- package/src/ui/molecules/SidebarGroup/SidebarGroup.tsx +30 -38
- package/src/ui/providers/ThemeProvider.tsx +105 -0
- package/src/ui/tokens/breakpoints.ts +71 -0
- package/src/ui/tokens/colors.ts +250 -0
- package/src/ui/tokens/sidebar.ts +9 -3
- package/src/ui/tokens/spacing.ts +127 -0
- package/src/ui/tokens/themes/dark.ts +18 -0
- package/src/ui/tokens/themes/light.ts +18 -0
- package/src/ui/tokens/tokens.factory.ts +117 -0
- package/src/ui/tokens/typography.ts +191 -0
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
import type { ButtonHTMLAttributes } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type ButtonVariant = 'primary' | 'regular' | 'secondary' | 'error' | 'outline' | 'ghost';
|
|
3
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
variant?: ButtonVariant;
|
|
6
|
+
size?: ButtonSize;
|
|
7
|
+
isLoading?: boolean;
|
|
8
|
+
leftIcon?: ReactNode;
|
|
9
|
+
rightIcon?: ReactNode;
|
|
4
10
|
}
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Button Component
|
|
13
|
+
*
|
|
14
|
+
* A styled button component with variants and sizes.
|
|
15
|
+
* Follows Atomic Design principles as an Atom component.
|
|
16
|
+
* Uses Builder Pattern for class construction.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <Button
|
|
21
|
+
* variant="primary"
|
|
22
|
+
* size="md"
|
|
23
|
+
* onClick={handleClick}
|
|
24
|
+
* >
|
|
25
|
+
* Click me
|
|
26
|
+
* </Button>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export default function Button({ variant, size, isLoading, leftIcon, rightIcon, className, disabled, children, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import Button from
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Button from './Button';
|
|
3
3
|
declare const meta: Meta<typeof Button>;
|
|
4
|
-
export declare const Primary: StoryObj<typeof Button>;
|
|
5
4
|
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Button>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const Secondary: Story;
|
|
8
|
+
export declare const Error: Story;
|
|
9
|
+
export declare const Outline: Story;
|
|
10
|
+
export declare const Ghost: Story;
|
|
11
|
+
export declare const Sizes: Story;
|
|
12
|
+
export declare const Loading: Story;
|
|
13
|
+
export declare const Disabled: Story;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
3
|
+
label?: ReactNode;
|
|
4
|
+
error?: boolean;
|
|
5
|
+
helperText?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Checkbox Component
|
|
9
|
+
*
|
|
10
|
+
* A styled checkbox input component.
|
|
11
|
+
* Follows Atomic Design principles as an Atom component.
|
|
12
|
+
* Uses Composite Pattern when combined with Label and ErrorMessage.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <Checkbox
|
|
17
|
+
* id="terms"
|
|
18
|
+
* label="I agree to the terms"
|
|
19
|
+
* checked={checked}
|
|
20
|
+
* onChange={handleChange}
|
|
21
|
+
* />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export default function Checkbox({ id, label, error, helperText, className, disabled, ...props }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Checkbox from './Checkbox';
|
|
3
|
+
declare const meta: Meta<typeof Checkbox>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Checkbox>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Checked: Story;
|
|
8
|
+
export declare const WithError: Story;
|
|
9
|
+
export declare const Disabled: Story;
|
|
10
|
+
export declare const WithoutLabel: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export interface CollapsibleProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
trigger: ReactNode;
|
|
5
|
+
defaultOpen?: boolean;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
onOpenChange?: (open: boolean) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
duration?: number;
|
|
10
|
+
storageKey?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Collapsible Component
|
|
14
|
+
*
|
|
15
|
+
* A generic, reusable collapsible component for any content.
|
|
16
|
+
* Supports both controlled and uncontrolled modes.
|
|
17
|
+
* Includes smooth animations and full ARIA support.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <Collapsible
|
|
22
|
+
* trigger={<button>Toggle</button>}
|
|
23
|
+
* defaultOpen={true}
|
|
24
|
+
* >
|
|
25
|
+
* <div>Collapsible content</div>
|
|
26
|
+
* </Collapsible>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export default function Collapsible({ children, trigger, defaultOpen, open, onOpenChange, disabled, duration, storageKey, className, ...props }: CollapsibleProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Collapsible from "./Collapsible";
|
|
3
|
+
declare const meta: Meta<typeof Collapsible>;
|
|
4
|
+
export declare const Default: StoryObj<typeof Collapsible>;
|
|
5
|
+
export declare const DefaultClosed: StoryObj<typeof Collapsible>;
|
|
6
|
+
export declare const Controlled: StoryObj<typeof Collapsible>;
|
|
7
|
+
export declare const WithStorage: StoryObj<typeof Collapsible>;
|
|
8
|
+
export declare const Disabled: StoryObj<typeof Collapsible>;
|
|
9
|
+
export default meta;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
3
|
+
label?: ReactNode;
|
|
4
|
+
error?: boolean;
|
|
5
|
+
helperText?: string;
|
|
6
|
+
size?: 'sm' | 'md' | 'lg';
|
|
7
|
+
variant?: 'default' | 'outlined' | 'filled';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Input Component
|
|
11
|
+
*
|
|
12
|
+
* A styled text input component with label and error support.
|
|
13
|
+
* Follows Atomic Design principles as an Atom component.
|
|
14
|
+
* Uses Composite Pattern when combined with Label and ErrorMessage.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <Input
|
|
19
|
+
* id="email"
|
|
20
|
+
* label="Email"
|
|
21
|
+
* type="email"
|
|
22
|
+
* placeholder="Enter your email"
|
|
23
|
+
* error={hasError}
|
|
24
|
+
* helperText={errorMessage}
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export default function Input({ id, label, error, helperText, size, variant, className, disabled, ...props }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import Input from
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Input from './Input';
|
|
3
3
|
declare const meta: Meta<typeof Input>;
|
|
4
|
-
export declare const Primary: StoryObj<typeof Input>;
|
|
5
4
|
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Input>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithError: Story;
|
|
8
|
+
export declare const Sizes: Story;
|
|
9
|
+
export declare const Variants: Story;
|
|
10
|
+
export declare const Disabled: Story;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
3
|
+
label?: ReactNode;
|
|
4
|
+
error?: boolean;
|
|
5
|
+
helperText?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Radio Component
|
|
9
|
+
*
|
|
10
|
+
* A styled radio input component.
|
|
11
|
+
* Follows Atomic Design principles as an Atom component.
|
|
12
|
+
* Uses Composite Pattern when combined with Label and ErrorMessage.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <Radio
|
|
17
|
+
* id="option1"
|
|
18
|
+
* name="options"
|
|
19
|
+
* label="Option 1"
|
|
20
|
+
* value="1"
|
|
21
|
+
* checked={selected === "1"}
|
|
22
|
+
* onChange={handleChange}
|
|
23
|
+
* />
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export default function Radio({ id, label, error, helperText, className, disabled, ...props }: RadioProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Radio from './Radio';
|
|
3
|
+
declare const meta: Meta<typeof Radio>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Radio>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Checked: Story;
|
|
8
|
+
export declare const WithError: Story;
|
|
9
|
+
export declare const Disabled: Story;
|
|
10
|
+
export declare const RadioGroup: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,6 +3,8 @@ export interface SidebarItemProps extends Omit<AnchorHTMLAttributes<HTMLAnchorEl
|
|
|
3
3
|
href: string;
|
|
4
4
|
isActive?: boolean;
|
|
5
5
|
icon?: ReactNode;
|
|
6
|
+
nested?: boolean | number;
|
|
7
|
+
iconSize?: 'sm' | 'md' | 'lg';
|
|
6
8
|
children: ReactNode;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
@@ -18,4 +20,4 @@ export interface SidebarItemProps extends Omit<AnchorHTMLAttributes<HTMLAnchorEl
|
|
|
18
20
|
* </SidebarItem>
|
|
19
21
|
* ```
|
|
20
22
|
*/
|
|
21
|
-
export default function SidebarItem({ href, isActive, icon, children, className, ...props }: SidebarItemProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export default function SidebarItem({ href, isActive, icon, nested, iconSize, children, className, ...props }: SidebarItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,4 +4,7 @@ declare const meta: Meta<typeof SidebarItem>;
|
|
|
4
4
|
export declare const Default: StoryObj<typeof SidebarItem>;
|
|
5
5
|
export declare const Active: StoryObj<typeof SidebarItem>;
|
|
6
6
|
export declare const WithIcon: StoryObj<typeof SidebarItem>;
|
|
7
|
+
export declare const Nested: StoryObj<typeof SidebarItem>;
|
|
8
|
+
export declare const NestedLevel2: StoryObj<typeof SidebarItem>;
|
|
9
|
+
export declare const DifferentIconSizes: StoryObj<typeof SidebarItem>;
|
|
7
10
|
export default meta;
|
package/dist/ui/atoms/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as Info } from "./Info/Info";
|
|
2
2
|
export { default as Text } from "./Text/Text";
|
|
3
3
|
export { default as Input } from "./Input/Input";
|
|
4
|
+
export type { InputProps } from "./Input/Input";
|
|
4
5
|
export { default as Button } from "./Button/Button";
|
|
5
6
|
export { default as BoxWrapper } from "./BoxWrapper/BoxWrapper";
|
|
6
7
|
export { default as Badge } from "./Badge/Badge";
|
|
@@ -15,3 +16,9 @@ export { default as Skeleton } from "./Skeleton/Skeleton";
|
|
|
15
16
|
export type { SkeletonProps } from "./Skeleton/Skeleton";
|
|
16
17
|
export { default as SidebarItem } from "./SidebarItem/SidebarItem";
|
|
17
18
|
export type { SidebarItemProps } from "./SidebarItem/SidebarItem";
|
|
19
|
+
export { default as Collapsible } from "./Collapsible/Collapsible";
|
|
20
|
+
export type { CollapsibleProps } from "./Collapsible/Collapsible";
|
|
21
|
+
export { default as Checkbox } from "./Checkbox/Checkbox";
|
|
22
|
+
export type { CheckboxProps } from "./Checkbox/Checkbox";
|
|
23
|
+
export { default as Radio } from "./Radio/Radio";
|
|
24
|
+
export type { RadioProps } from "./Radio/Radio";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface UseCollapsibleOptions {
|
|
2
|
+
defaultOpen?: boolean;
|
|
3
|
+
open?: boolean;
|
|
4
|
+
onOpenChange?: (open: boolean) => void;
|
|
5
|
+
storageKey?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UseCollapsibleReturn {
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
toggle: () => void;
|
|
10
|
+
setOpen: (open: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* useCollapsible Hook
|
|
14
|
+
*
|
|
15
|
+
* Reusable hook for collapsible component logic.
|
|
16
|
+
* Supports both controlled and uncontrolled modes.
|
|
17
|
+
* Optional localStorage persistence.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const { isOpen, toggle } = useCollapsible({
|
|
22
|
+
* defaultOpen: true,
|
|
23
|
+
* storageKey: 'my-collapsible-state'
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useCollapsible({ defaultOpen, open, onOpenChange, storageKey, }: UseCollapsibleOptions): UseCollapsibleReturn;
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
export * from "./atoms";
|
|
2
2
|
export * from "./molecules";
|
|
3
3
|
export * from "./organisms";
|
|
4
|
+
export * from "./tokens/sidebar";
|
|
5
|
+
export * from "./tokens/spacing";
|
|
6
|
+
export * from "./tokens/typography";
|
|
7
|
+
export * from "./tokens/colors";
|
|
8
|
+
export * from "./tokens/breakpoints";
|
|
9
|
+
export * from "./tokens/tokens.factory";
|
|
10
|
+
export * from "./tokens/themes/light";
|
|
11
|
+
export * from "./tokens/themes/dark";
|
|
12
|
+
export * from "./providers/ThemeProvider";
|
|
13
|
+
export { getSpacingClass, getSpacing } from "./tokens/spacing";
|
|
14
|
+
export { getTypographyClasses, getTypography } from "./tokens/typography";
|
|
15
|
+
export { getColorClass, getColor } from "./tokens/colors";
|
|
16
|
+
export { getBreakpoint, getMediaQuery } from "./tokens/breakpoints";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { HTMLProps } from "react";
|
|
2
|
-
|
|
2
|
+
import { type InputProps } from "../../atoms";
|
|
3
|
+
interface Props extends Omit<HTMLProps<HTMLInputElement>, 'size'> {
|
|
3
4
|
label: string;
|
|
5
|
+
size?: InputProps['size'];
|
|
4
6
|
}
|
|
5
|
-
export default function InputWithLabel({ label, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default function InputWithLabel({ label, size, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
6
8
|
export {};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
2
|
export interface SidebarGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
title?: string;
|
|
4
|
+
titleIcon?: ReactNode;
|
|
4
5
|
children: ReactNode;
|
|
6
|
+
collapsible?: boolean;
|
|
7
|
+
defaultCollapsed?: boolean;
|
|
8
|
+
collapsed?: boolean;
|
|
9
|
+
onCollapseChange?: (collapsed: boolean) => void;
|
|
10
|
+
storageKey?: string;
|
|
11
|
+
showChevron?: boolean;
|
|
5
12
|
}
|
|
6
13
|
/**
|
|
7
14
|
* SidebarGroup Component
|
|
@@ -17,4 +24,4 @@ export interface SidebarGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
17
24
|
* </SidebarGroup>
|
|
18
25
|
* ```
|
|
19
26
|
*/
|
|
20
|
-
export default function SidebarGroup({ title, children, className, ...props }: SidebarGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export default function SidebarGroup({ title, titleIcon, children, collapsible, defaultCollapsed, collapsed, onCollapseChange, storageKey, showChevron, className, ...props }: SidebarGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import SidebarGroup from "./SidebarGroup";
|
|
3
|
+
declare const meta: Meta<typeof SidebarGroup>;
|
|
4
|
+
export declare const Default: StoryObj<typeof SidebarGroup>;
|
|
5
|
+
export declare const WithoutTitle: StoryObj<typeof SidebarGroup>;
|
|
6
|
+
export declare const Collapsible: StoryObj<typeof SidebarGroup>;
|
|
7
|
+
export declare const CollapsibleDefaultCollapsed: StoryObj<typeof SidebarGroup>;
|
|
8
|
+
export declare const ControlledCollapsible: StoryObj<typeof SidebarGroup>;
|
|
9
|
+
export declare const WithNestedItems: StoryObj<typeof SidebarGroup>;
|
|
10
|
+
export declare const MultipleGroups: StoryObj<typeof SidebarGroup>;
|
|
11
|
+
export default meta;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ColorRole, type SemanticColor } from '../tokens/colors';
|
|
3
|
+
import type { ThemeMode } from '../tokens/tokens.factory';
|
|
4
|
+
export interface ThemeContextValue {
|
|
5
|
+
theme: ThemeMode;
|
|
6
|
+
toggleTheme: () => void;
|
|
7
|
+
setTheme: (theme: ThemeMode) => void;
|
|
8
|
+
colors: Record<ColorRole, SemanticColor>;
|
|
9
|
+
isDark: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ThemeProviderProps {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
defaultTheme?: ThemeMode;
|
|
14
|
+
storageKey?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ThemeProvider Component
|
|
18
|
+
*
|
|
19
|
+
* Provides theme context to the application.
|
|
20
|
+
* Uses Strategy Pattern for different theme strategies (light, dark).
|
|
21
|
+
* Uses Observer Pattern to notify components about theme changes.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <ThemeProvider defaultTheme="light">
|
|
26
|
+
* <App />
|
|
27
|
+
* </ThemeProvider>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function ThemeProvider({ children, defaultTheme, storageKey, }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
/**
|
|
32
|
+
* Hook to use theme context
|
|
33
|
+
*/
|
|
34
|
+
export declare function useTheme(): ThemeContextValue;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Breakpoint Tokens
|
|
3
|
+
*
|
|
4
|
+
* Responsive breakpoints for consistent media queries.
|
|
5
|
+
* Uses Factory Pattern for type-safe breakpoint creation.
|
|
6
|
+
*/
|
|
7
|
+
export type BreakpointName = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
8
|
+
export interface BreakpointToken {
|
|
9
|
+
name: BreakpointName;
|
|
10
|
+
minWidth: number;
|
|
11
|
+
px: string;
|
|
12
|
+
rem: string;
|
|
13
|
+
tailwind: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Breakpoint Token Factory
|
|
17
|
+
* Creates breakpoint tokens with consistent values
|
|
18
|
+
*/
|
|
19
|
+
export declare class BreakpointTokenFactory {
|
|
20
|
+
/**
|
|
21
|
+
* Create breakpoint token
|
|
22
|
+
*/
|
|
23
|
+
static create(name: BreakpointName): BreakpointToken;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Pre-defined breakpoint tokens
|
|
27
|
+
*/
|
|
28
|
+
export declare const BREAKPOINT_TOKENS: Record<BreakpointName, BreakpointToken>;
|
|
29
|
+
/**
|
|
30
|
+
* Helper function to get breakpoint token
|
|
31
|
+
*/
|
|
32
|
+
export declare function getBreakpoint(name: BreakpointName): BreakpointToken;
|
|
33
|
+
/**
|
|
34
|
+
* Helper function to create media query string
|
|
35
|
+
*/
|
|
36
|
+
export declare function getMediaQuery(name: BreakpointName, direction?: 'min' | 'max'): string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color Tokens
|
|
3
|
+
*
|
|
4
|
+
* Semantic color system for consistent theming.
|
|
5
|
+
* Uses Strategy Pattern for different color strategies (light, dark, custom).
|
|
6
|
+
*/
|
|
7
|
+
export type ColorRole = 'primary' | 'secondary' | 'success' | 'warning' | 'error' | 'info' | 'neutral';
|
|
8
|
+
export type ColorShade = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
9
|
+
export interface ColorToken {
|
|
10
|
+
hex: string;
|
|
11
|
+
rgb: string;
|
|
12
|
+
tailwind: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SemanticColor {
|
|
15
|
+
light: ColorToken;
|
|
16
|
+
DEFAULT: ColorToken;
|
|
17
|
+
dark: ColorToken;
|
|
18
|
+
contrast: ColorToken;
|
|
19
|
+
}
|
|
20
|
+
export interface ColorPalette {
|
|
21
|
+
[key: number]: ColorToken;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Color Strategy Interface
|
|
25
|
+
* Strategy Pattern for different color generation strategies
|
|
26
|
+
*/
|
|
27
|
+
export interface ColorStrategy {
|
|
28
|
+
generatePrimary(): SemanticColor;
|
|
29
|
+
generateSecondary(): SemanticColor;
|
|
30
|
+
generateSuccess(): SemanticColor;
|
|
31
|
+
generateWarning(): SemanticColor;
|
|
32
|
+
generateError(): SemanticColor;
|
|
33
|
+
generateInfo(): SemanticColor;
|
|
34
|
+
generateNeutral(): SemanticColor;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Light Theme Color Strategy
|
|
38
|
+
*/
|
|
39
|
+
export declare class LightColorStrategy implements ColorStrategy {
|
|
40
|
+
generatePrimary(): SemanticColor;
|
|
41
|
+
generateSecondary(): SemanticColor;
|
|
42
|
+
generateSuccess(): SemanticColor;
|
|
43
|
+
generateWarning(): SemanticColor;
|
|
44
|
+
generateError(): SemanticColor;
|
|
45
|
+
generateInfo(): SemanticColor;
|
|
46
|
+
generateNeutral(): SemanticColor;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Dark Theme Color Strategy
|
|
50
|
+
*/
|
|
51
|
+
export declare class DarkColorStrategy implements ColorStrategy {
|
|
52
|
+
generatePrimary(): SemanticColor;
|
|
53
|
+
generateSecondary(): SemanticColor;
|
|
54
|
+
generateSuccess(): SemanticColor;
|
|
55
|
+
generateWarning(): SemanticColor;
|
|
56
|
+
generateError(): SemanticColor;
|
|
57
|
+
generateInfo(): SemanticColor;
|
|
58
|
+
generateNeutral(): SemanticColor;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Color Token Factory
|
|
62
|
+
* Uses Strategy Pattern to generate colors based on theme
|
|
63
|
+
*/
|
|
64
|
+
export declare class ColorTokenFactory {
|
|
65
|
+
private strategy;
|
|
66
|
+
constructor(strategy: ColorStrategy);
|
|
67
|
+
/**
|
|
68
|
+
* Set color strategy
|
|
69
|
+
*/
|
|
70
|
+
setStrategy(strategy: ColorStrategy): void;
|
|
71
|
+
/**
|
|
72
|
+
* Generate semantic color palette
|
|
73
|
+
*/
|
|
74
|
+
generatePalette(): Record<ColorRole, SemanticColor>;
|
|
75
|
+
}
|
|
76
|
+
export declare const COLOR_TOKENS_LIGHT: Record<ColorRole, SemanticColor>;
|
|
77
|
+
export declare const COLOR_TOKENS_DARK: Record<ColorRole, SemanticColor>;
|
|
78
|
+
/**
|
|
79
|
+
* Default color tokens (light theme)
|
|
80
|
+
*/
|
|
81
|
+
export declare const COLOR_TOKENS: Record<ColorRole, SemanticColor>;
|
|
82
|
+
/**
|
|
83
|
+
* Helper function to get color token
|
|
84
|
+
*/
|
|
85
|
+
export declare function getColor(role: ColorRole, shade?: 'light' | 'DEFAULT' | 'dark'): ColorToken;
|
|
86
|
+
/**
|
|
87
|
+
* Helper function to get color as Tailwind class
|
|
88
|
+
*/
|
|
89
|
+
export declare function getColorClass(role: ColorRole, shade?: 'light' | 'DEFAULT' | 'dark', type?: 'text' | 'bg' | 'border'): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sidebar Design Tokens
|
|
3
|
+
*
|
|
4
|
+
* Centralized tokens for sidebar components to ensure consistency
|
|
5
|
+
* and ease of maintenance. All spacing, sizing, and color values
|
|
6
|
+
* should reference these tokens.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SIDEBAR_TOKENS: {
|
|
9
|
+
readonly icon: {
|
|
10
|
+
readonly sm: "h-4 w-4";
|
|
11
|
+
readonly md: "h-5 w-5";
|
|
12
|
+
readonly lg: "h-6 w-6";
|
|
13
|
+
};
|
|
14
|
+
readonly text: {
|
|
15
|
+
readonly xs: "text-xs";
|
|
16
|
+
readonly sm: "text-sm";
|
|
17
|
+
readonly base: "text-base";
|
|
18
|
+
};
|
|
19
|
+
readonly spacing: {
|
|
20
|
+
readonly itemPaddingX: "px-4";
|
|
21
|
+
readonly itemPaddingY: "py-2";
|
|
22
|
+
readonly nestedIndent: "pl-6";
|
|
23
|
+
readonly nestedIndentLevel2: "pl-10";
|
|
24
|
+
readonly nestedIndentLevel3: "pl-14";
|
|
25
|
+
readonly groupTitlePadding: "px-4 py-2";
|
|
26
|
+
readonly iconMargin: "mr-3";
|
|
27
|
+
};
|
|
28
|
+
readonly colors: {
|
|
29
|
+
readonly active: {
|
|
30
|
+
readonly bg: "bg-indigo-50";
|
|
31
|
+
readonly text: "text-indigo-700";
|
|
32
|
+
readonly border: "border-indigo-600";
|
|
33
|
+
};
|
|
34
|
+
readonly inactive: {
|
|
35
|
+
readonly text: "text-gray-700";
|
|
36
|
+
readonly hover: "hover:bg-gray-100 hover:text-gray-900";
|
|
37
|
+
};
|
|
38
|
+
readonly groupTitle: "text-gray-500";
|
|
39
|
+
};
|
|
40
|
+
readonly chevron: {
|
|
41
|
+
readonly size: "h-3 w-3";
|
|
42
|
+
readonly color: "text-gray-400";
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Helper function to get nested indent class based on level
|
|
47
|
+
*/
|
|
48
|
+
export declare function getNestedIndentClass(level: number): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spacing Tokens
|
|
3
|
+
*
|
|
4
|
+
* Centralized spacing scale based on 4px base unit.
|
|
5
|
+
* Uses Factory Pattern for type-safe token creation.
|
|
6
|
+
*/
|
|
7
|
+
export type SpacingScale = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 64 | 80 | 96;
|
|
8
|
+
export interface SpacingToken {
|
|
9
|
+
value: number;
|
|
10
|
+
rem: string;
|
|
11
|
+
px: string;
|
|
12
|
+
tailwind: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Spacing Token Factory
|
|
16
|
+
* Creates spacing tokens with consistent naming and values
|
|
17
|
+
*/
|
|
18
|
+
export declare class SpacingTokenFactory {
|
|
19
|
+
private static readonly BASE_UNIT;
|
|
20
|
+
/**
|
|
21
|
+
* Create a spacing token from scale value
|
|
22
|
+
*/
|
|
23
|
+
static create(scale: SpacingScale): SpacingToken;
|
|
24
|
+
/**
|
|
25
|
+
* Get Tailwind class for spacing value
|
|
26
|
+
*/
|
|
27
|
+
private static getTailwindClass;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Pre-defined spacing tokens
|
|
31
|
+
*/
|
|
32
|
+
export declare const SPACING_TOKENS: {
|
|
33
|
+
readonly none: SpacingToken;
|
|
34
|
+
readonly xs: SpacingToken;
|
|
35
|
+
readonly sm: SpacingToken;
|
|
36
|
+
readonly md: SpacingToken;
|
|
37
|
+
readonly base: SpacingToken;
|
|
38
|
+
readonly lg: SpacingToken;
|
|
39
|
+
readonly xl: SpacingToken;
|
|
40
|
+
readonly '2xl': SpacingToken;
|
|
41
|
+
readonly '3xl': SpacingToken;
|
|
42
|
+
readonly '4xl': SpacingToken;
|
|
43
|
+
readonly '5xl': SpacingToken;
|
|
44
|
+
readonly '6xl': SpacingToken;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Helper function to get spacing value
|
|
48
|
+
*/
|
|
49
|
+
export declare function getSpacing(scale: keyof typeof SPACING_TOKENS): SpacingToken;
|
|
50
|
+
/**
|
|
51
|
+
* Helper function to get spacing as Tailwind class
|
|
52
|
+
*/
|
|
53
|
+
export declare function getSpacingClass(scale: keyof typeof SPACING_TOKENS, direction?: 'p' | 'm' | 'px' | 'mx' | 'py' | 'my' | 'pt' | 'mt' | 'pr' | 'mr' | 'pb' | 'mb' | 'pl' | 'ml'): string;
|