@granto-umbrella/umbrella-components 1.0.0 → 1.0.2
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/.github/workflows/azure-static-web-apps-white-beach-08c746f0f.yml +5 -3
- package/package.json +3 -5
- package/src/assets/react.svg +1 -0
- package/src/components/atoms/Button/Button.stories.tsx +94 -0
- package/src/components/atoms/Button/Button.styles.ts +122 -0
- package/src/components/atoms/Button/Button.test.tsx +0 -0
- package/src/components/atoms/Button/Button.tsx +44 -0
- package/src/components/atoms/Button/Button.types.ts +11 -0
- package/src/components/atoms/Button/index.ts +1 -0
- package/src/components/atoms/Icon/Icon.stories.tsx +46 -0
- package/src/components/atoms/Icon/Icon.styles.ts +10 -0
- package/src/components/atoms/Icon/Icon.test.tsx +0 -0
- package/src/components/atoms/Icon/Icon.tsx +22 -0
- package/src/components/atoms/Icon/Icon.types.ts +6 -0
- package/src/components/atoms/Icon/index.ts +1 -0
- package/src/components/atoms/Input/Input.stories.tsx +135 -0
- package/src/components/atoms/Input/Input.styles.ts +87 -0
- package/src/components/atoms/Input/Input.test.tsx +0 -0
- package/src/components/atoms/Input/Input.tsx +50 -0
- package/src/components/atoms/Input/Input.types.ts +19 -0
- package/src/components/atoms/Input/index.ts +1 -0
- package/src/components/atoms/Select/Select.stories.tsx +101 -0
- package/src/components/atoms/Select/Select.styles.ts +67 -0
- package/src/components/atoms/Select/Select.test.tsx +0 -0
- package/src/components/atoms/Select/Select.tsx +40 -0
- package/src/components/atoms/Select/Select.types.ts +11 -0
- package/src/components/atoms/Select/index.tsx +1 -0
- package/src/index.ts +24 -0
- package/src/styles/Tokens.stories.tsx +186 -0
- package/src/styles/tokens/borders.ts +26 -0
- package/src/styles/tokens/colors.ts +103 -0
- package/src/styles/tokens/index.tsx +8 -0
- package/src/styles/tokens/shadows.ts +18 -0
- package/src/styles/tokens/sizes.ts +41 -0
- package/src/styles/tokens/typography.ts +123 -0
- package/src/types/radius.types.ts +7 -0
- package/src/types/shadows.types.ts +1 -0
- package/src/types/sizes.types.ts +37 -0
- package/storybook-static/assets/Button.stories-WRnO5s_-.js +101 -0
- package/storybook-static/assets/{Color-F6OSRLHC-B28yCw-n.js → Color-F6OSRLHC-DIVYeXSt.js} +1 -1
- package/storybook-static/assets/{DocsRenderer-CFRXHY34-CWahT8pR.js → DocsRenderer-CFRXHY34-CT_eS361.js} +582 -582
- package/storybook-static/assets/Input.stories-Wd3mlW4i.js +62 -0
- package/storybook-static/assets/{entry-preview-DiNZKYoC.js → entry-preview-CiwqR2jx.js} +10 -10
- package/storybook-static/assets/entry-preview-docs-kHJf9rLT.js +46 -46
- package/storybook-static/assets/{iframe-uxZGGVXq.js → iframe-039Wi6Rb.js} +2 -2
- package/storybook-static/assets/{index-P4L_AK6N.js → index-Bn6FWhtY.js} +1 -1
- package/storybook-static/assets/index-D0KPOhiX.js +234 -234
- package/storybook-static/assets/preview-BnGEyR21.js +1 -1
- package/storybook-static/assets/{preview-DVkvl-ZV.js → preview-M2P5O1Yh.js} +2 -2
- package/storybook-static/iframe.html +639 -639
- package/storybook-static/index.html +185 -185
- package/storybook-static/project.json +1 -1
- package/storybook-static/sb-addons/actions-11/manager-bundle.js +3 -3
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js +331 -331
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js.LEGAL.txt +51 -51
- package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +12 -12
- package/storybook-static/sb-addons/essentials-docs-3/manager-bundle.js +230 -230
- package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +3 -3
- package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +3 -3
- package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js +3 -3
- package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +3 -3
- package/storybook-static/sb-addons/interactions-10/manager-bundle.js +210 -210
- package/storybook-static/assets/Button.stories-DowwDwMw.js +0 -96
- package/storybook-static/assets/Input.stories-BxeTVJE8.js +0 -49
|
@@ -31,6 +31,10 @@ jobs:
|
|
|
31
31
|
- name: Install dependencies
|
|
32
32
|
run: yarn install
|
|
33
33
|
|
|
34
|
+
# Build Storybook
|
|
35
|
+
- name: Build Storybook
|
|
36
|
+
run: yarn build-storybook
|
|
37
|
+
|
|
34
38
|
# Deploy to Azure Static Web Apps
|
|
35
39
|
- name: Deploy to Azure Static Web Apps
|
|
36
40
|
id: builddeploy
|
|
@@ -39,11 +43,9 @@ jobs:
|
|
|
39
43
|
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WHITE_BEACH_08C746F0F }}
|
|
40
44
|
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for GitHub integrations (i.e., PR comments)
|
|
41
45
|
action: "upload"
|
|
42
|
-
|
|
43
|
-
app_location: "/" # App source code path
|
|
46
|
+
app_location: "" # Root of the built Storybook
|
|
44
47
|
api_location: "" # API source code path - optional
|
|
45
48
|
output_location: "storybook-static" # Built Storybook directory
|
|
46
|
-
###### End of Repository/Build Configurations ######
|
|
47
49
|
|
|
48
50
|
close_pull_request_job:
|
|
49
51
|
if: github.event_name == 'pull_request' && github.event.action == 'closed'
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granto-umbrella/umbrella-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Umbrella Components for React",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "
|
|
7
|
-
"
|
|
8
|
-
"meu-cli": "cli/index.js"
|
|
9
|
-
},
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"module": "src/index.js",
|
|
10
8
|
"repository": {
|
|
11
9
|
"type": "git",
|
|
12
10
|
"url": "https://github.com/grantoseguros/granto-umbrella-components.git"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
2
|
+
import Button from "./Button";
|
|
3
|
+
import * as Icons from "@phosphor-icons/react";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Atoms/Button",
|
|
7
|
+
component: Button,
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
source: {
|
|
11
|
+
type: "code",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
argTypes: {
|
|
16
|
+
size: { control: "select", options: ["xs", "sm", "md", "lg"] },
|
|
17
|
+
variant: {
|
|
18
|
+
control: "select",
|
|
19
|
+
options: ["primary", "outline", "danger", "ghost"],
|
|
20
|
+
},
|
|
21
|
+
radius: {
|
|
22
|
+
control: "select",
|
|
23
|
+
options: [
|
|
24
|
+
"--border-0",
|
|
25
|
+
"--border-1",
|
|
26
|
+
"--border-2",
|
|
27
|
+
"--border-3",
|
|
28
|
+
"--border-4",
|
|
29
|
+
"--border-5",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
isLoading: { control: "boolean" },
|
|
33
|
+
leftIcon: {
|
|
34
|
+
control: "select",
|
|
35
|
+
options: Object.keys(Icons),
|
|
36
|
+
},
|
|
37
|
+
rightIcon: {
|
|
38
|
+
control: "select",
|
|
39
|
+
options: Object.keys(Icons),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
} as Meta;
|
|
43
|
+
|
|
44
|
+
const Template: StoryFn = (args) => <Button {...args} />;
|
|
45
|
+
|
|
46
|
+
export const Primary = Template.bind({});
|
|
47
|
+
Primary.args = { children: "Primary" };
|
|
48
|
+
Primary.parameters = {
|
|
49
|
+
docs: {
|
|
50
|
+
source: {
|
|
51
|
+
code: `<Button size="md" variant="primary" radius="--border-1">Primary</Button>`,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const WithLeftIcon = Template.bind({});
|
|
57
|
+
WithLeftIcon.args = {
|
|
58
|
+
children: "Left Icon",
|
|
59
|
+
leftIcon: "ArrowLeft",
|
|
60
|
+
};
|
|
61
|
+
WithLeftIcon.parameters = {
|
|
62
|
+
docs: {
|
|
63
|
+
source: {
|
|
64
|
+
code: `<Button size="md" variant="primary" radius="--border-1" leftIcon={<ArrowLeft size={16} />}>Left Icon</Button>`,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const WithRightIcon = Template.bind({});
|
|
70
|
+
WithRightIcon.args = {
|
|
71
|
+
children: "Right Icon",
|
|
72
|
+
rightIcon: "ArrowRight",
|
|
73
|
+
};
|
|
74
|
+
WithRightIcon.parameters = {
|
|
75
|
+
docs: {
|
|
76
|
+
source: {
|
|
77
|
+
code: `<Button size="md" variant="primary" radius="--border-1" rightIcon={<ArrowRight size={16} />}>Right Icon</Button>`,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const WithBothIcons = Template.bind({});
|
|
83
|
+
WithBothIcons.args = {
|
|
84
|
+
children: "Both Icons",
|
|
85
|
+
leftIcon: "ArrowLeft",
|
|
86
|
+
rightIcon: "ArrowRight",
|
|
87
|
+
};
|
|
88
|
+
WithBothIcons.parameters = {
|
|
89
|
+
docs: {
|
|
90
|
+
source: {
|
|
91
|
+
code: `<Button size="md" variant="primary" radius="--border-1" leftIcon={<ArrowLeft size={16} />} rightIcon={<ArrowRight size={16} />}>Both Icons</Button>`,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import {
|
|
3
|
+
primitiveSizes,
|
|
4
|
+
semanticColors,
|
|
5
|
+
semanticRadiusBorders,
|
|
6
|
+
semanticSizes,
|
|
7
|
+
} from "../../../styles/tokens";
|
|
8
|
+
|
|
9
|
+
const buttonSizes = {
|
|
10
|
+
xs: css`
|
|
11
|
+
padding: ${primitiveSizes["size-1.5"]} ${semanticSizes["xl"]};
|
|
12
|
+
font-size: ${primitiveSizes["size-3.5"]};
|
|
13
|
+
icon-size: ${primitiveSizes["size-4"]};
|
|
14
|
+
`,
|
|
15
|
+
sm: css`
|
|
16
|
+
padding: ${primitiveSizes["size-2.5"]} ${primitiveSizes["size-5"]};
|
|
17
|
+
font-size: ${primitiveSizes["size-3.5"]};
|
|
18
|
+
icon-size: ${primitiveSizes["size-5"]};
|
|
19
|
+
`,
|
|
20
|
+
md: css`
|
|
21
|
+
padding: ${semanticSizes.lg} ${semanticSizes["2xl"]};
|
|
22
|
+
font-size: ${primitiveSizes["size-4"]};
|
|
23
|
+
icon-size: ${primitiveSizes["size-5"]};
|
|
24
|
+
`,
|
|
25
|
+
lg: css`
|
|
26
|
+
padding: ${semanticSizes.xl} ${semanticSizes["2xl"]};
|
|
27
|
+
font-size: ${primitiveSizes["size-5"]};
|
|
28
|
+
icon-size: ${primitiveSizes["size-6"]};
|
|
29
|
+
`,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const buttonVariants = {
|
|
33
|
+
primary: css`
|
|
34
|
+
background: ${semanticColors.branding["--branding-400"]};
|
|
35
|
+
color: ${semanticColors.base["--background"]};
|
|
36
|
+
border: none;
|
|
37
|
+
&:hover {
|
|
38
|
+
background: ${semanticColors.branding["--branding-300"]};
|
|
39
|
+
}
|
|
40
|
+
&:active {
|
|
41
|
+
background: ${semanticColors.branding["--branding-500"]};
|
|
42
|
+
}
|
|
43
|
+
&:disabled {
|
|
44
|
+
background: ${semanticColors.branding["--branding-100"]};
|
|
45
|
+
}
|
|
46
|
+
`,
|
|
47
|
+
outline: css`
|
|
48
|
+
border: 1px solid ${semanticColors.branding["--branding-400"]};
|
|
49
|
+
color: ${semanticColors.branding["--branding-400"]};
|
|
50
|
+
background: transparent;
|
|
51
|
+
&:hover {
|
|
52
|
+
border: 1px solid ${semanticColors.branding["--branding-300"]};
|
|
53
|
+
color: ${semanticColors.branding["--branding-300"]};
|
|
54
|
+
}
|
|
55
|
+
&:active {
|
|
56
|
+
border: 1px solid ${semanticColors.branding["--branding-500"]};
|
|
57
|
+
color: ${semanticColors.branding["--branding-500"]};
|
|
58
|
+
}
|
|
59
|
+
&:disabled {
|
|
60
|
+
color: ${semanticColors.branding["--branding-100"]};
|
|
61
|
+
border: 1px solid ${semanticColors.branding["--branding-100"]};
|
|
62
|
+
}
|
|
63
|
+
`,
|
|
64
|
+
ghost: css`
|
|
65
|
+
background: transparent;
|
|
66
|
+
color: ${semanticColors.branding["--branding-400"]};
|
|
67
|
+
border: none;
|
|
68
|
+
&:hover {
|
|
69
|
+
color: ${semanticColors.branding["--branding-300"]};
|
|
70
|
+
}
|
|
71
|
+
&:active {
|
|
72
|
+
color: ${semanticColors.branding["--branding-500"]};
|
|
73
|
+
}
|
|
74
|
+
&:disabled {
|
|
75
|
+
color: ${semanticColors.branding["--branding-100"]};
|
|
76
|
+
}
|
|
77
|
+
`,
|
|
78
|
+
danger: css`
|
|
79
|
+
background: ${semanticColors.danger["--danger-400"]};
|
|
80
|
+
color: ${semanticColors.base["--background"]};
|
|
81
|
+
border: none;
|
|
82
|
+
&:hover {
|
|
83
|
+
background: ${semanticColors.danger["--danger-300"]};
|
|
84
|
+
}
|
|
85
|
+
&:active {
|
|
86
|
+
background: ${semanticColors.danger["--danger-500"]};
|
|
87
|
+
}
|
|
88
|
+
&:disabled {
|
|
89
|
+
background: ${semanticColors.danger["--danger-200"]};
|
|
90
|
+
}
|
|
91
|
+
`,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const StyledButton = styled.button<{
|
|
95
|
+
size: keyof typeof buttonSizes;
|
|
96
|
+
variant: keyof typeof buttonVariants;
|
|
97
|
+
radius: keyof typeof semanticRadiusBorders;
|
|
98
|
+
}>`
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: center;
|
|
102
|
+
font-weight: 500;
|
|
103
|
+
border-radius: ${({ radius }) => semanticRadiusBorders[radius]};
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
transition: all 0.2s ease-in-out;
|
|
106
|
+
|
|
107
|
+
${({ size }) => buttonSizes[size]}
|
|
108
|
+
${({ variant }) => buttonVariants[variant]}
|
|
109
|
+
|
|
110
|
+
&:disabled {
|
|
111
|
+
cursor: not-allowed;
|
|
112
|
+
opacity: 0.6;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.icon-left {
|
|
116
|
+
margin-right: ${semanticSizes.sm};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.icon-right {
|
|
120
|
+
margin-left: ${semanticSizes.sm};
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyledButton } from "./Button.styles";
|
|
3
|
+
import { ButtonProps } from "./Button.types";
|
|
4
|
+
import * as Icons from "@phosphor-icons/react";
|
|
5
|
+
|
|
6
|
+
const Button: React.FC<ButtonProps> = ({
|
|
7
|
+
children,
|
|
8
|
+
size = "md",
|
|
9
|
+
variant = "primary",
|
|
10
|
+
radius = "--border-2",
|
|
11
|
+
isLoading = false,
|
|
12
|
+
leftIcon,
|
|
13
|
+
rightIcon,
|
|
14
|
+
...props
|
|
15
|
+
}) => {
|
|
16
|
+
const IconComponentLeft =
|
|
17
|
+
leftIcon && (Icons[leftIcon as keyof typeof Icons] as React.ElementType);
|
|
18
|
+
const IconComponentRight =
|
|
19
|
+
rightIcon && (Icons[rightIcon as keyof typeof Icons] as React.ElementType);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<StyledButton size={size} variant={variant} radius={radius} {...props}>
|
|
23
|
+
{isLoading ? (
|
|
24
|
+
<Icons.Spinner size={16} />
|
|
25
|
+
) : (
|
|
26
|
+
<>
|
|
27
|
+
{IconComponentLeft && (
|
|
28
|
+
<span className="icon-left">
|
|
29
|
+
<IconComponentLeft size={16} />
|
|
30
|
+
</span>
|
|
31
|
+
)}
|
|
32
|
+
{children}
|
|
33
|
+
{IconComponentRight && (
|
|
34
|
+
<span className="icon-right">
|
|
35
|
+
<IconComponentRight size={16} />
|
|
36
|
+
</span>
|
|
37
|
+
)}
|
|
38
|
+
</>
|
|
39
|
+
)}
|
|
40
|
+
</StyledButton>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default Button;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Radius } from "../../../types/radius.types";
|
|
2
|
+
|
|
3
|
+
export interface ButtonProps
|
|
4
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
6
|
+
variant?: "primary" | "outline" | "danger" | "ghost";
|
|
7
|
+
radius?: Radius;
|
|
8
|
+
isLoading?: boolean;
|
|
9
|
+
leftIcon?: string;
|
|
10
|
+
rightIcon?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Button";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
2
|
+
import Icon from "./Icon";
|
|
3
|
+
import { IconProps } from "./Icon.types";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Atoms/Icon",
|
|
7
|
+
component: Icon,
|
|
8
|
+
argTypes: {
|
|
9
|
+
name: {
|
|
10
|
+
control: "select",
|
|
11
|
+
options: [
|
|
12
|
+
"House",
|
|
13
|
+
"MagnifyingGlass",
|
|
14
|
+
"Gear",
|
|
15
|
+
"Plus",
|
|
16
|
+
"Trash",
|
|
17
|
+
"Check",
|
|
18
|
+
"Warning",
|
|
19
|
+
"Info",
|
|
20
|
+
"User",
|
|
21
|
+
"ArrowRight",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
size: { control: "select", options: ["xs", "sm", "md", "lg"] },
|
|
25
|
+
weight: {
|
|
26
|
+
control: "select",
|
|
27
|
+
options: ["thin", "light", "regular", "bold", "fill"],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
} as Meta;
|
|
31
|
+
|
|
32
|
+
const Template: StoryFn<IconProps> = (args) => <Icon {...args} />;
|
|
33
|
+
|
|
34
|
+
export const Default = Template.bind({});
|
|
35
|
+
Default.args = {
|
|
36
|
+
name: "House",
|
|
37
|
+
size: "md",
|
|
38
|
+
weight: "regular",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Large = Template.bind({});
|
|
42
|
+
Large.args = {
|
|
43
|
+
name: "Gear",
|
|
44
|
+
size: "lg",
|
|
45
|
+
weight: "bold",
|
|
46
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as Icons from "@phosphor-icons/react";
|
|
3
|
+
import { IconProps } from "./Icon.types";
|
|
4
|
+
import iconSizes from "./Icon.styles";
|
|
5
|
+
|
|
6
|
+
const Icon: React.FC<IconProps> = ({
|
|
7
|
+
name,
|
|
8
|
+
size = "md",
|
|
9
|
+
weight = "regular",
|
|
10
|
+
...props
|
|
11
|
+
}) => {
|
|
12
|
+
const IconComponent = Icons[name as keyof typeof Icons] as React.ElementType;
|
|
13
|
+
|
|
14
|
+
if (!IconComponent) {
|
|
15
|
+
console.warn(`Ícone "${name}" não encontrado.`);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return <IconComponent size={iconSizes[size]} weight={weight} {...props} />;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default Icon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Icon";
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
2
|
+
import Input from "./";
|
|
3
|
+
import { InputProps } from "./Input.types";
|
|
4
|
+
import { FiSearch } from "react-icons/fi";
|
|
5
|
+
import { semanticColors, semanticBorders } from "../../../styles/tokens";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Atoms/Input",
|
|
9
|
+
component: Input,
|
|
10
|
+
argTypes: {
|
|
11
|
+
type: { control: "select", options: ["text", "password", "email"] },
|
|
12
|
+
error: { control: "boolean" },
|
|
13
|
+
disabled: { control: "boolean" },
|
|
14
|
+
placeholder: { control: "text" },
|
|
15
|
+
},
|
|
16
|
+
} as Meta;
|
|
17
|
+
|
|
18
|
+
const Template: StoryFn<InputProps> = (args) => <Input {...args} />;
|
|
19
|
+
|
|
20
|
+
export const Default = Template.bind({});
|
|
21
|
+
Default.args = {
|
|
22
|
+
placeholder: "Placeholder",
|
|
23
|
+
type: "text",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const WithIcon = Template.bind({});
|
|
27
|
+
WithIcon.args = {
|
|
28
|
+
placeholder: "Search...",
|
|
29
|
+
icon: <FiSearch />,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const Error = Template.bind({});
|
|
33
|
+
Error.args = {
|
|
34
|
+
placeholder: "Error",
|
|
35
|
+
error: true,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Disabled = Template.bind({});
|
|
39
|
+
Disabled.args = {
|
|
40
|
+
placeholder: "Disabled",
|
|
41
|
+
disabled: true,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const WithSuccess = Template.bind({});
|
|
45
|
+
WithSuccess.args = {
|
|
46
|
+
placeholder: "Success",
|
|
47
|
+
style: { border: `1px solid ${semanticColors.success["--success-400"]}` },
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const DefaultBorder = Template.bind({});
|
|
51
|
+
DefaultBorder.args = {
|
|
52
|
+
placeholder: "Default Border",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const StrongBorder = Template.bind({});
|
|
56
|
+
StrongBorder.args = {
|
|
57
|
+
placeholder: "Strong Border",
|
|
58
|
+
style: {
|
|
59
|
+
border: `${semanticBorders["border-1"]} solid ${semanticColors.branding["--branding-400"]}`,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const ErrorBorder = Template.bind({});
|
|
64
|
+
ErrorBorder.args = {
|
|
65
|
+
placeholder: "Error Border",
|
|
66
|
+
error: true,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const HeavyBorder = Template.bind({});
|
|
70
|
+
HeavyBorder.args = {
|
|
71
|
+
placeholder: "Heavy Border",
|
|
72
|
+
style: {
|
|
73
|
+
border: `${semanticBorders["border-4"]} solid ${semanticColors.neutral["--neutral-400"]}`,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const RoundedSmall = Template.bind({});
|
|
78
|
+
RoundedSmall.args = {
|
|
79
|
+
placeholder: "Small Radius",
|
|
80
|
+
radius: "--border-1",
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const RoundedLarge = Template.bind({});
|
|
84
|
+
RoundedLarge.args = {
|
|
85
|
+
placeholder: "Large Radius",
|
|
86
|
+
radius: "--border-2",
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const RoundedFull = Template.bind({});
|
|
90
|
+
RoundedFull.args = {
|
|
91
|
+
placeholder: "Full Radius",
|
|
92
|
+
radius: "--border-4",
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const DefaultShadow = Template.bind({});
|
|
96
|
+
DefaultShadow.args = {
|
|
97
|
+
placeholder: "Default Shadow",
|
|
98
|
+
shadow: "shadow",
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const MediumShadow = Template.bind({});
|
|
102
|
+
MediumShadow.args = {
|
|
103
|
+
placeholder: "Medium Shadow",
|
|
104
|
+
shadow: "shadow-md",
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const LargeShadow = Template.bind({});
|
|
108
|
+
LargeShadow.args = {
|
|
109
|
+
placeholder: "Large Shadow",
|
|
110
|
+
shadow: "shadow-lg",
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const Small = Template.bind({});
|
|
114
|
+
Small.args = {
|
|
115
|
+
placeholder: "Small Size",
|
|
116
|
+
size: "sm",
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const Medium = Template.bind({});
|
|
120
|
+
Medium.args = {
|
|
121
|
+
placeholder: "Medium Size",
|
|
122
|
+
size: "md",
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const Large = Template.bind({});
|
|
126
|
+
Large.args = {
|
|
127
|
+
placeholder: "Large Size",
|
|
128
|
+
size: "lg",
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const Full = Template.bind({});
|
|
132
|
+
Full.args = {
|
|
133
|
+
placeholder: "Full Width",
|
|
134
|
+
size: "full",
|
|
135
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import {
|
|
3
|
+
semanticColors,
|
|
4
|
+
semanticShadows,
|
|
5
|
+
semanticSizes,
|
|
6
|
+
semanticRadiusBorders,
|
|
7
|
+
primitiveSizes,
|
|
8
|
+
} from "../../../styles/tokens";
|
|
9
|
+
|
|
10
|
+
export const Container = styled.div`
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: ${primitiveSizes["size-2"]};
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export const Label = styled.label`
|
|
17
|
+
font-size: ${primitiveSizes["size-3.5"]};
|
|
18
|
+
color: ${semanticColors.neutral["--neutral-500"]};
|
|
19
|
+
font-weight: 500;
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export const SupportText = styled.span<{ $error?: boolean }>`
|
|
23
|
+
font-size: ${primitiveSizes["size-3"]};
|
|
24
|
+
color: ${({ $error }) =>
|
|
25
|
+
$error
|
|
26
|
+
? semanticColors.danger["--danger-400"]
|
|
27
|
+
: semanticColors.neutral["--neutral-400"]};
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
export const InputWrapper = styled.div<{
|
|
31
|
+
$error?: boolean;
|
|
32
|
+
$disabled?: boolean;
|
|
33
|
+
$size?: keyof typeof semanticSizes;
|
|
34
|
+
$radius?: keyof typeof semanticRadiusBorders;
|
|
35
|
+
$shadow?: keyof typeof semanticShadows;
|
|
36
|
+
}>`
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
padding: ${primitiveSizes["size-4"]};
|
|
40
|
+
gap: ${primitiveSizes["size-2"]};
|
|
41
|
+
height: ${({ $size }) => semanticSizes[$size || "md"]};
|
|
42
|
+
border-radius: ${({ $radius }) =>
|
|
43
|
+
semanticRadiusBorders[$radius || "--border-1"]};
|
|
44
|
+
box-shadow: ${({ $shadow }) => semanticShadows[$shadow || "shadow"]};
|
|
45
|
+
border: 1px solid
|
|
46
|
+
${({ $error }) =>
|
|
47
|
+
$error
|
|
48
|
+
? semanticColors.danger["--danger-100"]
|
|
49
|
+
: semanticColors.neutral["--neutral-300"]};
|
|
50
|
+
background-color: ${({ $disabled }) =>
|
|
51
|
+
$disabled
|
|
52
|
+
? semanticColors.neutral["--neutral-100"]
|
|
53
|
+
: semanticColors.base["--background"]};
|
|
54
|
+
transition: border-color 0.2s, box-shadow 0.2s;
|
|
55
|
+
|
|
56
|
+
&:focus-within {
|
|
57
|
+
box-shadow: ${({ $shadow }) => semanticShadows[$shadow || "shadow-md"]};
|
|
58
|
+
border-color: ${({ $error }) =>
|
|
59
|
+
$error
|
|
60
|
+
? semanticColors.danger["--danger-500"]
|
|
61
|
+
: semanticColors.branding["--branding-300"]};
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
export const StyledInput = styled.input`
|
|
66
|
+
flex: 1;
|
|
67
|
+
border: none;
|
|
68
|
+
outline: none;
|
|
69
|
+
font-size: ${primitiveSizes["size-3.5"]};
|
|
70
|
+
color: ${semanticColors.neutral["--neutral-600"]};
|
|
71
|
+
|
|
72
|
+
&::placeholder {
|
|
73
|
+
color: ${semanticColors.neutral["--neutral-300"]};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&:disabled {
|
|
77
|
+
background-color: transparent;
|
|
78
|
+
cursor: not-allowed;
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
export const Icon = styled.div`
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: center;
|
|
86
|
+
color: ${semanticColors.neutral["--neutral-400"]};
|
|
87
|
+
`;
|
|
File without changes
|