pge-front-common 1.0.2 → 1.0.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/.storybook/main.ts +22 -21
- package/.storybook/preview.ts +24 -13
- package/README.md +22 -6
- package/package.json +8 -3
- package/src/components/Button/Button.stories.tsx +21 -23
- package/src/components/Button/Button.tsx +22 -46
- package/src/components/Button/styles.tsx +39 -0
- package/src/components/Modal/Modal.stories.tsx +62 -0
- package/src/components/Modal/Modal.tsx +44 -0
- package/src/components/Modal/ModalConfirm/ModalConfirm.stories.tsx +48 -0
- package/src/components/Modal/ModalConfirm/index.tsx +32 -0
- package/src/components/Modal/ModalConfirm/styles.tsx +9 -0
- package/src/components/Modal/iconeClose.tsx +17 -0
- package/src/components/Modal/styles.tsx +75 -0
- package/src/components/theme.ts +16 -0
- package/src/index.ts +2 -1
- package/src/styled-components.d.ts +16 -0
- package/src/components/Button/button.css +0 -30
package/.storybook/main.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import type { StorybookConfig } from "@storybook/react-vite";
|
|
2
|
-
|
|
3
|
-
const config: StorybookConfig = {
|
|
4
|
-
stories: [
|
|
5
|
-
// "../stories/**/*.mdx",
|
|
6
|
-
// "../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
|
|
7
|
-
"../src/**/*.stories.tsx",
|
|
8
|
-
],
|
|
9
|
-
addons: [
|
|
10
|
-
"@storybook/addon-onboarding",
|
|
11
|
-
"@storybook/addon-links",
|
|
12
|
-
"@storybook/addon-essentials",
|
|
13
|
-
"@chromatic-com/storybook",
|
|
14
|
-
"@storybook/addon-interactions",
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
1
|
+
import type { StorybookConfig } from "@storybook/react-vite";
|
|
2
|
+
|
|
3
|
+
const config: StorybookConfig = {
|
|
4
|
+
stories: [
|
|
5
|
+
// "../stories/**/*.mdx",
|
|
6
|
+
// "../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
|
|
7
|
+
"../src/**/*.stories.tsx",
|
|
8
|
+
],
|
|
9
|
+
addons: [
|
|
10
|
+
"@storybook/addon-onboarding",
|
|
11
|
+
"@storybook/addon-links",
|
|
12
|
+
"@storybook/addon-essentials",
|
|
13
|
+
"@chromatic-com/storybook",
|
|
14
|
+
"@storybook/addon-interactions",
|
|
15
|
+
"@storybook/addon-themes",
|
|
16
|
+
],
|
|
17
|
+
framework: {
|
|
18
|
+
name: "@storybook/react-vite",
|
|
19
|
+
options: {},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export default config;
|
package/.storybook/preview.ts
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
1
|
+
// .storybook/preview.jsx
|
|
2
|
+
import { createGlobalStyle, ThemeProvider } from "styled-components";
|
|
3
|
+
import { withThemeFromJSXProvider } from "@storybook/addon-themes";
|
|
4
|
+
|
|
5
|
+
import theme from "../src/components/theme";
|
|
6
|
+
|
|
7
|
+
const GlobalStyle = createGlobalStyle`
|
|
8
|
+
@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
|
|
9
|
+
body {
|
|
10
|
+
font-family: 'Open Sans', sans-serif !;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/* snipped for brevity */
|
|
15
|
+
|
|
16
|
+
export const decorators = [
|
|
17
|
+
withThemeFromJSXProvider({
|
|
18
|
+
themes: {
|
|
19
|
+
default: theme,
|
|
20
|
+
},
|
|
21
|
+
defaultTheme: "default",
|
|
22
|
+
Provider: ThemeProvider,
|
|
23
|
+
GlobalStyles: GlobalStyle,
|
|
24
|
+
}),
|
|
25
|
+
];
|
package/README.md
CHANGED
|
@@ -10,16 +10,14 @@ My Component Library é uma biblioteca de componentes React criada com TypeScrip
|
|
|
10
10
|
- [Instalação](#instalação)
|
|
11
11
|
- [Uso](#uso)
|
|
12
12
|
- [Desenvolvimento](#desenvolvimento)
|
|
13
|
-
- [
|
|
14
|
-
- [Contribuição](#contribuição)
|
|
15
|
-
- [Licença](#licença)
|
|
13
|
+
- [Template Pull Request](#template)
|
|
16
14
|
|
|
17
15
|
## Instalação
|
|
18
16
|
|
|
19
17
|
Instale a biblioteca usando npm:
|
|
20
18
|
|
|
21
19
|
```bash
|
|
22
|
-
npm
|
|
20
|
+
npm i pge-front-common
|
|
23
21
|
```
|
|
24
22
|
|
|
25
23
|
## Uso
|
|
@@ -28,7 +26,7 @@ Instale a biblioteca usando npm:
|
|
|
28
26
|
|
|
29
27
|
```typescript
|
|
30
28
|
import React from 'react';
|
|
31
|
-
import { Button } from '
|
|
29
|
+
import { Button } from 'pge-front-common';
|
|
32
30
|
|
|
33
31
|
const App: React.FC = () => {
|
|
34
32
|
const handleClick = () => {
|
|
@@ -38,7 +36,7 @@ const App: React.FC = () => {
|
|
|
38
36
|
return (
|
|
39
37
|
<div>
|
|
40
38
|
<h1>Hello, World!</h1>
|
|
41
|
-
|
|
39
|
+
<Button variant="secondary" text="Text" />
|
|
42
40
|
</div>
|
|
43
41
|
);
|
|
44
42
|
};
|
|
@@ -62,3 +60,21 @@ npm run storybook
|
|
|
62
60
|
```
|
|
63
61
|
|
|
64
62
|
O Storybook estará disponível em http://localhost:6006.
|
|
63
|
+
|
|
64
|
+
## Template Pull Request
|
|
65
|
+
|
|
66
|
+
# Qual é a Feature ou Bug?
|
|
67
|
+
|
|
68
|
+
# Como foi implementada a solução?
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Isso pode impactar outra parte do projeto?
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# O que é esperado após esta implementação
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# Existem alterações na UI/UX? (screenshots, gravações de tela)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# Como reproduzir esta feature/correção?
|
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"@storybook/addon-interactions": "^8.1.11",
|
|
9
9
|
"@storybook/addon-links": "^8.1.11",
|
|
10
10
|
"@storybook/addon-onboarding": "^8.1.11",
|
|
11
|
+
"@storybook/addon-themes": "^8.1.11",
|
|
11
12
|
"@storybook/blocks": "^8.1.11",
|
|
12
13
|
"@storybook/react": "^8.1.11",
|
|
13
14
|
"@storybook/react-vite": "^8.1.11",
|
|
@@ -21,7 +22,8 @@
|
|
|
21
22
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
22
23
|
"rollup-plugin-postcss": "^4.0.2",
|
|
23
24
|
"storybook": "^8.1.11",
|
|
24
|
-
"typescript": "^5.5.2"
|
|
25
|
+
"typescript": "^5.5.2",
|
|
26
|
+
"@radix-ui/react-alert-dialog": "^1.1.1"
|
|
25
27
|
},
|
|
26
28
|
"peerDependencies": {
|
|
27
29
|
"react": "^18.2.0",
|
|
@@ -36,9 +38,12 @@
|
|
|
36
38
|
"module": "lib/index.esm.js",
|
|
37
39
|
"types": "lib/index.d.ts",
|
|
38
40
|
"name": "pge-front-common",
|
|
39
|
-
"version": "1.0.
|
|
41
|
+
"version": "1.0.3",
|
|
40
42
|
"description": "",
|
|
41
43
|
"keywords": [],
|
|
42
44
|
"author": "sturmer cesar",
|
|
43
|
-
"license": "ISC"
|
|
45
|
+
"license": "ISC",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"styled-components": "^6.1.11"
|
|
48
|
+
}
|
|
44
49
|
}
|
|
@@ -2,51 +2,49 @@ import type { Meta, StoryObj } from "@storybook/react";
|
|
|
2
2
|
import { fn } from "@storybook/test";
|
|
3
3
|
import { Button } from "./Button";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
5
|
+
const meta: Meta<typeof Button> = {
|
|
7
6
|
title: "Example/Button",
|
|
8
7
|
component: Button,
|
|
9
8
|
parameters: {
|
|
10
|
-
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
11
9
|
layout: "centered",
|
|
12
10
|
},
|
|
13
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
14
11
|
tags: ["autodocs"],
|
|
15
|
-
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
16
12
|
argTypes: {
|
|
17
|
-
|
|
13
|
+
variant: {
|
|
14
|
+
control: { type: "select" },
|
|
15
|
+
options: ["primary", "secondary"],
|
|
16
|
+
},
|
|
17
|
+
text: { control: "text" },
|
|
18
|
+
leftIcon: { control: "text" },
|
|
19
|
+
onClick: { action: "clicked" },
|
|
18
20
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
21
|
+
args: {
|
|
22
|
+
onClick: fn(),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
22
25
|
|
|
23
26
|
export default meta;
|
|
27
|
+
|
|
24
28
|
type Story = StoryObj<typeof meta>;
|
|
25
29
|
|
|
26
|
-
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
27
30
|
export const Primary: Story = {
|
|
28
31
|
args: {
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
variant: "primary",
|
|
33
|
+
text: "Primary Button",
|
|
31
34
|
},
|
|
32
35
|
};
|
|
33
36
|
|
|
34
37
|
export const Secondary: Story = {
|
|
35
38
|
args: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const Large: Story = {
|
|
41
|
-
args: {
|
|
42
|
-
size: "large",
|
|
43
|
-
label: "Button",
|
|
39
|
+
variant: "secondary",
|
|
40
|
+
text: "Secondary Button",
|
|
44
41
|
},
|
|
45
42
|
};
|
|
46
43
|
|
|
47
|
-
export const
|
|
44
|
+
export const WithIcon: Story = {
|
|
48
45
|
args: {
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
variant: "primary",
|
|
47
|
+
text: "Button with Icon",
|
|
48
|
+
leftIcon: "⭐", // You can use any ReactNode, here we use a simple star emoji for demonstration
|
|
51
49
|
},
|
|
52
50
|
};
|
|
@@ -1,52 +1,28 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import "
|
|
1
|
+
import React, { ButtonHTMLAttributes } from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import * as s from "./styles";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
primary?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* What background color to use
|
|
11
|
-
*/
|
|
12
|
-
backgroundColor?: string;
|
|
13
|
-
/**
|
|
14
|
-
* How large should the button be?
|
|
15
|
-
*/
|
|
16
|
-
size?: "small" | "medium" | "large";
|
|
17
|
-
/**
|
|
18
|
-
* Button contents
|
|
19
|
-
*/
|
|
20
|
-
label: string;
|
|
21
|
-
/**
|
|
22
|
-
* Optional click handler
|
|
23
|
-
*/
|
|
24
|
-
onClick?: () => void;
|
|
5
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
variant: "primary" | "secondary";
|
|
7
|
+
text: string;
|
|
8
|
+
leftIcon?: React.ReactNode;
|
|
25
9
|
}
|
|
26
10
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
11
|
+
const StyledButton = styled(s.BaseButton)<{ variant: "primary" | "secondary" }>`
|
|
12
|
+
${({ variant }) =>
|
|
13
|
+
variant === "primary" ? s.PrimaryButton : s.SecondaryButton}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export function Button({
|
|
17
|
+
variant,
|
|
18
|
+
text = "",
|
|
19
|
+
leftIcon,
|
|
35
20
|
...props
|
|
36
|
-
}: ButtonProps)
|
|
37
|
-
const mode = primary
|
|
38
|
-
? "storybook-button--primary"
|
|
39
|
-
: "storybook-button--secondary";
|
|
21
|
+
}: ButtonProps) {
|
|
40
22
|
return (
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)}
|
|
46
|
-
style={{ backgroundColor }}
|
|
47
|
-
{...props}
|
|
48
|
-
>
|
|
49
|
-
{label}
|
|
50
|
-
</button>
|
|
23
|
+
<StyledButton variant={variant} {...props}>
|
|
24
|
+
{leftIcon}
|
|
25
|
+
{text}
|
|
26
|
+
</StyledButton>
|
|
51
27
|
);
|
|
52
|
-
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
|
|
3
|
+
// Estilos base compartilhados
|
|
4
|
+
export const BaseButton = styled.button`
|
|
5
|
+
all: unset;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
gap: 4px;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
|
|
12
|
+
&:disabled {
|
|
13
|
+
cursor: not-allowed;
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
// Estilos do botão primário
|
|
18
|
+
export const PrimaryButton = css`
|
|
19
|
+
width: fit-content;
|
|
20
|
+
height: fit-content;
|
|
21
|
+
padding: 12px 16px;
|
|
22
|
+
border-radius: 8px;
|
|
23
|
+
border: 1px solid ${({ theme }) => theme.colors.primary};
|
|
24
|
+
color: #fff;
|
|
25
|
+
font-weight: 700;
|
|
26
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
// Estilos do botão secundário
|
|
30
|
+
export const SecondaryButton = css`
|
|
31
|
+
width: fit-content;
|
|
32
|
+
height: fit-content;
|
|
33
|
+
padding: 12px 8px;
|
|
34
|
+
border-radius: 8px;
|
|
35
|
+
border: 1px solid ${({ theme }) => theme.colors.primary};
|
|
36
|
+
font-weight: 700;
|
|
37
|
+
color: ${({ theme }) => theme.colors.primary};
|
|
38
|
+
background: transparent;
|
|
39
|
+
`;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { Modal } from "./Modal";
|
|
4
|
+
import { fn } from "@storybook/test";
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Example/Modal",
|
|
8
|
+
component: Modal,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: "centered",
|
|
11
|
+
},
|
|
12
|
+
tags: ["autodocs"],
|
|
13
|
+
argTypes: {
|
|
14
|
+
isModalOpen: { control: "boolean" },
|
|
15
|
+
onOpenChange: { action: "onOpenChange" },
|
|
16
|
+
children: { control: "text" },
|
|
17
|
+
},
|
|
18
|
+
args: {
|
|
19
|
+
isModalOpen: false,
|
|
20
|
+
onOpenChange: fn(),
|
|
21
|
+
children: "This is the modal content.",
|
|
22
|
+
title: "Title",
|
|
23
|
+
},
|
|
24
|
+
} satisfies Meta<typeof Modal>;
|
|
25
|
+
|
|
26
|
+
export default meta;
|
|
27
|
+
type Story = StoryObj<typeof meta>;
|
|
28
|
+
|
|
29
|
+
const Template: Story = {
|
|
30
|
+
render: (args) => {
|
|
31
|
+
const [isModalOpen, setIsModalOpen] = useState(args.isModalOpen);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Modal
|
|
35
|
+
{...args}
|
|
36
|
+
isModalOpen={isModalOpen}
|
|
37
|
+
onOpenChange={(open) => {
|
|
38
|
+
setIsModalOpen(open);
|
|
39
|
+
args.onOpenChange(open);
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
{args.children}
|
|
43
|
+
</Modal>
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const Default: Story = {
|
|
49
|
+
...Template,
|
|
50
|
+
args: {
|
|
51
|
+
isModalOpen: true,
|
|
52
|
+
children: "This is the modal content.",
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Closed: Story = {
|
|
57
|
+
...Template,
|
|
58
|
+
args: {
|
|
59
|
+
isModalOpen: false,
|
|
60
|
+
children: "This is the modal content.",
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as Alert from "@radix-ui/react-alert-dialog";
|
|
3
|
+
import {
|
|
4
|
+
AlertOverlay,
|
|
5
|
+
ContentContainer,
|
|
6
|
+
ModalHeaderContainer,
|
|
7
|
+
ModalHeaderText,
|
|
8
|
+
CloseBtn,
|
|
9
|
+
ContentChildren,
|
|
10
|
+
} from "./styles";
|
|
11
|
+
import { CloseIcon } from "./iconeClose";
|
|
12
|
+
|
|
13
|
+
export interface ModalProps {
|
|
14
|
+
isModalOpen: boolean;
|
|
15
|
+
onOpenChange: React.Dispatch<React.SetStateAction<boolean>>;
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
title: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Modal = ({
|
|
21
|
+
isModalOpen,
|
|
22
|
+
onOpenChange,
|
|
23
|
+
children,
|
|
24
|
+
title,
|
|
25
|
+
}: ModalProps) => {
|
|
26
|
+
return (
|
|
27
|
+
<Alert.Root open={isModalOpen} onOpenChange={onOpenChange}>
|
|
28
|
+
<Alert.Portal>
|
|
29
|
+
<AlertOverlay />
|
|
30
|
+
<ContentContainer>
|
|
31
|
+
<ModalHeaderContainer>
|
|
32
|
+
<ModalHeaderText>{title}</ModalHeaderText>
|
|
33
|
+
<CloseBtn onClick={() => onOpenChange(!isModalOpen)}>
|
|
34
|
+
<CloseIcon />
|
|
35
|
+
{/* <CustomIcon className="material-icons-outlined">close</CustomIcon> */}
|
|
36
|
+
</CloseBtn>
|
|
37
|
+
</ModalHeaderContainer>
|
|
38
|
+
|
|
39
|
+
<ContentChildren>{children}</ContentChildren>
|
|
40
|
+
</ContentContainer>
|
|
41
|
+
</Alert.Portal>
|
|
42
|
+
</Alert.Root>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import ModalConfirm from "./index";
|
|
4
|
+
import { fn } from "@storybook/test";
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Example/ModalConfirm",
|
|
8
|
+
component: ModalConfirm,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: "centered",
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
args: {
|
|
14
|
+
isModalOpen: false,
|
|
15
|
+
onOpenChange: fn(),
|
|
16
|
+
children: "conteúdo",
|
|
17
|
+
},
|
|
18
|
+
} satisfies Meta<typeof ModalConfirm>;
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
|
|
23
|
+
const Template: Story = {
|
|
24
|
+
render: (args) => {
|
|
25
|
+
const [isModalOpen, setIsModalOpen] = useState(args.isModalOpen);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<ModalConfirm
|
|
29
|
+
{...args}
|
|
30
|
+
isModalOpen={isModalOpen}
|
|
31
|
+
onOpenChange={(open) => {
|
|
32
|
+
setIsModalOpen(open);
|
|
33
|
+
args.onOpenChange(open);
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
{args.children}
|
|
37
|
+
</ModalConfirm>
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const Default: Story = {
|
|
43
|
+
...Template,
|
|
44
|
+
args: {
|
|
45
|
+
isModalOpen: true,
|
|
46
|
+
children: "conteúdo",
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Modal } from "../Modal";
|
|
3
|
+
import { Button } from "../../Button/Button";
|
|
4
|
+
import * as S from "./styles";
|
|
5
|
+
|
|
6
|
+
export interface ModalProps {
|
|
7
|
+
isModalOpen: boolean;
|
|
8
|
+
onOpenChange: React.Dispatch<React.SetStateAction<boolean>>;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ModalConfirm: React.FC<ModalProps> = ({
|
|
13
|
+
isModalOpen,
|
|
14
|
+
onOpenChange,
|
|
15
|
+
children,
|
|
16
|
+
}) => {
|
|
17
|
+
return (
|
|
18
|
+
<Modal
|
|
19
|
+
isModalOpen={isModalOpen}
|
|
20
|
+
onOpenChange={onOpenChange}
|
|
21
|
+
title="Título (Resumo do conteúdo)"
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
<S.ContainerModalConfirm>
|
|
25
|
+
<Button variant="secondary" text="Cancelar" />
|
|
26
|
+
<Button variant="primary" text="Ação" />
|
|
27
|
+
</S.ContainerModalConfirm>
|
|
28
|
+
</Modal>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default ModalConfirm;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { SVGProps } from "react";
|
|
2
|
+
|
|
3
|
+
export const CloseIcon = (props: SVGProps<SVGSVGElement>) => (
|
|
4
|
+
<svg
|
|
5
|
+
width="14"
|
|
6
|
+
height="17"
|
|
7
|
+
viewBox="0 0 14 17"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
{...props}
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
d="M7.4251 10.1343L2.5251 15.8543C2.34176 16.0684 2.10843 16.1754 1.8251 16.1754C1.54176 16.1754 1.30843 16.0684 1.1251 15.8543C0.941764 15.6403 0.850098 15.3679 0.850098 15.0372C0.850098 14.7064 0.941764 14.4341 1.1251 14.2201L6.0251 8.50003L1.1251 2.78002C0.941764 2.566 0.850098 2.29362 0.850098 1.96287C0.850098 1.63212 0.941764 1.35974 1.1251 1.14573C1.30843 0.931714 1.54176 0.824707 1.8251 0.824707C2.10843 0.824707 2.34176 0.931714 2.5251 1.14573L7.4251 6.86574L12.3251 1.14573C12.5084 0.931714 12.7418 0.824707 13.0251 0.824707C13.3084 0.824707 13.5418 0.931714 13.7251 1.14573C13.9084 1.35974 14.0001 1.63212 14.0001 1.96287C14.0001 2.29362 13.9084 2.566 13.7251 2.78002L8.8251 8.50003L13.7251 14.2201C13.9084 14.4341 14.0001 14.7064 14.0001 15.0372C14.0001 15.3679 13.9084 15.6403 13.7251 15.8543C13.5418 16.0684 13.3084 16.1754 13.0251 16.1754C12.7418 16.1754 12.5084 16.0684 12.3251 15.8543L7.4251 10.1343Z"
|
|
14
|
+
fill="white"
|
|
15
|
+
/>
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import styled, { keyframes } from "styled-components";
|
|
2
|
+
|
|
3
|
+
const overlayShow = keyframes`
|
|
4
|
+
from {
|
|
5
|
+
opacity: 0;
|
|
6
|
+
}
|
|
7
|
+
to {
|
|
8
|
+
opacity: 1;
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
const AlertOverlay = styled.div`
|
|
13
|
+
background: rgb(61 62 63 / 0.5);
|
|
14
|
+
position: fixed;
|
|
15
|
+
inset: 0;
|
|
16
|
+
animation: ${overlayShow} 300ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const ModalHeaderContainer = styled.div`
|
|
20
|
+
width: 410px;
|
|
21
|
+
height: 56px;
|
|
22
|
+
border-radius: 6px 6px 0 0;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: row;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: space-between;
|
|
27
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
28
|
+
padding-left: 24px;
|
|
29
|
+
padding-right: 24px;
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
const ModalHeaderText = styled.div`
|
|
33
|
+
font-size: 20px;
|
|
34
|
+
font-weight: 700;
|
|
35
|
+
line-height: 24px;
|
|
36
|
+
text-align: left;
|
|
37
|
+
color: ${({ theme }) => theme.colors.base.white};
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const CloseBtn = styled.button`
|
|
41
|
+
all: unset;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
const CustomIcon = styled.div`
|
|
46
|
+
color: ${({ theme }) => theme.colors.base.white};
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
const ContentContainer = styled.div`
|
|
50
|
+
border-radius: 6px;
|
|
51
|
+
box-shadow:
|
|
52
|
+
hsl(206 22% 7% / 35%) 0px 10px 38px -10px,
|
|
53
|
+
hsl(206 22% 7% / 20%) 0px 10px 20px -15px;
|
|
54
|
+
position: fixed;
|
|
55
|
+
top: 50%;
|
|
56
|
+
left: 50%;
|
|
57
|
+
transform: translate(-50%, -50%);
|
|
58
|
+
max-width: 500px;
|
|
59
|
+
height: auto;
|
|
60
|
+
background: ${({ theme }) => theme.colors.base.white};
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const ContentChildren = styled.div`
|
|
64
|
+
padding: 20px;
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
AlertOverlay,
|
|
69
|
+
ModalHeaderContainer,
|
|
70
|
+
ModalHeaderText,
|
|
71
|
+
CloseBtn,
|
|
72
|
+
CustomIcon,
|
|
73
|
+
ContentContainer,
|
|
74
|
+
ContentChildren,
|
|
75
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// styled-components.d.ts
|
|
2
|
+
import "styled-components";
|
|
3
|
+
|
|
4
|
+
declare module "styled-components" {
|
|
5
|
+
export interface DefaultTheme {
|
|
6
|
+
colors: {
|
|
7
|
+
primary: string;
|
|
8
|
+
secondary: string;
|
|
9
|
+
|
|
10
|
+
base: {
|
|
11
|
+
white: string;
|
|
12
|
+
black: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
.storybook-button {
|
|
2
|
-
font-family: "Nunito Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
3
|
-
font-weight: 700;
|
|
4
|
-
border: 0;
|
|
5
|
-
border-radius: 3em;
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
display: inline-block;
|
|
8
|
-
line-height: 1;
|
|
9
|
-
}
|
|
10
|
-
.storybook-button--primary {
|
|
11
|
-
color: white;
|
|
12
|
-
background-color: #1ea7fd;
|
|
13
|
-
}
|
|
14
|
-
.storybook-button--secondary {
|
|
15
|
-
color: #333;
|
|
16
|
-
background-color: transparent;
|
|
17
|
-
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
|
|
18
|
-
}
|
|
19
|
-
.storybook-button--small {
|
|
20
|
-
font-size: 12px;
|
|
21
|
-
padding: 10px 16px;
|
|
22
|
-
}
|
|
23
|
-
.storybook-button--medium {
|
|
24
|
-
font-size: 14px;
|
|
25
|
-
padding: 11px 20px;
|
|
26
|
-
}
|
|
27
|
-
.storybook-button--large {
|
|
28
|
-
font-size: 16px;
|
|
29
|
-
padding: 12px 24px;
|
|
30
|
-
}
|