ds-learning 0.1.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 +36 -0
- package/package.json +54 -0
- package/src/components/Avatar/Avatar.mdx +16 -0
- package/src/components/Avatar/Avatar.stories.ts +30 -0
- package/src/components/Avatar/Avatar.tsx +21 -0
- package/src/components/Avatar/styles/avatar.styles.ts +15 -0
- package/src/components/Avatar/variants/AvatarIcon.tsx +9 -0
- package/src/components/Avatar/variants/AvatarImage.tsx +12 -0
- package/src/components/Box/Box.mdx +16 -0
- package/src/components/Box/Box.stories.ts +36 -0
- package/src/components/Box/Box.tsx +18 -0
- package/src/components/Box/styles/box.styles.ts +19 -0
- package/src/components/Button/Button.mdx +30 -0
- package/src/components/Button/Button.stories.ts +88 -0
- package/src/components/Button/Button.tsx +31 -0
- package/src/components/Divider/Divider.mdx +16 -0
- package/src/components/Divider/Divider.stories.ts +23 -0
- package/src/components/Divider/Divider.tsx +25 -0
- package/src/components/Divider/styles/divider.styles.ts +25 -0
- package/src/components/Dropdown/Dropdown.stories.ts +22 -0
- package/src/components/Dropdown/Dropdrown.tsx +88 -0
- package/src/components/Input/Input.mdx +28 -0
- package/src/components/Input/Input.stories.ts +70 -0
- package/src/components/Input/Input.tsx +29 -0
- package/src/components/Link/Link.mdx +17 -0
- package/src/components/Link/Link.stories.ts +35 -0
- package/src/components/Link/Link.tsx +14 -0
- package/src/components/Modal/Modal.mdx +10 -0
- package/src/components/Modal/Modal.stories.tsx +46 -0
- package/src/components/Modal/Modal.tsx +63 -0
- package/src/components/Molecules.mdx +3 -0
- package/src/components/Notice/ExclamationIcon.tsx +23 -0
- package/src/components/Notice/Notice.mdx +20 -0
- package/src/components/Notice/Notice.stories.ts +40 -0
- package/src/components/Notice/Notice.tsx +41 -0
- package/src/components/Notice/styles/notice.styles.ts +14 -0
- package/src/components/Switch/Switch.tsx +53 -0
- package/src/components/Switch/styles/switch.styles.ts +40 -0
- package/src/components/TextBlock/TextBlock.mdx +18 -0
- package/src/components/TextBlock/TextBlock.stories.ts +48 -0
- package/src/components/TextBlock/TextBlock.tsx +39 -0
- package/src/components/TextBlock/styles/styles.text-block.ts +10 -0
- package/src/components/Typography/Typography.mdx +18 -0
- package/src/components/Typography/Typography.stories.ts +35 -0
- package/src/components/Typography/Typography.tsx +28 -0
- package/src/components/Typography/styles/typography.styles.ts +22 -0
- package/src/components/index.ts +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
|
2
|
+
|
|
3
|
+
## Getting Started
|
|
4
|
+
|
|
5
|
+
First, run the development server:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run dev
|
|
9
|
+
# or
|
|
10
|
+
yarn dev
|
|
11
|
+
# or
|
|
12
|
+
pnpm dev
|
|
13
|
+
# or
|
|
14
|
+
bun dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
|
18
|
+
|
|
19
|
+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
|
20
|
+
|
|
21
|
+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
|
22
|
+
|
|
23
|
+
## Learn More
|
|
24
|
+
|
|
25
|
+
To learn more about Next.js, take a look at the following resources:
|
|
26
|
+
|
|
27
|
+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
|
28
|
+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
29
|
+
|
|
30
|
+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
|
31
|
+
|
|
32
|
+
## Deploy on Vercel
|
|
33
|
+
|
|
34
|
+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
|
35
|
+
|
|
36
|
+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ds-learning",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev",
|
|
7
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
8
|
+
"start": "next start",
|
|
9
|
+
"lint": "eslint",
|
|
10
|
+
"storybook": "storybook dev -p 6006",
|
|
11
|
+
"build-storybook": "storybook build"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@headlessui/react": "^2.2.9",
|
|
15
|
+
"@heroicons/react": "^2.2.0",
|
|
16
|
+
"chromatic": "^15.2.0",
|
|
17
|
+
"class-variance-authority": "^0.7.1",
|
|
18
|
+
"next": "16.1.6",
|
|
19
|
+
"react": "19.2.3",
|
|
20
|
+
"react-dom": "19.2.3"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@chromatic-com/storybook": "^5.0.1",
|
|
24
|
+
"@storybook/addon-a11y": "^10.2.8",
|
|
25
|
+
"@storybook/addon-docs": "^10.2.8",
|
|
26
|
+
"@storybook/addon-onboarding": "^10.2.8",
|
|
27
|
+
"@storybook/addon-vitest": "^10.2.8",
|
|
28
|
+
"@storybook/nextjs": "^10.2.8",
|
|
29
|
+
"@storybook/nextjs-vite": "^10.2.8",
|
|
30
|
+
"@tailwindcss/postcss": "^4",
|
|
31
|
+
"@types/node": "^20",
|
|
32
|
+
"@types/react": "^19",
|
|
33
|
+
"@types/react-dom": "^19",
|
|
34
|
+
"@vitest/browser-playwright": "^4.0.18",
|
|
35
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
36
|
+
"eslint": "^9",
|
|
37
|
+
"eslint-config-next": "16.1.6",
|
|
38
|
+
"eslint-plugin-storybook": "^10.2.8",
|
|
39
|
+
"playwright": "^1.58.2",
|
|
40
|
+
"storybook": "^10.2.8",
|
|
41
|
+
"tailwindcss": "^4",
|
|
42
|
+
"typescript": "^5",
|
|
43
|
+
"vite": "^7.3.1",
|
|
44
|
+
"vitest": "^4.0.18"
|
|
45
|
+
},
|
|
46
|
+
"description": "This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).",
|
|
47
|
+
"main": "components/index.ts",
|
|
48
|
+
"author": "",
|
|
49
|
+
"license": "ISC",
|
|
50
|
+
"files": [
|
|
51
|
+
"src/components/*",
|
|
52
|
+
"src/app/global.css"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as AvatarStories from './Avatar.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={AvatarStories} />
|
|
5
|
+
|
|
6
|
+
# Avatar
|
|
7
|
+
Este é um componente de avatar.
|
|
8
|
+
|
|
9
|
+
### Default
|
|
10
|
+
<Canvas of={AvatarStories.Default} />
|
|
11
|
+
### Com Imagem
|
|
12
|
+
<Canvas of={AvatarStories.WithImage} />
|
|
13
|
+
|
|
14
|
+
### Documentacao iterativa
|
|
15
|
+
<Canvas of={AvatarStories.Default} />
|
|
16
|
+
<Controls of={AvatarStories.Default} />
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/nextjs';
|
|
2
|
+
import { Avatar, AvatarProps } from './Avatar'
|
|
3
|
+
|
|
4
|
+
const meta: Meta<AvatarProps> = {
|
|
5
|
+
title: 'DesignSystem/Molecules/Avatar',
|
|
6
|
+
component: Avatar,
|
|
7
|
+
args: {},
|
|
8
|
+
argTypes: {
|
|
9
|
+
size: {
|
|
10
|
+
control: { type: 'select' },
|
|
11
|
+
options: ['xs', 'sm', 'md', 'lg']
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
|
|
18
|
+
export const Default: StoryObj<AvatarProps> = {
|
|
19
|
+
args: {
|
|
20
|
+
size: 'lg',
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const WithImage: StoryObj<AvatarProps> = {
|
|
25
|
+
args: {
|
|
26
|
+
size: 'lg',
|
|
27
|
+
srcImageIcon: 'https://placehold.co/400x400.png',
|
|
28
|
+
altImageIcon: 'Avatar Image',
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority";
|
|
2
|
+
import { avatarStyles } from "./styles/avatar.styles";
|
|
3
|
+
import { AvatarImage } from "./variants/AvatarImage";
|
|
4
|
+
import { AvatarIcon } from "./variants/AvatarIcon";
|
|
5
|
+
|
|
6
|
+
export type AvatarProps = VariantProps<typeof avatarStyles> & {
|
|
7
|
+
srcImageIcon?: string;
|
|
8
|
+
altImageIcon?: string;
|
|
9
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
10
|
+
|
|
11
|
+
const Avatar = ({ size = "md", srcImageIcon, altImageIcon }: AvatarProps) => {
|
|
12
|
+
const avatarContent = srcImageIcon ? <AvatarImage src={srcImageIcon} alt={altImageIcon} /> : <AvatarIcon />;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className={`${avatarStyles({ size: size })}`}>
|
|
16
|
+
{avatarContent}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { Avatar };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const avatarStyles = cva('rounded-full flex items-center justify-center bg-gray-100', {
|
|
4
|
+
variants: {
|
|
5
|
+
size: {
|
|
6
|
+
xs: 'w-6 h-6',
|
|
7
|
+
sm: 'w-8 h-8',
|
|
8
|
+
md: 'w-10 h-10',
|
|
9
|
+
lg: 'w-12 h-12',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
defaultVariants: {
|
|
13
|
+
size: 'md'
|
|
14
|
+
}
|
|
15
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Image from "next/image";
|
|
2
|
+
|
|
3
|
+
export type AvatarImageProps = {
|
|
4
|
+
src?: string;
|
|
5
|
+
alt?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const AvatarImage = ({ src = "", alt = "" }: AvatarImageProps) => {
|
|
9
|
+
return <Image width={100} height={100} src={src} alt={alt} className="rounded-full" />;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { AvatarImage };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as BoxStories from './Box.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={BoxStories} />
|
|
5
|
+
|
|
6
|
+
# Box
|
|
7
|
+
Este é um componente de caixa para armazenar textos e imagens
|
|
8
|
+
|
|
9
|
+
### Default
|
|
10
|
+
<Canvas of={BoxStories.Default} />
|
|
11
|
+
### Com background
|
|
12
|
+
<Canvas of={BoxStories.WithFilledBackground} />
|
|
13
|
+
|
|
14
|
+
### Documentacao iterativa
|
|
15
|
+
<Canvas of={BoxStories.Default} />
|
|
16
|
+
<Controls of={BoxStories.Default} />
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/nextjs"
|
|
2
|
+
import { BoxProps, Box } from "./Box"
|
|
3
|
+
|
|
4
|
+
const meta: Meta<BoxProps> = {
|
|
5
|
+
title: "Atoms/Box",
|
|
6
|
+
component: Box,
|
|
7
|
+
args: {
|
|
8
|
+
variant: 'default',
|
|
9
|
+
rounded: false,
|
|
10
|
+
children: "Aqui será um texto dentro da box."
|
|
11
|
+
},
|
|
12
|
+
argTypes: {
|
|
13
|
+
variant: {
|
|
14
|
+
control: { type: "select" },
|
|
15
|
+
options: ["default", "dark", "outlined"]
|
|
16
|
+
},
|
|
17
|
+
rounded: {
|
|
18
|
+
control: { type: "boolean" },
|
|
19
|
+
options: [true, false]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
|
|
26
|
+
export const Default: StoryObj<BoxProps> = {
|
|
27
|
+
args: {}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const WithFilledBackground: StoryObj<BoxProps> = {
|
|
31
|
+
args: {
|
|
32
|
+
variant: "dark",
|
|
33
|
+
rounded: true,
|
|
34
|
+
children: "This is a box with filled background"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority"
|
|
2
|
+
import { boxStyles } from "./styles/box.styles"
|
|
3
|
+
|
|
4
|
+
export type BoxProps = VariantProps<typeof boxStyles> & {} & React.HTMLAttributes<HTMLDivElement>
|
|
5
|
+
|
|
6
|
+
const Box = ({
|
|
7
|
+
rounded = false,
|
|
8
|
+
variant = "default",
|
|
9
|
+
children,
|
|
10
|
+
className,
|
|
11
|
+
...rest
|
|
12
|
+
}: BoxProps) => {
|
|
13
|
+
return (
|
|
14
|
+
<div {...rest} className={`${boxStyles({ variant: variant, rounded: rounded })}`}>{children}</div>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Box }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const boxStyles = cva('px-lg py-sm', {
|
|
4
|
+
variants: {
|
|
5
|
+
rounded: {
|
|
6
|
+
true: "rounded-md",
|
|
7
|
+
false: "none"
|
|
8
|
+
},
|
|
9
|
+
border: {
|
|
10
|
+
true: "border border-gray-100",
|
|
11
|
+
false: "none",
|
|
12
|
+
},
|
|
13
|
+
variant: {
|
|
14
|
+
default: 'bg-disabled text-text-primary',
|
|
15
|
+
dark: 'bg-dark text-red-500',
|
|
16
|
+
outlined: 'border border-gray-100 bg-transparent text-text-primary',
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as ButtonStories from './Button.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={ButtonStories} />
|
|
5
|
+
|
|
6
|
+
# Botao
|
|
7
|
+
Este é um componente de botao, usado para disparar açoes.
|
|
8
|
+
|
|
9
|
+
### Primário
|
|
10
|
+
<Canvas of={ButtonStories.Primary} />
|
|
11
|
+
### Desabilitado
|
|
12
|
+
<Canvas of={ButtonStories.Disabled} />
|
|
13
|
+
### Secundário
|
|
14
|
+
<Canvas of={ButtonStories.Secondary} />
|
|
15
|
+
### Secundário Desabilitado
|
|
16
|
+
<Canvas of={ButtonStories.SecondaryDisabled} />
|
|
17
|
+
### Terciário
|
|
18
|
+
<Canvas of={ButtonStories.Tertiary} />
|
|
19
|
+
### Terciário Desabilitado
|
|
20
|
+
<Canvas of={ButtonStories.TertiaryDisabled} />
|
|
21
|
+
### Tema Violeta
|
|
22
|
+
<Canvas of={ButtonStories.Violet} />
|
|
23
|
+
### Tema Violeta Secundario
|
|
24
|
+
<Canvas of={ButtonStories.VioletSecondary} />
|
|
25
|
+
### Tema Violeta Terciário
|
|
26
|
+
<Canvas of={ButtonStories.VioletTertiary} />
|
|
27
|
+
|
|
28
|
+
### Documentacao iterativa:
|
|
29
|
+
<Canvas of={ButtonStories.Primary} withToolbar />
|
|
30
|
+
<Controls of={ButtonStories.Primary} />
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/nextjs"
|
|
2
|
+
import { Button, ButtonProps } from "./Button"
|
|
3
|
+
|
|
4
|
+
const meta: Meta<ButtonProps> = {
|
|
5
|
+
title: 'DesignSystem/Molecules/Button',
|
|
6
|
+
component: Button,
|
|
7
|
+
argTypes: {
|
|
8
|
+
children: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
},
|
|
11
|
+
disabled: {
|
|
12
|
+
type: 'boolean',
|
|
13
|
+
},
|
|
14
|
+
onClick: {
|
|
15
|
+
action: 'cliked',
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default meta
|
|
22
|
+
|
|
23
|
+
export const Primary: StoryObj<ButtonProps> = {
|
|
24
|
+
args: {
|
|
25
|
+
children: 'Button',
|
|
26
|
+
className: '',
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Disabled: StoryObj<ButtonProps> = {
|
|
31
|
+
args: {
|
|
32
|
+
children: 'Button',
|
|
33
|
+
disabled: true,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const Secondary: StoryObj<ButtonProps> = {
|
|
38
|
+
args: {
|
|
39
|
+
children: 'Button',
|
|
40
|
+
variant: 'secondary',
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const SecondaryDisabled: StoryObj<ButtonProps> = {
|
|
45
|
+
args: {
|
|
46
|
+
children: 'Button',
|
|
47
|
+
variant: 'secondary',
|
|
48
|
+
disabled: true,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const Tertiary: StoryObj<ButtonProps> = {
|
|
53
|
+
args: {
|
|
54
|
+
children: 'Button',
|
|
55
|
+
variant: 'tertiary'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const TertiaryDisabled: StoryObj<ButtonProps> = {
|
|
60
|
+
args: {
|
|
61
|
+
children: 'Button',
|
|
62
|
+
variant: 'tertiary',
|
|
63
|
+
disabled: true,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const Violet: StoryObj<ButtonProps> = {
|
|
68
|
+
args: {
|
|
69
|
+
children: 'Button',
|
|
70
|
+
className: 'theme-violet',
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const VioletSecondary: StoryObj<ButtonProps> = {
|
|
75
|
+
args: {
|
|
76
|
+
children: 'Button',
|
|
77
|
+
variant: 'secondary',
|
|
78
|
+
className: 'theme-violet',
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const VioletTertiary: StoryObj<ButtonProps> = {
|
|
83
|
+
args: {
|
|
84
|
+
children: 'Button',
|
|
85
|
+
variant: 'tertiary',
|
|
86
|
+
className: 'theme-violet'
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ButtonProps = {
|
|
2
|
+
children: React.ReactNode,
|
|
3
|
+
variant?: 'primary' | 'secondary' | 'tertiary',
|
|
4
|
+
} & React.ButtonHTMLAttributes<HTMLButtonElement>
|
|
5
|
+
|
|
6
|
+
const Button = ({ variant = 'primary', children, className, disabled, ...rest }: ButtonProps) => {
|
|
7
|
+
|
|
8
|
+
function getVariantClasses(variant: ButtonProps['variant'], disabled: ButtonProps['disabled']) {
|
|
9
|
+
const whenDisabled = 'bg-disabled text-text-disabled';
|
|
10
|
+
switch (variant) {
|
|
11
|
+
case 'primary':
|
|
12
|
+
return disabled ? whenDisabled : 'bg-primary text-white';
|
|
13
|
+
case 'secondary':
|
|
14
|
+
return disabled ? whenDisabled : 'bg-quaternary text-secondary';
|
|
15
|
+
case 'tertiary':
|
|
16
|
+
return disabled ? 'bg-transarent text-text-disabled' : 'bg-transparent text-primary';
|
|
17
|
+
default:
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<button
|
|
24
|
+
// data-selected={isSelected}
|
|
25
|
+
className={`rounded-md px-lg py-2xs ${getVariantClasses(variant, disabled)} ${className}`}
|
|
26
|
+
{...rest}
|
|
27
|
+
>{children}</button>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { Button }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as DividerStories from './Divider.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={DividerStories} />
|
|
5
|
+
|
|
6
|
+
# Divider
|
|
7
|
+
Este é um componente de divisao, uasdo em alguns casos para manter a aplicacao moderna
|
|
8
|
+
|
|
9
|
+
### Default
|
|
10
|
+
<Canvas of={DividerStories.Default} />
|
|
11
|
+
### Com children
|
|
12
|
+
<Canvas of={DividerStories.WithChildren} />
|
|
13
|
+
|
|
14
|
+
### Documentacao iterativa
|
|
15
|
+
<Canvas of={DividerStories.Default} withToolbar />
|
|
16
|
+
<Controls of={DividerStories.Default} />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
+
import { Divider, DividerProps } from "./Divider";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<DividerProps> = {
|
|
5
|
+
title: 'Atoms/Divider',
|
|
6
|
+
component: Divider,
|
|
7
|
+
args: {}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
export const Default: StoryObj<DividerProps> = {
|
|
13
|
+
args: {
|
|
14
|
+
background: 'dark',
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const WithChildren: StoryObj<DividerProps> = {
|
|
19
|
+
args: {
|
|
20
|
+
background: 'dark',
|
|
21
|
+
children: 'Divider com children',
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority"
|
|
2
|
+
import { dividerStyles } from "./styles/divider.styles"
|
|
3
|
+
|
|
4
|
+
export type DividerProps = VariantProps<typeof dividerStyles> & {
|
|
5
|
+
width?: string
|
|
6
|
+
} & React.HTMLAttributes<HTMLDivElement>
|
|
7
|
+
|
|
8
|
+
const Divider = ({
|
|
9
|
+
width,
|
|
10
|
+
size,
|
|
11
|
+
children,
|
|
12
|
+
background,
|
|
13
|
+
}: DividerProps) => {
|
|
14
|
+
const hasChildren = !!children;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className={`flex items-center justify-center ${width}`}>
|
|
18
|
+
<div className={`${dividerStyles({ hasChildren: hasChildren, background: background, size: size })}`}></div>
|
|
19
|
+
{children && <div className="px-xs">{children}</div>}
|
|
20
|
+
<div className={`${dividerStyles({ hasChildren: hasChildren, background: background, size: size })}`}></div>
|
|
21
|
+
</div>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { Divider }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const dividerStyles = cva('', {
|
|
4
|
+
variants: {
|
|
5
|
+
hasChildren: {
|
|
6
|
+
true: 'w-1/3',
|
|
7
|
+
false: 'w-1/2'
|
|
8
|
+
},
|
|
9
|
+
background: {
|
|
10
|
+
dark: 'bg-dark',
|
|
11
|
+
light: 'bg-light',
|
|
12
|
+
},
|
|
13
|
+
size: {
|
|
14
|
+
xs: 'h-0.5',
|
|
15
|
+
sm: 'h-1',
|
|
16
|
+
md: 'h-1.5',
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
hasChildren: false,
|
|
21
|
+
background: 'light',
|
|
22
|
+
size: 'md'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/nextjs'
|
|
2
|
+
import { Dropdown, DropdownProps } from './Dropdrown'
|
|
3
|
+
|
|
4
|
+
const meta: Meta<DropdownProps> = {
|
|
5
|
+
title: 'Molecules/Dropdown',
|
|
6
|
+
component: Dropdown,
|
|
7
|
+
args: {}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default meta
|
|
11
|
+
|
|
12
|
+
export const Default: StoryObj<DropdownProps> = {
|
|
13
|
+
args: {
|
|
14
|
+
list: []
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const WithList: StoryObj<DropdownProps> = {
|
|
19
|
+
args: {
|
|
20
|
+
list: ['Option 1', 'Option 2', 'Option 3']
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Combobox,
|
|
3
|
+
ComboboxInput,
|
|
4
|
+
ComboboxOption,
|
|
5
|
+
ComboboxOptions,
|
|
6
|
+
} from "@headlessui/react";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
|
|
9
|
+
type Person = {
|
|
10
|
+
id: number;
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type DropdownProps = {
|
|
15
|
+
list: string[];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const Dropdown = ({ list, ...rest }: DropdownProps) => {
|
|
19
|
+
const [selectedPerson, setSelectedPerson] = useState<string | null>(list[0]);
|
|
20
|
+
const [query, setQuery] = useState("");
|
|
21
|
+
|
|
22
|
+
const filteredPeople =
|
|
23
|
+
query === ""
|
|
24
|
+
? list
|
|
25
|
+
: list.filter((listItem) => {
|
|
26
|
+
return listItem.toLowerCase().includes(query.toLowerCase());
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Combobox
|
|
31
|
+
value={selectedPerson}
|
|
32
|
+
onChange={setSelectedPerson}
|
|
33
|
+
onClose={() => setQuery("")}
|
|
34
|
+
>
|
|
35
|
+
<div className="relative">
|
|
36
|
+
<ComboboxInput
|
|
37
|
+
aria-label="Assignee"
|
|
38
|
+
className="
|
|
39
|
+
w-full rounded-lg border border-gray-300 bg-white
|
|
40
|
+
py-2.5 pl-3 pr-10 text-sm text-gray-900
|
|
41
|
+
shadow-sm
|
|
42
|
+
outline-none
|
|
43
|
+
transition
|
|
44
|
+
focus:border-blue-500
|
|
45
|
+
focus:ring-2 focus:ring-blue-500/20
|
|
46
|
+
"
|
|
47
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
48
|
+
onFocus={(event) => setQuery(event.target.value)}
|
|
49
|
+
/>
|
|
50
|
+
|
|
51
|
+
{/* Ícone opcional */}
|
|
52
|
+
<div className="pointer-events-none absolute inset-y-0 right-3 flex items-center text-gray-400">
|
|
53
|
+
▾
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<ComboboxOptions
|
|
58
|
+
anchor="bottom"
|
|
59
|
+
className="
|
|
60
|
+
absolute z-50 mt-2 max-h-60 w-full overflow-auto
|
|
61
|
+
rounded-lg border border-gray-200 bg-white
|
|
62
|
+
p-1 shadow-lg
|
|
63
|
+
transition
|
|
64
|
+
empty:invisible
|
|
65
|
+
"
|
|
66
|
+
>
|
|
67
|
+
{filteredPeople.map((listItem, index) => (
|
|
68
|
+
<ComboboxOption
|
|
69
|
+
key={index}
|
|
70
|
+
value={listItem}
|
|
71
|
+
className="
|
|
72
|
+
cursor-pointer select-none rounded-md px-3 py-2 text-sm
|
|
73
|
+
text-gray-700
|
|
74
|
+
transition
|
|
75
|
+
data-[focus]:bg-blue-500
|
|
76
|
+
data-[focus]:text-white
|
|
77
|
+
data-[selected]:font-medium
|
|
78
|
+
"
|
|
79
|
+
>
|
|
80
|
+
{listItem}
|
|
81
|
+
</ComboboxOption>
|
|
82
|
+
))}
|
|
83
|
+
</ComboboxOptions>
|
|
84
|
+
</Combobox>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export { Dropdown };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as InputStories from './Input.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={InputStories} />
|
|
5
|
+
|
|
6
|
+
# Input
|
|
7
|
+
Este é um componente de input, usado para receber dados do usuario.
|
|
8
|
+
|
|
9
|
+
### Primário
|
|
10
|
+
<Canvas of={InputStories.Primary} />
|
|
11
|
+
### Desabilitado
|
|
12
|
+
<Canvas of={InputStories.Disabled} />
|
|
13
|
+
### Input com Label
|
|
14
|
+
<Canvas of={InputStories.Label} />
|
|
15
|
+
### Input com Label Desabilitado
|
|
16
|
+
<Canvas of={InputStories.LabelDisabled} />
|
|
17
|
+
### Multilinhas
|
|
18
|
+
<Canvas of={InputStories.Multiline} />
|
|
19
|
+
### Multilinhas Desabilitado
|
|
20
|
+
<Canvas of={InputStories.MultilineDisabled} />
|
|
21
|
+
### Multilinhas com Label
|
|
22
|
+
<Canvas of={InputStories.LabelMultiline} />
|
|
23
|
+
### Multilinhas com Label Desabilitado
|
|
24
|
+
<Canvas of={InputStories.LabelMultilineDisabled} />
|
|
25
|
+
|
|
26
|
+
### Documentacao iterativa:
|
|
27
|
+
<Canvas of={InputStories.Primary} withToolbar />
|
|
28
|
+
<Controls of={InputStories.Primary} />
|