w-design-system 0.0.18 → 0.0.19
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/.babelrc +8 -0
- package/.storybook/main.ts +19 -0
- package/.storybook/preview.ts +14 -0
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +0 -1
- package/dist/components/index.js.map +1 -1
- package/package.json +2 -6
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/src/assets/icon/index.ts +6 -0
- package/src/components/Banner/index.tsx +47 -0
- package/src/components/Banner/stories.tsx +31 -0
- package/src/components/Banner/styles.ts +59 -0
- package/src/components/Button/index.tsx +31 -0
- package/src/components/Button/stories.tsx +98 -0
- package/src/components/Button/styles.ts +198 -0
- package/src/components/Button/test.tsx +44 -0
- package/src/components/ButtonRadiusIcon/index.tsx +22 -0
- package/src/components/ButtonRadiusIcon/stories.tsx +47 -0
- package/src/components/ButtonRadiusIcon/styles.ts +139 -0
- package/src/components/ButtonRound/index.tsx +25 -0
- package/src/components/ButtonRound/stories.tsx +50 -0
- package/src/components/ButtonRound/styles.ts +136 -0
- package/src/components/IconWrapper/index.tsx +43 -0
- package/src/components/Modal/index.tsx +30 -0
- package/src/components/Modal/stories.tsx +53 -0
- package/src/components/Modal/styles.ts +51 -0
- package/src/components/Paragraph/index.tsx +42 -0
- package/src/components/Paragraph/stories.tsx +107 -0
- package/src/components/Tabs/index.tsx +24 -0
- package/src/components/Tabs/stories.tsx +74 -0
- package/src/components/Tabs/styles.ts +23 -0
- package/src/components/Themes/index.ts +99 -0
- package/src/components/Title/index.tsx +33 -0
- package/src/components/Title/stories.tsx +68 -0
- package/src/components/Types/index.ts +45 -0
- package/src/components/index.tsx +10 -0
- package/src/index.tsx +11 -0
- package/src/prettier.config.js +11 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/reportWebVitals.ts +16 -0
- package/src/setupTests.ts +5 -0
- package/src/src/globalStyles.ts +11 -0
- package/src/stories/Button.stories.ts +52 -0
- package/src/stories/Button.tsx +42 -0
- package/src/stories/Configure.mdx +364 -0
- package/src/stories/Header.stories.ts +33 -0
- package/src/stories/Header.tsx +56 -0
- package/src/stories/Page.stories.ts +32 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +1 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +69 -0
- package/src/utils/constanst.ts +2 -0
- package/tsconfig.json +38 -0
- package/webpack.config.js +56 -0
- package/dist/assets/icon/svg.d.ts +0 -7
- package/dist/bundle.js +0 -549
- package/dist/bundle.js.LICENSE.txt +0 -35
- /package/{dist/assets/icons → src/assets/icon}/alert.svg +0 -0
- /package/{dist/assets/icons → src/assets/icon}/close.svg +0 -0
- /package/{dist/assets/icons → src/assets/icon}/comment.svg +0 -0
- /package/{dist/assets/icons → src/assets/icon}/doc-check.svg +0 -0
- /package/{dist/assets/icons → src/assets/icon}/image.svg +0 -0
package/.babelrc
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StorybookConfig } from "@storybook/react-webpack5";
|
|
2
|
+
|
|
3
|
+
const config: StorybookConfig = {
|
|
4
|
+
stories: ['../src/components/**/stories.tsx', '../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
5
|
+
addons: [
|
|
6
|
+
"@storybook/preset-create-react-app",
|
|
7
|
+
"@storybook/addon-onboarding",
|
|
8
|
+
"@storybook/addon-links",
|
|
9
|
+
"@storybook/addon-essentials",
|
|
10
|
+
"@chromatic-com/storybook",
|
|
11
|
+
"@storybook/addon-interactions",
|
|
12
|
+
],
|
|
13
|
+
framework: {
|
|
14
|
+
name: "@storybook/react-webpack5",
|
|
15
|
+
options: {},
|
|
16
|
+
},
|
|
17
|
+
staticDirs: ["../public"],
|
|
18
|
+
};
|
|
19
|
+
export default config;
|
|
@@ -8,5 +8,4 @@ export { Paragraph } from './Paragraph/index';
|
|
|
8
8
|
export { Tabs } from './Tabs/index';
|
|
9
9
|
export { theme } from './Themes/index';
|
|
10
10
|
export { Title } from './Title/index';
|
|
11
|
-
export { docCheckSVG, alertSVG, commentSVG, imageSVG, closeSVG } from '../assets/icon/index';
|
|
12
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/components/index.js
CHANGED
|
@@ -8,5 +8,4 @@ export { Paragraph } from './Paragraph/index';
|
|
|
8
8
|
export { Tabs } from './Tabs/index';
|
|
9
9
|
export { theme } from './Themes/index';
|
|
10
10
|
export { Title } from './Title/index';
|
|
11
|
-
export { docCheckSVG, alertSVG, commentSVG, imageSVG, closeSVG } from '../assets/icon/index';
|
|
12
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-design-system",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"files": [
|
|
6
|
-
"dist",
|
|
7
|
-
"README.md"
|
|
8
|
-
],
|
|
9
5
|
"dependencies": {
|
|
10
6
|
"@svgr/webpack": "^8.1.0",
|
|
11
7
|
"@testing-library/jest-dom": "^5.17.0",
|
|
@@ -28,7 +24,7 @@
|
|
|
28
24
|
"scripts": {
|
|
29
25
|
"start": "react-scripts start",
|
|
30
26
|
"copy-assets": "cpx 'src/assets/icon/**/*' dist/assets/icon",
|
|
31
|
-
"build": "
|
|
27
|
+
"build": "tsc -p . && yarn copy-assets",
|
|
32
28
|
"test": "react-scripts test",
|
|
33
29
|
"eject": "react-scripts eject",
|
|
34
30
|
"storybook": "storybook dev -p 6006",
|
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<meta name="theme-color" content="#000000" />
|
|
8
|
+
<meta
|
|
9
|
+
name="description"
|
|
10
|
+
content="Web site created using create-react-app"
|
|
11
|
+
/>
|
|
12
|
+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
13
|
+
<!--
|
|
14
|
+
manifest.json provides metadata used when your web app is installed on a
|
|
15
|
+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
16
|
+
-->
|
|
17
|
+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
18
|
+
<!--
|
|
19
|
+
Notice the use of %PUBLIC_URL% in the tags above.
|
|
20
|
+
It will be replaced with the URL of the `public` folder during the build.
|
|
21
|
+
Only files inside the `public` folder can be referenced from the HTML.
|
|
22
|
+
|
|
23
|
+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
24
|
+
work correctly both with client-side routing and a non-root public URL.
|
|
25
|
+
Learn how to configure a non-root public URL by running `npm run build`.
|
|
26
|
+
-->
|
|
27
|
+
<title>React App</title>
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
31
|
+
<div id="root"></div>
|
|
32
|
+
<!--
|
|
33
|
+
This HTML file is a template.
|
|
34
|
+
If you open it directly in the browser, you will see an empty page.
|
|
35
|
+
|
|
36
|
+
You can add webfonts, meta tags, or analytics to this file.
|
|
37
|
+
The build step will place the bundled scripts into the <body> tag.
|
|
38
|
+
|
|
39
|
+
To begin the development, run `npm start` or `yarn start`.
|
|
40
|
+
To create a production bundle, use `npm run build` or `yarn build`.
|
|
41
|
+
-->
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "React App",
|
|
3
|
+
"name": "Create React App Sample",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "favicon.ico",
|
|
7
|
+
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
+
"type": "image/x-icon"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"src": "logo192.png",
|
|
12
|
+
"type": "image/png",
|
|
13
|
+
"sizes": "192x192"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"src": "logo512.png",
|
|
17
|
+
"type": "image/png",
|
|
18
|
+
"sizes": "512x512"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"start_url": ".",
|
|
22
|
+
"display": "standalone",
|
|
23
|
+
"theme_color": "#000000",
|
|
24
|
+
"background_color": "#ffffff"
|
|
25
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { default as docCheckSVG } from './doc-check.svg'
|
|
2
|
+
import { default as alertSVG } from './alert.svg'
|
|
3
|
+
import { default as commentSVG } from './comment.svg'
|
|
4
|
+
import { default as imageSVG } from './image.svg'
|
|
5
|
+
import { default as closeSVG } from './close.svg'
|
|
6
|
+
export { docCheckSVG, alertSVG, commentSVG, imageSVG, closeSVG }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { BannerStyled } from './styles'
|
|
3
|
+
import { BannerTypes } from '../Types'
|
|
4
|
+
import { docCheckSVG, alertSVG, commentSVG, closeSVG } from '../../assets/icon'
|
|
5
|
+
import { IconWrapper } from '../IconWrapper'
|
|
6
|
+
import { Paragraph } from '../Paragraph'
|
|
7
|
+
import { theme } from '../Themes'
|
|
8
|
+
const {
|
|
9
|
+
colors: { cyan40, mint40, honey40, red40, shade40, shade30 },
|
|
10
|
+
} = theme
|
|
11
|
+
export const Banner: React.FC<BannerTypes> = ({ title, onClick, variant, subTitle }) => {
|
|
12
|
+
const searchIcon = () => {
|
|
13
|
+
switch (variant) {
|
|
14
|
+
case 'notice':
|
|
15
|
+
return { icon: commentSVG, color: cyan40 }
|
|
16
|
+
case 'success':
|
|
17
|
+
return { icon: docCheckSVG, color: mint40 }
|
|
18
|
+
case 'warning':
|
|
19
|
+
return { icon: alertSVG, color: honey40 }
|
|
20
|
+
case 'danger':
|
|
21
|
+
return { icon: alertSVG, color: red40 }
|
|
22
|
+
default:
|
|
23
|
+
return { icon: commentSVG, color: cyan40 }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { icon, color } = searchIcon()
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<BannerStyled variant={variant}>
|
|
31
|
+
<div className={'bannerWrapper'}>
|
|
32
|
+
<IconWrapper src={icon} className={'buttonRadiusWrapperIcon'} />
|
|
33
|
+
<span>
|
|
34
|
+
<Paragraph size={'medium'} color={color}>
|
|
35
|
+
{title}
|
|
36
|
+
</Paragraph>
|
|
37
|
+
{subTitle && (
|
|
38
|
+
<Paragraph size={'small'} color={shade40}>
|
|
39
|
+
{subTitle}
|
|
40
|
+
</Paragraph>
|
|
41
|
+
)}
|
|
42
|
+
</span>
|
|
43
|
+
</div>
|
|
44
|
+
<IconWrapper src={closeSVG} width={'14px'} height={'14px'} color={shade30} onClick={onClick} />
|
|
45
|
+
</BannerStyled>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
import { VARIANTS_TYPES_BANNER } from '../../utils/constanst'
|
|
3
|
+
|
|
4
|
+
import { Banner } from './index'
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Banner> = {
|
|
7
|
+
title: 'Components/Banner',
|
|
8
|
+
component: Banner,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: {
|
|
11
|
+
variant: {
|
|
12
|
+
control: {
|
|
13
|
+
type: 'select',
|
|
14
|
+
options: VARIANTS_TYPES_BANNER,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
onClick: { action: 'clicked' },
|
|
19
|
+
},
|
|
20
|
+
} satisfies Meta<typeof Banner>
|
|
21
|
+
|
|
22
|
+
export default meta
|
|
23
|
+
type Story = StoryObj<typeof Banner>
|
|
24
|
+
|
|
25
|
+
export const Playground: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
variant: 'success',
|
|
28
|
+
title: 'Sucesso!',
|
|
29
|
+
subTitle: 'Mensagem de sucesso.',
|
|
30
|
+
},
|
|
31
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components'
|
|
2
|
+
import { theme } from '../Themes'
|
|
3
|
+
|
|
4
|
+
import { BannerTypes } from '../Types'
|
|
5
|
+
|
|
6
|
+
const { colors } = theme
|
|
7
|
+
const buttonRadiusWrapperIconStyles = (color: string) => css`
|
|
8
|
+
.buttonRadiusWrapperIcon {
|
|
9
|
+
svg {
|
|
10
|
+
fill: ${color};
|
|
11
|
+
path {
|
|
12
|
+
fill: ${color};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`
|
|
17
|
+
const colorScheme = {
|
|
18
|
+
notice: css`
|
|
19
|
+
background: ${colors.cyan10};
|
|
20
|
+
border-color: ${colors.cyan40};
|
|
21
|
+
${buttonRadiusWrapperIconStyles(colors.cyan40)};
|
|
22
|
+
`,
|
|
23
|
+
danger: css`
|
|
24
|
+
background: ${colors.red10};
|
|
25
|
+
border-color: ${colors.red40};
|
|
26
|
+
${buttonRadiusWrapperIconStyles(colors.red40)};
|
|
27
|
+
`,
|
|
28
|
+
warning: css`
|
|
29
|
+
background: ${colors.honey10};
|
|
30
|
+
border-color: ${colors.honey40};
|
|
31
|
+
${buttonRadiusWrapperIconStyles(colors.honey40)};
|
|
32
|
+
`,
|
|
33
|
+
success: css`
|
|
34
|
+
background: ${colors.mint10};
|
|
35
|
+
border-color: ${colors.mint40};
|
|
36
|
+
${buttonRadiusWrapperIconStyles(colors.mint40)};
|
|
37
|
+
`,
|
|
38
|
+
} as const
|
|
39
|
+
|
|
40
|
+
export const BannerStyled = styled.div<BannerTypes>`
|
|
41
|
+
display: flex;
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
justify-content: space-between;
|
|
44
|
+
align-items: center;
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: 100%;
|
|
47
|
+
max-height: 100px;
|
|
48
|
+
min-height: 56px;
|
|
49
|
+
padding: 12px 24px;
|
|
50
|
+
border-radius: 16px;
|
|
51
|
+
border: 1px dashed;
|
|
52
|
+
${({ variant = 'notice' }) => colorScheme[variant]};
|
|
53
|
+
|
|
54
|
+
.bannerWrapper {
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: 12px;
|
|
58
|
+
}
|
|
59
|
+
`
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { IconWrapper } from '../IconWrapper'
|
|
3
|
+
import { ButtonStyled } from './styles'
|
|
4
|
+
import { ButtonTypes } from '../Types'
|
|
5
|
+
|
|
6
|
+
export const Button: React.FC<ButtonTypes> = ({
|
|
7
|
+
variant = 'primary',
|
|
8
|
+
children,
|
|
9
|
+
disabled = false,
|
|
10
|
+
icon,
|
|
11
|
+
radius,
|
|
12
|
+
outline,
|
|
13
|
+
halfLeft,
|
|
14
|
+
halfRight,
|
|
15
|
+
fullWidth,
|
|
16
|
+
...props
|
|
17
|
+
}) => (
|
|
18
|
+
<ButtonStyled
|
|
19
|
+
variant={variant}
|
|
20
|
+
disabled={disabled}
|
|
21
|
+
radius={radius}
|
|
22
|
+
outline={outline}
|
|
23
|
+
halfLeft={halfLeft}
|
|
24
|
+
halfRight={halfRight}
|
|
25
|
+
fullWidth={fullWidth}
|
|
26
|
+
{...props}
|
|
27
|
+
>
|
|
28
|
+
{icon && <IconWrapper src={icon} color={'white'} className={'buttonRadiusWrapperIcon'} />}
|
|
29
|
+
{children}
|
|
30
|
+
</ButtonStyled>
|
|
31
|
+
)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
import exampleIcon from '../../assets/icon/image.svg'
|
|
3
|
+
import { Button } from './index'
|
|
4
|
+
import { VARIANTS_TYPES } from '../../utils/constanst'
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Button> = {
|
|
7
|
+
title: 'Components/Button',
|
|
8
|
+
component: Button,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: {
|
|
11
|
+
variant: {
|
|
12
|
+
control: {
|
|
13
|
+
type: 'select',
|
|
14
|
+
options: VARIANTS_TYPES,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
disabled: {
|
|
18
|
+
control: 'boolean',
|
|
19
|
+
},
|
|
20
|
+
icon: {
|
|
21
|
+
control: 'object',
|
|
22
|
+
options: [exampleIcon],
|
|
23
|
+
description: exampleIcon,
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
onClick: { action: 'clicked' },
|
|
27
|
+
},
|
|
28
|
+
} satisfies Meta<typeof Button>
|
|
29
|
+
|
|
30
|
+
export default meta
|
|
31
|
+
type Story = StoryObj<typeof Button>
|
|
32
|
+
|
|
33
|
+
export const Playground: Story = {
|
|
34
|
+
args: {
|
|
35
|
+
variant: 'primary',
|
|
36
|
+
children: 'ButtonPlayground',
|
|
37
|
+
disabled: false,
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const ButtonDefault: Story = {
|
|
42
|
+
args: {
|
|
43
|
+
variant: 'secondary',
|
|
44
|
+
children: 'ButtonPlayground',
|
|
45
|
+
disabled: false,
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const ButtonOutilne: Story = {
|
|
50
|
+
args: {
|
|
51
|
+
variant: 'secondary',
|
|
52
|
+
children: 'ButtonPlayground',
|
|
53
|
+
disabled: false,
|
|
54
|
+
outline: true,
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
export const ButtonRadius: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
variant: 'success',
|
|
60
|
+
children: 'ButtonPlayground',
|
|
61
|
+
disabled: false,
|
|
62
|
+
radius: true,
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const ButtonDisabled: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
variant: 'danger',
|
|
69
|
+
children: 'ButtonPlayground',
|
|
70
|
+
disabled: true,
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const ButtonIcon: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
variant: 'primary',
|
|
77
|
+
children: 'ButtonPlayground',
|
|
78
|
+
icon: exampleIcon,
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const ButtonIconHalfRightOutiline: Story = {
|
|
83
|
+
args: {
|
|
84
|
+
variant: 'success',
|
|
85
|
+
children: 'ButtonPlayground',
|
|
86
|
+
icon: exampleIcon,
|
|
87
|
+
halfRight: true,
|
|
88
|
+
outline: true,
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
export const ButtonIconHalfLeft: Story = {
|
|
92
|
+
args: {
|
|
93
|
+
variant: 'success',
|
|
94
|
+
children: 'ButtonPlayground',
|
|
95
|
+
icon: exampleIcon,
|
|
96
|
+
halfLeft: true,
|
|
97
|
+
},
|
|
98
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components'
|
|
2
|
+
import { theme } from '../Themes'
|
|
3
|
+
import { ButtonTypes } from '../Types'
|
|
4
|
+
|
|
5
|
+
const { colors } = theme
|
|
6
|
+
const buttonRadiusWrapperIconStyles = (color: string) => css`
|
|
7
|
+
.buttonRadiusWrapperIcon {
|
|
8
|
+
margin-top: 4px;
|
|
9
|
+
svg {
|
|
10
|
+
fill: ${color};
|
|
11
|
+
path {
|
|
12
|
+
fill: ${color};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`
|
|
17
|
+
const colorScheme = {
|
|
18
|
+
primary: css`
|
|
19
|
+
background: ${colors.cyan50};
|
|
20
|
+
&:hover {
|
|
21
|
+
background-color: ${colors.cyan40};
|
|
22
|
+
}
|
|
23
|
+
&:active {
|
|
24
|
+
background-color: ${colors.cyan50};
|
|
25
|
+
}
|
|
26
|
+
`,
|
|
27
|
+
secondary: css`
|
|
28
|
+
background: ${colors.cyan30};
|
|
29
|
+
&:hover {
|
|
30
|
+
background-color: ${colors.cyan40};
|
|
31
|
+
}
|
|
32
|
+
&:active {
|
|
33
|
+
background-color: ${colors.cyan30};
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
danger: css`
|
|
37
|
+
background: ${colors.red40};
|
|
38
|
+
&:hover {
|
|
39
|
+
background-color: ${colors.red30};
|
|
40
|
+
}
|
|
41
|
+
&:active {
|
|
42
|
+
background-color: ${colors.red40};
|
|
43
|
+
}
|
|
44
|
+
`,
|
|
45
|
+
warning: css`
|
|
46
|
+
background: ${colors.honey10};
|
|
47
|
+
color: ${colors.honey30};
|
|
48
|
+
&:hover {
|
|
49
|
+
background-color: ${colors.honey20};
|
|
50
|
+
}
|
|
51
|
+
&:active {
|
|
52
|
+
background-color: ${colors.honey10};
|
|
53
|
+
}
|
|
54
|
+
${buttonRadiusWrapperIconStyles(colors.honey30)};
|
|
55
|
+
`,
|
|
56
|
+
success: css`
|
|
57
|
+
background: ${colors.mint40};
|
|
58
|
+
&:hover {
|
|
59
|
+
background-color: ${colors.mint30};
|
|
60
|
+
}
|
|
61
|
+
&:active {
|
|
62
|
+
background-color: ${colors.mint40};
|
|
63
|
+
}
|
|
64
|
+
`,
|
|
65
|
+
gray: css`
|
|
66
|
+
background: ${colors.shade10};
|
|
67
|
+
color: ${colors.shade40};
|
|
68
|
+
&:hover {
|
|
69
|
+
background-color: ${colors.shade20};
|
|
70
|
+
}
|
|
71
|
+
&:active {
|
|
72
|
+
background-color: ${colors.shade10};
|
|
73
|
+
}
|
|
74
|
+
${buttonRadiusWrapperIconStyles(colors.shade40)};
|
|
75
|
+
`,
|
|
76
|
+
yellow: css`
|
|
77
|
+
background: ${colors.yellow10};
|
|
78
|
+
color: ${colors.yellow30};
|
|
79
|
+
&:hover {
|
|
80
|
+
background-color: ${colors.yellow20};
|
|
81
|
+
}
|
|
82
|
+
&:active {
|
|
83
|
+
background-color: ${colors.yellow10};
|
|
84
|
+
}
|
|
85
|
+
${buttonRadiusWrapperIconStyles(colors.yellow30)};
|
|
86
|
+
`,
|
|
87
|
+
} as const
|
|
88
|
+
|
|
89
|
+
const colorSchemeOutilne = {
|
|
90
|
+
primary: css`
|
|
91
|
+
color: ${colors.cyan50};
|
|
92
|
+
border: 2px solid ${colors.cyan50};
|
|
93
|
+
&:hover {
|
|
94
|
+
background-color: ${colors.cyan10};
|
|
95
|
+
}
|
|
96
|
+
&:active {
|
|
97
|
+
background-color: ${colors.cyan10};
|
|
98
|
+
}
|
|
99
|
+
${buttonRadiusWrapperIconStyles(colors.cyan50)};
|
|
100
|
+
`,
|
|
101
|
+
secondary: css`
|
|
102
|
+
color: ${colors.cyan40};
|
|
103
|
+
border: 2px solid ${colors.cyan40};
|
|
104
|
+
&:hover {
|
|
105
|
+
background-color: ${colors.cyan10};
|
|
106
|
+
}
|
|
107
|
+
&:active {
|
|
108
|
+
background-color: ${colors.cyan10};
|
|
109
|
+
}
|
|
110
|
+
${buttonRadiusWrapperIconStyles(colors.cyan40)};
|
|
111
|
+
`,
|
|
112
|
+
danger: css`
|
|
113
|
+
color: ${colors.red40};
|
|
114
|
+
border: 2px solid ${colors.red40};
|
|
115
|
+
&:hover {
|
|
116
|
+
background-color: ${colors.red10};
|
|
117
|
+
}
|
|
118
|
+
&:active {
|
|
119
|
+
background-color: ${colors.red10};
|
|
120
|
+
}
|
|
121
|
+
${buttonRadiusWrapperIconStyles(colors.red40)};
|
|
122
|
+
`,
|
|
123
|
+
warning: css`
|
|
124
|
+
color: ${colors.honey40};
|
|
125
|
+
border: 2px solid ${colors.honey40};
|
|
126
|
+
&:hover {
|
|
127
|
+
background-color: ${colors.honey10};
|
|
128
|
+
}
|
|
129
|
+
&:active {
|
|
130
|
+
background-color: ${colors.honey10};
|
|
131
|
+
}
|
|
132
|
+
${buttonRadiusWrapperIconStyles(colors.honey40)};
|
|
133
|
+
`,
|
|
134
|
+
success: css`
|
|
135
|
+
color: ${colors.mint40};
|
|
136
|
+
border: 2px solid ${colors.mint40};
|
|
137
|
+
&:hover {
|
|
138
|
+
background-color: ${colors.mint10};
|
|
139
|
+
}
|
|
140
|
+
&:active {
|
|
141
|
+
background-color: ${colors.mint10};
|
|
142
|
+
}
|
|
143
|
+
${buttonRadiusWrapperIconStyles(colors.mint40)};
|
|
144
|
+
`,
|
|
145
|
+
gray: css`
|
|
146
|
+
color: ${colors.shade40};
|
|
147
|
+
border: 2px solid ${colors.shade40};
|
|
148
|
+
&:hover {
|
|
149
|
+
background-color: ${colors.shade20};
|
|
150
|
+
}
|
|
151
|
+
&:active {
|
|
152
|
+
background-color: ${colors.shade10};
|
|
153
|
+
}
|
|
154
|
+
${buttonRadiusWrapperIconStyles(colors.shade40)};
|
|
155
|
+
`,
|
|
156
|
+
yellow: css`
|
|
157
|
+
color: ${colors.yellow30};
|
|
158
|
+
border: 2px solid ${colors.yellow30};
|
|
159
|
+
&:hover {
|
|
160
|
+
background-color: ${colors.yellow10};
|
|
161
|
+
}
|
|
162
|
+
&:active {
|
|
163
|
+
background-color: ${colors.yellow10};
|
|
164
|
+
}
|
|
165
|
+
${buttonRadiusWrapperIconStyles(colors.yellow30)};
|
|
166
|
+
`,
|
|
167
|
+
} as const
|
|
168
|
+
|
|
169
|
+
export const ButtonStyled = styled.button<ButtonTypes>`
|
|
170
|
+
display: inline-flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
justify-content: center;
|
|
173
|
+
box-sizing: border-box;
|
|
174
|
+
height: 48px;
|
|
175
|
+
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
|
|
176
|
+
padding: 12px 24px;
|
|
177
|
+
font-size: 16px;
|
|
178
|
+
font-weight: 600;
|
|
179
|
+
line-height: 140%;
|
|
180
|
+
border: none;
|
|
181
|
+
border-radius: ${({ radius }) => (radius ? '24px' : '5px')};
|
|
182
|
+
font-family: 'Nunito Sans', sans-serif;
|
|
183
|
+
transition:
|
|
184
|
+
background-color 0.3s,
|
|
185
|
+
opacity 0.3s;
|
|
186
|
+
color: white;
|
|
187
|
+
gap: 12px;
|
|
188
|
+
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
|
|
189
|
+
opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};
|
|
190
|
+
${({ variant = 'primary', outline }) => (!outline ? colorScheme[variant] : colorSchemeOutilne[variant])};
|
|
191
|
+
background: ${({ outline }) => outline && 'white'};
|
|
192
|
+
border-radius: ${({ halfLeft, halfRight, radius }) =>
|
|
193
|
+
!halfLeft && !halfRight ? (radius ? '24px' : '5px') : halfLeft ? '24px 0 0 24px' : '0 24px 24px 0'};
|
|
194
|
+
|
|
195
|
+
.buttonRadiusWrapperIcon {
|
|
196
|
+
margin-top: 4px;
|
|
197
|
+
}
|
|
198
|
+
`
|