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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/nextjs"
|
|
2
|
+
import { Input, InputProps } from "./Input"
|
|
3
|
+
|
|
4
|
+
const meta: Meta<InputProps> = {
|
|
5
|
+
title: 'Molecules/Input',
|
|
6
|
+
component: Input,
|
|
7
|
+
argTypes: {},
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default meta
|
|
11
|
+
|
|
12
|
+
export const Primary: StoryObj<InputProps> = {
|
|
13
|
+
args: {
|
|
14
|
+
value: 'Input',
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Disabled: StoryObj<InputProps> = {
|
|
19
|
+
args: {
|
|
20
|
+
value: 'Input',
|
|
21
|
+
disabled: true,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Multiline: StoryObj<InputProps> = {
|
|
26
|
+
args: {
|
|
27
|
+
value: 'Input',
|
|
28
|
+
multiline: true,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const MultilineDisabled: StoryObj<InputProps> = {
|
|
33
|
+
args: {
|
|
34
|
+
value: 'Input',
|
|
35
|
+
multiline: true,
|
|
36
|
+
disabled: true,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Label: StoryObj<InputProps> = {
|
|
41
|
+
args: {
|
|
42
|
+
value: 'Input',
|
|
43
|
+
label: 'Label',
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const LabelDisabled: StoryObj<InputProps> = {
|
|
48
|
+
args: {
|
|
49
|
+
value: 'Input',
|
|
50
|
+
label: 'Label',
|
|
51
|
+
disabled: true,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const LabelMultiline: StoryObj<InputProps> = {
|
|
56
|
+
args: {
|
|
57
|
+
value: 'Input',
|
|
58
|
+
label: 'Label',
|
|
59
|
+
multiline: true,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const LabelMultilineDisabled: StoryObj<InputProps> = {
|
|
64
|
+
args: {
|
|
65
|
+
value: 'Input',
|
|
66
|
+
label: 'Label',
|
|
67
|
+
multiline: true,
|
|
68
|
+
disabled: true,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type InputProps = {
|
|
2
|
+
label?: string
|
|
3
|
+
multiline?: boolean
|
|
4
|
+
} & (
|
|
5
|
+
React.InputHTMLAttributes<HTMLInputElement> |
|
|
6
|
+
React.TextareaHTMLAttributes<HTMLTextAreaElement>
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
const InputOrTextarea = (props: InputProps) => {
|
|
10
|
+
if (props.multiline) {
|
|
11
|
+
return <textarea {...props as React.TextareaHTMLAttributes<HTMLTextAreaElement>} />
|
|
12
|
+
}
|
|
13
|
+
return <input {...props as React.InputHTMLAttributes<HTMLInputElement>} />
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const Input = ({ className, label, ...rest }: InputProps) => {
|
|
17
|
+
return (
|
|
18
|
+
<div className="relative">
|
|
19
|
+
{label && <label className="absolute pt-4xs pl-xs text-xs">{label}</label>}
|
|
20
|
+
<InputOrTextarea
|
|
21
|
+
className={`bg-dark text-gray disabled:bg-disabled disabled:border-2 disabled:border-disabled rounded-md p-xs
|
|
22
|
+
${label && 'pt-sm'}
|
|
23
|
+
${className}`}
|
|
24
|
+
{...rest} />
|
|
25
|
+
</div>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { Input }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as LinkStories from './Link.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={LinkStories} />
|
|
5
|
+
|
|
6
|
+
# Link
|
|
7
|
+
Este é um componente de link, usado para navegar entre páginas ou seções.
|
|
8
|
+
|
|
9
|
+
### Primário
|
|
10
|
+
<Canvas of={LinkStories.Primary} />
|
|
11
|
+
### Desabilitado
|
|
12
|
+
<Canvas of={LinkStories.Disabled} />
|
|
13
|
+
### Tema Violeta
|
|
14
|
+
<Canvas of={LinkStories.Violet} />
|
|
15
|
+
|
|
16
|
+
### Documentacao iterativa:
|
|
17
|
+
<Controls of={LinkStories.Primary} />
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
+
import { Link, LinkProps } from "./Link";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<LinkProps> = {
|
|
5
|
+
title: 'Molecules/Link',
|
|
6
|
+
component: Link,
|
|
7
|
+
args: {
|
|
8
|
+
className: '',
|
|
9
|
+
},
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
export const Primary: StoryObj<LinkProps> = {
|
|
15
|
+
args: {
|
|
16
|
+
children: 'Link',
|
|
17
|
+
href: '/'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Disabled: StoryObj<LinkProps> = {
|
|
22
|
+
args: {
|
|
23
|
+
children: 'Link',
|
|
24
|
+
href: '/',
|
|
25
|
+
disabled: true
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Violet: StoryObj<LinkProps> = {
|
|
30
|
+
args: {
|
|
31
|
+
children: 'Link',
|
|
32
|
+
href: '/',
|
|
33
|
+
className: 'theme-violet'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type LinkProps = {
|
|
2
|
+
children: React.ReactNode,
|
|
3
|
+
disabled?: boolean,
|
|
4
|
+
} & React.AnchorHTMLAttributes<HTMLAnchorElement>
|
|
5
|
+
|
|
6
|
+
const Link = ({ children, href, disabled, className,...rest }: LinkProps) => {
|
|
7
|
+
return <a
|
|
8
|
+
href={disabled ? undefined : href}
|
|
9
|
+
aria-disabled={disabled}
|
|
10
|
+
className={`text-primary aria-disabled:text-text-disabled ${className}`}
|
|
11
|
+
{...rest}>{children}</a>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { Link }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { Modal, ModalProps } from "./Modal"
|
|
3
|
+
import { Button } from '../Button/Button'
|
|
4
|
+
import { Typography } from '../Typography/Typography'
|
|
5
|
+
import { Meta, StoryObj } from '@storybook/nextjs'
|
|
6
|
+
|
|
7
|
+
const ModalStoryComponent = (args: ModalProps) => {
|
|
8
|
+
const [isOpen, setIsOpen] = useState(args.isOpen)
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
<Button onClick={() => setIsOpen(true)}>Abrir Modal</Button>
|
|
13
|
+
<Modal {...args} isOpen={isOpen} onClose={() => setIsOpen(false)} title='Modal Componente'>
|
|
14
|
+
<Typography>
|
|
15
|
+
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English
|
|
16
|
+
</Typography>
|
|
17
|
+
<Typography>
|
|
18
|
+
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English
|
|
19
|
+
</Typography>
|
|
20
|
+
<div className='w-full flex flex-col items-center space-y-2'>
|
|
21
|
+
<Button onClick={() => setIsOpen(false)} variant='primary' className='w-full'>Primary</Button>
|
|
22
|
+
<Button onClick={() => setIsOpen(false)} variant='secondary'className='w-full'>Secondary</Button>
|
|
23
|
+
</div>
|
|
24
|
+
</Modal>
|
|
25
|
+
</>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { ModalStoryComponent }
|
|
30
|
+
|
|
31
|
+
const meta: Meta<ModalProps> = {
|
|
32
|
+
title: 'Molecules/Modal',
|
|
33
|
+
component: Modal,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default meta;
|
|
37
|
+
|
|
38
|
+
export const ModalInfo: StoryObj<ModalProps> = {
|
|
39
|
+
args: {
|
|
40
|
+
isOpen: false,
|
|
41
|
+
title: 'Modal Info'
|
|
42
|
+
},
|
|
43
|
+
render: (args: ModalProps) => {
|
|
44
|
+
return <ModalStoryComponent {...args} />
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Dialog, Transition, DialogProps } from "@headlessui/react"
|
|
2
|
+
import { XMarkIcon } from "@heroicons/react/24/outline"
|
|
3
|
+
import React, { Fragment } from "react"
|
|
4
|
+
|
|
5
|
+
export type ModalProps = {
|
|
6
|
+
children?: React.ReactNode
|
|
7
|
+
isOpen: boolean
|
|
8
|
+
onClose: () => void
|
|
9
|
+
title?: string
|
|
10
|
+
} & DialogProps & React.HTMLAttributes<HTMLDivElement>
|
|
11
|
+
|
|
12
|
+
const Modal = ({
|
|
13
|
+
children,
|
|
14
|
+
isOpen,
|
|
15
|
+
onClose,
|
|
16
|
+
title
|
|
17
|
+
}: ModalProps) => {
|
|
18
|
+
return (
|
|
19
|
+
<Transition appear show={isOpen} as={Fragment}>
|
|
20
|
+
<Dialog as="div" className="relative z-10" onClose={onClose}>
|
|
21
|
+
<Transition.Child
|
|
22
|
+
as={Fragment}
|
|
23
|
+
enter="ease-out duration-300"
|
|
24
|
+
enterFrom="opacity-0"
|
|
25
|
+
enterTo="opacity-100"
|
|
26
|
+
leave="ease-in duration-200"
|
|
27
|
+
leaveFrom="opacity-100"
|
|
28
|
+
leaveTo="opacity-0"
|
|
29
|
+
>
|
|
30
|
+
<div className="fixed inset-0 bg-black opacity-25" />
|
|
31
|
+
</Transition.Child>
|
|
32
|
+
|
|
33
|
+
<div className="fixed inset-0 overflow-y-auto">
|
|
34
|
+
<div className="flex min-h-full items-center justify-center p-4">
|
|
35
|
+
<Transition.Child
|
|
36
|
+
as={Fragment}
|
|
37
|
+
enter="ease-out duration-300"
|
|
38
|
+
enterFrom="opacity-0 scale-95"
|
|
39
|
+
enterTo="opacity-100 scale-100"
|
|
40
|
+
leave="ease-in duration-200"
|
|
41
|
+
leaveFrom="opacity-100 scale-100"
|
|
42
|
+
leaveTo="opacity-0"
|
|
43
|
+
>
|
|
44
|
+
<Dialog.Panel className="flex flex-col gap-5 max-w-3xl bg-white transform overflow-hidden rounded-lg p-7 transition-all">
|
|
45
|
+
<div className="flex items-center justify-between">
|
|
46
|
+
<Dialog.Title as="h3" className="text-lg font-semibold">
|
|
47
|
+
{title}
|
|
48
|
+
</Dialog.Title>
|
|
49
|
+
<button onClick={onClose}>
|
|
50
|
+
<XMarkIcon className="w-5 h-5 text-disabled" />
|
|
51
|
+
</button>
|
|
52
|
+
</div>
|
|
53
|
+
{children}
|
|
54
|
+
</Dialog.Panel>
|
|
55
|
+
</Transition.Child>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</Dialog>
|
|
59
|
+
</Transition>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { Modal }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ExclamationCircleIcon } from "@heroicons/react/24/solid";
|
|
2
|
+
|
|
3
|
+
export type ExclamationIconProps = {
|
|
4
|
+
variant: "warning" | "error" | "default"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const ExclamationIcon = ({ variant }: ExclamationIconProps) => {
|
|
8
|
+
const colorsIconMap = {
|
|
9
|
+
"warning": "#F6D523",
|
|
10
|
+
"error": "#FF3030",
|
|
11
|
+
"default": ""
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<ExclamationCircleIcon
|
|
16
|
+
width={32}
|
|
17
|
+
height={32}
|
|
18
|
+
color={colorsIconMap[variant]}
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { ExclamationIcon as Exclamationicon }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as NoticeStories from './Notice.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={NoticeStories} />
|
|
5
|
+
|
|
6
|
+
### Notice Card
|
|
7
|
+
Este é um componente usado para exibir noticias
|
|
8
|
+
|
|
9
|
+
### Default
|
|
10
|
+
<Canvas of={NoticeStories.Default} />
|
|
11
|
+
### Warning
|
|
12
|
+
<Canvas of={NoticeStories.Warning} />
|
|
13
|
+
### Error
|
|
14
|
+
<Canvas of={NoticeStories.Error} />
|
|
15
|
+
|
|
16
|
+
### Documentacao irativa
|
|
17
|
+
<Canvas of={NoticeStories.Default} />
|
|
18
|
+
<Controls of={NoticeStories.Default} />
|
|
19
|
+
|
|
20
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/nextjs'
|
|
2
|
+
import { Notice, NoticeProps } from './Notice'
|
|
3
|
+
|
|
4
|
+
const meta: Meta<NoticeProps> = {
|
|
5
|
+
title: 'Molecules/Notice',
|
|
6
|
+
component: Notice,
|
|
7
|
+
args: {
|
|
8
|
+
variant: 'default',
|
|
9
|
+
},
|
|
10
|
+
argTypes: {
|
|
11
|
+
variant: {
|
|
12
|
+
control: { type: 'select' },
|
|
13
|
+
options: ['default', 'warning', 'error']
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
|
|
20
|
+
export const Default: StoryObj<NoticeProps> = {
|
|
21
|
+
args: {
|
|
22
|
+
noticeTitle: 'Default Notice',
|
|
23
|
+
notice: 'This is a default notice without any specific variant.',
|
|
24
|
+
variant: 'default',
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const Warning: StoryObj<NoticeProps> = {
|
|
29
|
+
args: {
|
|
30
|
+
notice: 'This is a warning notice. Please be cautious!',
|
|
31
|
+
variant: 'warning'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const Error: StoryObj<NoticeProps> = {
|
|
36
|
+
args: {
|
|
37
|
+
notice: 'This is an error notice. Something went wrong!',
|
|
38
|
+
variant: 'error'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { XMarkIcon } from "@heroicons/react/24/solid";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
3
|
+
import { noticeStyles } from "./styles/notice.styles";
|
|
4
|
+
import { Typography } from "../Typography/Typography";
|
|
5
|
+
import { Exclamationicon } from "./ExclamationIcon";
|
|
6
|
+
|
|
7
|
+
export type NoticeProps = VariantProps<typeof noticeStyles> & {
|
|
8
|
+
notice?: string;
|
|
9
|
+
noticeTitle?: string;
|
|
10
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
11
|
+
|
|
12
|
+
const Notice = ({
|
|
13
|
+
variant = "warning",
|
|
14
|
+
notice,
|
|
15
|
+
noticeTitle,
|
|
16
|
+
}: NoticeProps) => {
|
|
17
|
+
return (
|
|
18
|
+
<div className={`${noticeStyles({ variant: variant })}`}>
|
|
19
|
+
<section className="flex items-center space-x-2">
|
|
20
|
+
{variant !== 'default' && (
|
|
21
|
+
<Exclamationicon variant={variant ?? 'warning'} />
|
|
22
|
+
)}
|
|
23
|
+
<div className="flex flex-col">
|
|
24
|
+
{noticeTitle && (
|
|
25
|
+
<Typography element="h1" variant="primary" size="xl">
|
|
26
|
+
{noticeTitle}
|
|
27
|
+
</Typography>
|
|
28
|
+
)}
|
|
29
|
+
{notice && (
|
|
30
|
+
<Typography element="p" variant="primary">
|
|
31
|
+
{notice}
|
|
32
|
+
</Typography>
|
|
33
|
+
)}
|
|
34
|
+
</div>
|
|
35
|
+
</section>
|
|
36
|
+
<XMarkIcon width={32} height={32} />
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { Notice };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority"
|
|
2
|
+
|
|
3
|
+
export const noticeStyles = cva('flex items-center justify-between rounded-md w-1/2 px-sm py-xs', {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
warning: 'bg-warning',
|
|
7
|
+
error: 'bg-error',
|
|
8
|
+
default: 'bg-disabled',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
defaultVariants: {
|
|
12
|
+
variant: 'default',
|
|
13
|
+
}
|
|
14
|
+
})
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import {
|
|
4
|
+
Switch as HeadlessSwitch,
|
|
5
|
+
type SwitchProps as HeadlessSwitchProps,
|
|
6
|
+
} from "@headlessui/react";
|
|
7
|
+
import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
|
8
|
+
|
|
9
|
+
export type SwitchProps = {
|
|
10
|
+
defaultEnable?: boolean;
|
|
11
|
+
variant?: "common" | "contract";
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onChange?: (enabled: boolean) => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Switch = ({
|
|
17
|
+
defaultEnable,
|
|
18
|
+
variant = "common",
|
|
19
|
+
disabled,
|
|
20
|
+
onChange,
|
|
21
|
+
...rest
|
|
22
|
+
}: SwitchProps) => {
|
|
23
|
+
const [enabled, setEnabled] = useState(defaultEnable);
|
|
24
|
+
|
|
25
|
+
const toggleSwitch = () => {
|
|
26
|
+
const newState = !enabled;
|
|
27
|
+
setEnabled(newState);
|
|
28
|
+
onChange?.(newState);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<HeadlessSwitch
|
|
33
|
+
checked={enabled}
|
|
34
|
+
onChange={toggleSwitch}
|
|
35
|
+
disabled={disabled}
|
|
36
|
+
{...rest}
|
|
37
|
+
>
|
|
38
|
+
{variant === "common" ? (
|
|
39
|
+
<span />
|
|
40
|
+
) : (
|
|
41
|
+
<span>
|
|
42
|
+
{enabled ? (
|
|
43
|
+
<CheckIcon aria-disabled={disabled} />
|
|
44
|
+
) : (
|
|
45
|
+
<XMarkIcon aria-disabled={disabled} />
|
|
46
|
+
)}
|
|
47
|
+
</span>
|
|
48
|
+
)}
|
|
49
|
+
</HeadlessSwitch>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { Switch };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const switchStyles = cva('outline-none relative inline-flex h-6 w-16 items-center rounded-full disabled:bg-disabled', {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
common: '',
|
|
7
|
+
contract: '',
|
|
8
|
+
},
|
|
9
|
+
enabled: {
|
|
10
|
+
true: '',
|
|
11
|
+
false: '',
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
compoundVariants: [
|
|
15
|
+
{
|
|
16
|
+
variant: 'common',
|
|
17
|
+
enabled: true,
|
|
18
|
+
className: 'bg-primary'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
variant: 'common',
|
|
22
|
+
enabled: false,
|
|
23
|
+
className: 'bg-primary hover:"bg-red-500'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
variant: 'contract',
|
|
27
|
+
enabled: true,
|
|
28
|
+
className: 'bg-success',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
variant: 'contract',
|
|
32
|
+
enabled: false,
|
|
33
|
+
className: 'bg-error',
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
variant: 'common',
|
|
38
|
+
enabled: false,
|
|
39
|
+
}
|
|
40
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as TextBlockStories from './TextBlock.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={TextBlockStories} />
|
|
5
|
+
|
|
6
|
+
### TextBlock
|
|
7
|
+
Este é um componente de Box que tem um titulo e subtitulo
|
|
8
|
+
|
|
9
|
+
### Default
|
|
10
|
+
<Canvas of={TextBlockStories.Default} />
|
|
11
|
+
### Dark
|
|
12
|
+
<Canvas of={TextBlockStories.Dark} />
|
|
13
|
+
### Outlined
|
|
14
|
+
<Canvas of={TextBlockStories.Outlined} />
|
|
15
|
+
|
|
16
|
+
### Documentacao iterativa
|
|
17
|
+
<Canvas of={TextBlockStories.Default} />
|
|
18
|
+
<Controls of={TextBlockStories.Default} />
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
+
import { TextBlock, TextBlockProps } from "./TextBlock";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<TextBlockProps> = {
|
|
5
|
+
title: "Atoms/TextBlock",
|
|
6
|
+
component: TextBlock,
|
|
7
|
+
args: {
|
|
8
|
+
variant: "default",
|
|
9
|
+
},
|
|
10
|
+
argTypes: {
|
|
11
|
+
variant: {
|
|
12
|
+
control: { type: "select" },
|
|
13
|
+
options: ["default", "dark", "outlined"],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
|
|
20
|
+
export const Default: StoryObj<TextBlockProps> = {
|
|
21
|
+
args: {
|
|
22
|
+
title: "Default Text Block",
|
|
23
|
+
variant: "default",
|
|
24
|
+
variantContent: "primary",
|
|
25
|
+
children:
|
|
26
|
+
"This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant.",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Dark: StoryObj<TextBlockProps> = {
|
|
31
|
+
args: {
|
|
32
|
+
title: "Dark Text Block",
|
|
33
|
+
variant: "dark",
|
|
34
|
+
variantContent: "secondary",
|
|
35
|
+
children:
|
|
36
|
+
"This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant.",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Outlined: StoryObj<TextBlockProps> = {
|
|
41
|
+
args: {
|
|
42
|
+
title: "Outlined Text Block",
|
|
43
|
+
variant: "outlined",
|
|
44
|
+
variantContent: "primary",
|
|
45
|
+
children:
|
|
46
|
+
"This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant. This is a dark text block with primary content variant.",
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority"
|
|
2
|
+
import { Typography } from "../Typography/Typography"
|
|
3
|
+
import { Box, BoxProps } from "../Box/Box"
|
|
4
|
+
import { textBlockStyles } from "./styles/styles.text-block"
|
|
5
|
+
|
|
6
|
+
type VariantContent = "primary" | "secondary" | "tertiary"
|
|
7
|
+
|
|
8
|
+
export type TextBlockProps = VariantProps<typeof textBlockStyles> & {
|
|
9
|
+
title?: string,
|
|
10
|
+
variantContent: VariantContent
|
|
11
|
+
} & React.HTMLAttributes<HTMLDivElement> & BoxProps
|
|
12
|
+
|
|
13
|
+
const TextBlock = ({
|
|
14
|
+
title,
|
|
15
|
+
children,
|
|
16
|
+
variant,
|
|
17
|
+
variantContent,
|
|
18
|
+
...rest
|
|
19
|
+
}: TextBlockProps) => {
|
|
20
|
+
return (
|
|
21
|
+
<Box
|
|
22
|
+
variant={variant}
|
|
23
|
+
{...rest}
|
|
24
|
+
>
|
|
25
|
+
<div className="flex flex-col space-y-2">
|
|
26
|
+
{title && (
|
|
27
|
+
<Typography
|
|
28
|
+
element="h1"
|
|
29
|
+
variant={variantContent}
|
|
30
|
+
size="xl"
|
|
31
|
+
>{title}</Typography>
|
|
32
|
+
)}
|
|
33
|
+
{children && <Typography element="p" variant={variantContent}>{children}</Typography>}
|
|
34
|
+
</div>
|
|
35
|
+
</Box>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { TextBlock }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
|
|
2
|
+
import * as TypographyStories from './Typography.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={TypographyStories} />
|
|
5
|
+
|
|
6
|
+
# Typography
|
|
7
|
+
Este é um componente de tipografia, usado para exibir um texto na tela.
|
|
8
|
+
|
|
9
|
+
### Primário
|
|
10
|
+
<Canvas of={TypographyStories.Primary} />
|
|
11
|
+
### Secundário
|
|
12
|
+
<Canvas of={TypographyStories.Secondary} />
|
|
13
|
+
### Terciário
|
|
14
|
+
<Canvas of={TypographyStories.Tertiary} />
|
|
15
|
+
|
|
16
|
+
### Documentacao iterativa:
|
|
17
|
+
<Canvas of={TypographyStories.Primary} />
|
|
18
|
+
<Controls of={TypographyStories.Primary} />
|