@gyramais/gyra-design 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.
Files changed (147) hide show
  1. package/.eslintrc.json +14 -0
  2. package/.storybook/main.ts +20 -0
  3. package/.storybook/preview.ts +45 -0
  4. package/README.md +31 -0
  5. package/dist/index.js +2 -0
  6. package/package.json +83 -0
  7. package/postcss.config.js +6 -0
  8. package/rollup.config.js +104 -0
  9. package/scripts/build-utils.js +16 -0
  10. package/src/components/Avatar/Avatar.stories.tsx +26 -0
  11. package/src/components/Avatar/Avatar.tsx +36 -0
  12. package/src/components/Avatar/index.css +9 -0
  13. package/src/components/Avatar/index.ts +1 -0
  14. package/src/components/Button/Button.stories.tsx +99 -0
  15. package/src/components/Button/Button.tsx +71 -0
  16. package/src/components/Button/index.css +168 -0
  17. package/src/components/Button/index.ts +1 -0
  18. package/src/components/Card/Card.stories.tsx +126 -0
  19. package/src/components/Card/Card.tsx +111 -0
  20. package/src/components/Card/index.css +96 -0
  21. package/src/components/Card/index.ts +1 -0
  22. package/src/components/Chart/Chart.stories.tsx +61 -0
  23. package/src/components/Chart/Chart.tsx +192 -0
  24. package/src/components/Chart/index.css +15 -0
  25. package/src/components/Chart/index.ts +1 -0
  26. package/src/components/Checkbox/Checkbox.stories.tsx +46 -0
  27. package/src/components/Checkbox/Checkbox.tsx +46 -0
  28. package/src/components/Checkbox/index.css +29 -0
  29. package/src/components/Checkbox/index.ts +1 -0
  30. package/src/components/Col/Col.stories.tsx +33 -0
  31. package/src/components/Col/Col.tsx +45 -0
  32. package/src/components/Col/index.css +57 -0
  33. package/src/components/Col/index.ts +1 -0
  34. package/src/components/Collapse/Collapse.stories.tsx +86 -0
  35. package/src/components/Collapse/Collapse.tsx +34 -0
  36. package/src/components/Collapse/CollapseIcon.tsx +33 -0
  37. package/src/components/Collapse/index.css +14 -0
  38. package/src/components/Collapse/index.ts +2 -0
  39. package/src/components/Divider/Divider.stories.tsx +45 -0
  40. package/src/components/Divider/Divider.tsx +42 -0
  41. package/src/components/Divider/index.css +20 -0
  42. package/src/components/Divider/index.ts +1 -0
  43. package/src/components/Drawer/Drawer.stories.tsx +51 -0
  44. package/src/components/Drawer/Drawer.tsx +40 -0
  45. package/src/components/Drawer/index.css +15 -0
  46. package/src/components/Drawer/index.ts +1 -0
  47. package/src/components/DropdownMenu/DropdownMenu.stories.tsx +66 -0
  48. package/src/components/DropdownMenu/DropdownMenu.tsx +91 -0
  49. package/src/components/DropdownMenu/index.css +18 -0
  50. package/src/components/DropdownMenu/index.ts +1 -0
  51. package/src/components/Filter/Filter.stories.tsx +94 -0
  52. package/src/components/Filter/Filter.tsx +213 -0
  53. package/src/components/Filter/index.css +81 -0
  54. package/src/components/Filter/index.ts +1 -0
  55. package/src/components/Form/Form.tsx +11 -0
  56. package/src/components/Form/Item.tsx +33 -0
  57. package/src/components/Form/index.css +4 -0
  58. package/src/components/Form/index.ts +1 -0
  59. package/src/components/HoverCard/HoverCard.stories.tsx +48 -0
  60. package/src/components/HoverCard/HoverCard.tsx +54 -0
  61. package/src/components/HoverCard/index.css +15 -0
  62. package/src/components/HoverCard/index.ts +1 -0
  63. package/src/components/Icon/Icon.stories.tsx +23 -0
  64. package/src/components/Icon/Icon.tsx +36 -0
  65. package/src/components/Icon/index.css +3 -0
  66. package/src/components/Icon/index.ts +1 -0
  67. package/src/components/IconDisplay/IconDisplay.stories.tsx +27 -0
  68. package/src/components/IconDisplay/IconDisplay.tsx +29 -0
  69. package/src/components/IconDisplay/index.css +18 -0
  70. package/src/components/IconDisplay/index.ts +1 -0
  71. package/src/components/Information/Information.stories.tsx +25 -0
  72. package/src/components/Information/Information.tsx +50 -0
  73. package/src/components/Information/index.css +34 -0
  74. package/src/components/Information/index.ts +1 -0
  75. package/src/components/Input/Input.stories.tsx +38 -0
  76. package/src/components/Input/Input.tsx +91 -0
  77. package/src/components/Input/index.css +74 -0
  78. package/src/components/Input/index.ts +1 -0
  79. package/src/components/Label/Label.tsx +26 -0
  80. package/src/components/Label/index.ts +1 -0
  81. package/src/components/Layout/Content.tsx +29 -0
  82. package/src/components/Layout/Header.tsx +29 -0
  83. package/src/components/Layout/Layout.stories.tsx +54 -0
  84. package/src/components/Layout/Layout.tsx +32 -0
  85. package/src/components/Layout/Sider.tsx +29 -0
  86. package/src/components/Layout/index.css +37 -0
  87. package/src/components/Layout/index.ts +4 -0
  88. package/src/components/List/List.stories.tsx +58 -0
  89. package/src/components/List/List.tsx +98 -0
  90. package/src/components/List/index.css +54 -0
  91. package/src/components/List/index.ts +1 -0
  92. package/src/components/Loading/Loading.stories.tsx +23 -0
  93. package/src/components/Loading/Loading.tsx +51 -0
  94. package/src/components/Loading/index.css +36 -0
  95. package/src/components/Loading/index.ts +1 -0
  96. package/src/components/Logo/Logo.stories.tsx +34 -0
  97. package/src/components/Logo/Logo.tsx +39 -0
  98. package/src/components/Logo/index.css +9 -0
  99. package/src/components/Logo/index.ts +1 -0
  100. package/src/components/Menubar/Menubar.stories.tsx +55 -0
  101. package/src/components/Menubar/Menubar.tsx +118 -0
  102. package/src/components/Menubar/index.css +96 -0
  103. package/src/components/Menubar/index.ts +1 -0
  104. package/src/components/Row/Row.stories.tsx +33 -0
  105. package/src/components/Row/Row.tsx +48 -0
  106. package/src/components/Row/index.css +116 -0
  107. package/src/components/Row/index.ts +1 -0
  108. package/src/components/Switch/Switch.stories.tsx +39 -0
  109. package/src/components/Switch/Switch.tsx +36 -0
  110. package/src/components/Switch/index.css +37 -0
  111. package/src/components/Switch/index.ts +1 -0
  112. package/src/components/Table/Table.stories.tsx +85 -0
  113. package/src/components/Table/Table.tsx +123 -0
  114. package/src/components/Table/index.css +74 -0
  115. package/src/components/Table/index.ts +1 -0
  116. package/src/components/Tabs/Tabs.stories.tsx +49 -0
  117. package/src/components/Tabs/Tabs.tsx +76 -0
  118. package/src/components/Tabs/index.css +89 -0
  119. package/src/components/Tabs/index.ts +1 -0
  120. package/src/components/Tag/Tag.stories.tsx +41 -0
  121. package/src/components/Tag/Tag.tsx +39 -0
  122. package/src/components/Tag/index.css +31 -0
  123. package/src/components/Tag/index.ts +1 -0
  124. package/src/components/Text/Text.stories.tsx +41 -0
  125. package/src/components/Toast/Toast.stories.tsx +47 -0
  126. package/src/components/Toast/Toast.tsx +13 -0
  127. package/src/components/Toast/index.ts +1 -0
  128. package/src/components/Tooltip/Tooltip.stories.tsx +44 -0
  129. package/src/components/Tooltip/Tooltip.tsx +60 -0
  130. package/src/components/Tooltip/index.css +15 -0
  131. package/src/components/Tooltip/index.ts +1 -0
  132. package/src/index.css +176 -0
  133. package/src/index.ts +38 -0
  134. package/src/shadcn/checkbox.tsx +28 -0
  135. package/src/shadcn/dropdown-menu.tsx +200 -0
  136. package/src/shadcn/form.tsx +178 -0
  137. package/src/shadcn/hover-card.tsx +31 -0
  138. package/src/shadcn/label.tsx +26 -0
  139. package/src/shadcn/lib/utils.ts +6 -0
  140. package/src/shadcn/menubar.tsx +248 -0
  141. package/src/shadcn/switch.tsx +25 -0
  142. package/src/shadcn/table.tsx +117 -0
  143. package/src/shadcn/tabs.tsx +55 -0
  144. package/src/shadcn/tooltip.tsx +30 -0
  145. package/src/theme.ts +123 -0
  146. package/tailwind.config.js +9 -0
  147. package/tsconfig.json +32 -0
package/.eslintrc.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "next/core-web-vitals",
3
+ "rules": {
4
+ "indent": ["error", 2, { "SwitchCase": 1 }],
5
+ "keyword-spacing": ["error", { "after": true, "before": true }],
6
+ "comma-dangle": ["error", "always-multiline"],
7
+ "semi": ["error", "always"],
8
+ "quotes": ["error", "single"],
9
+ "arrow-spacing": ["error", { "before": true, "after": true }],
10
+ "space-in-parens": ["error", "never"],
11
+ "no-trailing-spaces": ["error"],
12
+ "no-multi-spaces": ["error"]
13
+ }
14
+ }
@@ -0,0 +1,20 @@
1
+ import type { StorybookConfig } from "@storybook/react-vite";
2
+
3
+ const config: StorybookConfig = {
4
+ stories: ["../src/**/*.stories.tsx"],
5
+ addons: [
6
+ "@storybook/addon-links",
7
+ "@storybook/addon-essentials",
8
+ "@storybook/addon-onboarding",
9
+ "@storybook/addon-interactions",
10
+ ],
11
+ framework: {
12
+ name: "@storybook/react-vite",
13
+ options: {},
14
+ },
15
+ docs: {
16
+ autodocs: true,
17
+ defaultName: 'Overview',
18
+ },
19
+ };
20
+ export default config;
@@ -0,0 +1,45 @@
1
+ import '../src/index.css'
2
+ import 'react-toastify/dist/ReactToastify.css';
3
+ import 'react-modern-drawer/dist/index.css'
4
+
5
+ import type { Preview } from "@storybook/react";
6
+
7
+ const preview: Preview = {
8
+ parameters: {
9
+ layout: 'centered',
10
+ backgrounds: {
11
+ default: 'grey',
12
+ values: [{
13
+ name: 'black',
14
+ value: '#000000',
15
+ }, {
16
+ name: 'grey',
17
+ value: '#eeecec',
18
+ }, {
19
+ name: 'white',
20
+ value: '#ffffff',
21
+ }],
22
+ },
23
+ actions: { argTypesRegex: "^on[A-Z].*" },
24
+ controls: {
25
+ matchers: {
26
+ color: /(background|color)$/i,
27
+ date: /Date$/i,
28
+ },
29
+ exclude: [
30
+ 'children',
31
+ 'onClick',
32
+ ]
33
+ },
34
+ docs: {
35
+ controls: {
36
+ exclude: [
37
+ 'children',
38
+ 'onClick',
39
+ ]
40
+ },
41
+ },
42
+ },
43
+ };
44
+
45
+ export default preview;
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # gyra-design
2
+
3
+ Pacote de componentes da Gyramais com o intuito de padronizar e afunilar todos os componentes de projetos.
4
+ ## Stack utilizada
5
+
6
+ - **Componentes:** Typescript, React, TailwindCSS
7
+ - **Documentação:** Storybook
8
+ - **Bundler:** Rollup
9
+
10
+ ## Funcionalidades
11
+
12
+ - Tema personalizável
13
+ - Componentes padrão da Gyramais
14
+
15
+ ## Comandos
16
+
17
+ Baixe o projeto em gyramais/gyra-design
18
+ ```bash
19
+ npm install
20
+ npm run storybook
21
+ ```
22
+
23
+ Para realizar o build do pacote completo
24
+ ```
25
+ npm run build
26
+ ```
27
+
28
+ Para realizar o build de um componente específico (ex: Button)
29
+ ```
30
+ npm run build --component=Button
31
+ ```
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use client";var t=function(t){var e=t.replace("#","");return(299*parseInt(e.substr(0,2),16)+587*parseInt(e.substr(2,2),16)+114*parseInt(e.substr(4,2),16))/1e3<=128},e=function(e){return t(e)?"#ffffff":"#2b2b2b"},o=function(t,e){t.length>6&&(t=t.substring(1,t.length));var o=parseInt(t,16),r=Math.abs((o>>16&255)+e);r>255&&(r-=r-255);var n=Math.abs((o>>8&255)+e);n>255&&(n-=n-255);var c=Math.abs((255&o)+e);return c>255&&(c-=c-255),"#"+"".concat(Number(r<0||isNaN(r))?0:(r>255?255:r).toString(16)).padStart(2,"0")+"".concat(Number(n<0||isNaN(n))?0:(n>255?255:n).toString(16)).padStart(2,"0")+"".concat(Number(c<0||isNaN(c))?0:(c>255?255:c).toString(16)).padStart(2,"0")},r={setTheme:function(r){var n=r.colors,c=r.images,u=n.backgroundColor,l=n.primaryButton,a=n.secondaryButton,s=n.linkButton;if(u&&(document.documentElement.style.setProperty("--background-color",u),document.documentElement.style.setProperty("--background-text-color",e(u))),l){document.documentElement.style.setProperty("--primary-button-color",l),document.documentElement.style.setProperty("--primary-button-text-color",e(l)),document.documentElement.style.setProperty("--dark-button-color","".concat(l,"66")),document.documentElement.style.setProperty("--dark-button-text-color",e(l));for(var m=t(l),d=0;d<5;d+=1){var y=o(l,35*d*(m?1:-1));document.documentElement.style.setProperty("--primary-button-color-".concat(d,"00"),y)}}a&&(document.documentElement.style.setProperty("--secondary-button-color",a),document.documentElement.style.setProperty("--secondary-button-text-color",e(a))),s&&document.documentElement.style.setProperty("--link-button-color",s);var p=c.darkLogoUrl,b=c.whiteLogoUrl,i=c.iconUrl;if(p&&document.documentElement.style.setProperty("--dark-logo-url","url(".concat(p,")")),b&&document.documentElement.style.setProperty("--white-logo-url","url(".concat(b,")")),i&&document.documentElement.style.setProperty("--icon-url","url(".concat(i,")")),u&&p&&b){var g=t(u);document.documentElement.style.setProperty("--background-logo-url","".concat("url(".concat(g?b:p,")")))}}};export{r as default};
2
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@gyramais/gyra-design",
3
+ "version": "0.1.0",
4
+ "description": "Gyramais Design System",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "test": "npm run test",
10
+ "build": "node --max-old-space-size=8192 node_modules/rollup/dist/bin/rollup -c rollup.config.js",
11
+ "storybook": "storybook dev -p 6006",
12
+ "build-storybook": "storybook build"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/gyramais/gyra-design.git"
17
+ },
18
+ "author": "Gyramais Development Team <Ninjas>",
19
+ "license": "ISC",
20
+ "bugs": {
21
+ "url": "https://github.com/gyramais/gyra-design/issues"
22
+ },
23
+ "homepage": "https://github.com/gyramais/gyra-design#readme",
24
+ "dependencies": {
25
+ "@emotion/react": "^11.11.1",
26
+ "@emotion/styled": "^11.11.0",
27
+ "@mui/icons-material": "^5.14.16",
28
+ "@mui/material": "^5.14.17",
29
+ "@radix-ui/react-checkbox": "^1.0.4",
30
+ "@radix-ui/react-dropdown-menu": "^2.0.6",
31
+ "@radix-ui/react-hover-card": "^1.0.7",
32
+ "@radix-ui/react-label": "^2.0.2",
33
+ "@radix-ui/react-menubar": "^1.0.4",
34
+ "@radix-ui/react-switch": "^1.0.3",
35
+ "@radix-ui/react-tabs": "^1.0.4",
36
+ "@radix-ui/react-tooltip": "^1.0.7",
37
+ "@rollup/plugin-commonjs": "^25.0.7",
38
+ "@rollup/plugin-node-resolve": "^15.2.3",
39
+ "@rollup/plugin-terser": "^0.4.4",
40
+ "@rollup/plugin-typescript": "^11.1.5",
41
+ "@types/react": "^18.2.33",
42
+ "@types/react-collapse": "^5.0.4",
43
+ "@types/react-text-mask": "^5.4.14",
44
+ "class-variance-authority": "^0.7.0",
45
+ "classnames": "^2.3.2",
46
+ "clsx": "^2.0.0",
47
+ "dayjs": "^1.11.10",
48
+ "lucide-react": "^0.292.0",
49
+ "react": "18.2.0",
50
+ "react-collapse": "^5.1.1",
51
+ "react-dom": "^18.2.0",
52
+ "react-hook-form": "^7.48.2",
53
+ "react-modern-drawer": "^1.2.2",
54
+ "react-text-mask": "^5.5.0",
55
+ "react-toastify": "^9.1.3",
56
+ "recharts": "^2.10.1",
57
+ "rollup": "^4.2.0",
58
+ "rollup-plugin-dts": "^6.1.0",
59
+ "rollup-plugin-peer-deps-external": "^2.2.4",
60
+ "rollup-plugin-postcss": "^4.0.2",
61
+ "tailwind-merge": "^2.0.0",
62
+ "tailwindcss-animate": "^1.0.7",
63
+ "typescript": "^5.2.2"
64
+ },
65
+ "peerDependencies": {
66
+ "react": "18.2.0",
67
+ "react-dom": "^18.2.0"
68
+ },
69
+ "devDependencies": {
70
+ "@storybook/addon-essentials": "^7.5.2",
71
+ "@storybook/addon-interactions": "^7.5.2",
72
+ "@storybook/addon-links": "^7.5.2",
73
+ "@storybook/addon-onboarding": "^1.0.8",
74
+ "@storybook/blocks": "^7.5.2",
75
+ "@storybook/react": "^7.5.2",
76
+ "@storybook/react-vite": "^7.5.2",
77
+ "@storybook/testing-library": "^0.2.2",
78
+ "autoprefixer": "^10.4.16",
79
+ "postcss": "^8.4.31",
80
+ "storybook": "^7.5.2",
81
+ "tailwindcss": "^3.3.5"
82
+ }
83
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
@@ -0,0 +1,104 @@
1
+ const peerDepsExternal = require("rollup-plugin-peer-deps-external");
2
+ const resolve = require("@rollup/plugin-node-resolve");
3
+ const commonjs = require("@rollup/plugin-commonjs");
4
+ const typescript = require("@rollup/plugin-typescript");
5
+ const postcss = require("rollup-plugin-postcss");
6
+ const dts = require("rollup-plugin-dts");
7
+ const terser = require('@rollup/plugin-terser');
8
+
9
+ const packageJson = require("./package.json");
10
+ const { getFolders } = require('./scripts/build-utils');
11
+
12
+ const warnWithReturn = (warning, warn) => {
13
+ if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
14
+ return;
15
+ }
16
+ if (/recharts/.test(warning.message)) {
17
+ return;
18
+ }
19
+ if (/d3-interpolate/.test(warning.message)) {
20
+ return;
21
+ }
22
+
23
+ warn(warning)
24
+ }
25
+
26
+ const componentsBundleConfig = (process.env.npm_config_component ? [process.env.npm_config_component] : getFolders('./src/components'))
27
+ .map((component) => ({
28
+ input: `src/components/${component}/index.ts`,
29
+ output: [
30
+ // {
31
+ // file: `dist/components/${component}/index.js`,
32
+ // format: "cjs",
33
+ // sourcemap: true,
34
+ // exports: "named",
35
+ // banner: `'use client';`,
36
+ // },
37
+ {
38
+ file: `dist/components/${component}/index.js`,
39
+ format: "esm",
40
+ sourcemap: true,
41
+ exports: "named",
42
+ banner: `'use client';`,
43
+ }
44
+ ],
45
+ plugins: [
46
+ peerDepsExternal(),
47
+ resolve(),
48
+ commonjs(),
49
+ typescript({
50
+ declaration: false,
51
+ declarationDir: undefined,
52
+ }),
53
+ postcss({ inject: false }),
54
+ terser({
55
+ compress: { directives: false },
56
+ }),
57
+ ],
58
+ external: ["react", "react-dom"],
59
+ onwarn: warnWithReturn,
60
+ }));
61
+
62
+ module.exports = [
63
+ {
64
+ input: "src/index.ts",
65
+ output: [
66
+ // {
67
+ // file: packageJson.main,
68
+ // format: "cjs",
69
+ // sourcemap: true,
70
+ // exports: "named",
71
+ // banner: `'use client';`,
72
+ // },
73
+ {
74
+ file: packageJson.main,
75
+ format: "esm",
76
+ sourcemap: true,
77
+ exports: "named",
78
+ banner: `'use client';`,
79
+ }
80
+ ],
81
+ plugins: [
82
+ peerDepsExternal(),
83
+ resolve(),
84
+ commonjs(),
85
+ typescript(),
86
+ postcss({
87
+ extensions: [".css"],
88
+ extract: 'index.css',
89
+ }),
90
+ terser({
91
+ compress: { directives: false },
92
+ }),
93
+ ],
94
+ external: ["react", "react-dom"],
95
+ onwarn: warnWithReturn,
96
+ },
97
+ {
98
+ input: "dist/index.d.ts",
99
+ output: [{ file: "dist/index.d.ts", format: "es" }],
100
+ plugins: [dts.default()],
101
+ external: [/\.css$/]
102
+ },
103
+ ...componentsBundleConfig,
104
+ ];
@@ -0,0 +1,16 @@
1
+ const fs = require('fs');
2
+
3
+ const excludedPaths = [
4
+ 'utils',
5
+ 'Text',
6
+ ]
7
+
8
+ const getFolders = (entry) => {
9
+ const dirs = fs.readdirSync(entry)
10
+ const dirsWithoutIndex = dirs.filter(name => name !== 'index.ts').filter(name => !excludedPaths.includes(name))
11
+ return dirsWithoutIndex
12
+ }
13
+
14
+ module.exports = {
15
+ getFolders,
16
+ }
@@ -0,0 +1,26 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { Avatar } from "./Avatar";
3
+
4
+
5
+ const meta: Meta<typeof Avatar> = {
6
+ title: "Library/Components/Avatar",
7
+ component: Avatar,
8
+ parameters: {
9
+ layout: 'centered',
10
+ }
11
+ };
12
+
13
+ export default meta;
14
+
15
+ type Story = StoryObj<typeof Avatar>;
16
+
17
+ export const Default: Story = {
18
+ args: {
19
+ id: '',
20
+ className: '',
21
+ size: 32,
22
+ children: (
23
+ 'G'
24
+ ),
25
+ },
26
+ }
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import classNames from "classnames";
3
+ import "./index.css";
4
+
5
+ type AvatarProps = {
6
+ id?: string;
7
+ className?: string;
8
+ size?: number;
9
+ children?: React.ReactNode;
10
+ }
11
+
12
+ const Avatar = ({
13
+ id,
14
+ className,
15
+ size = 32,
16
+ children,
17
+ }: AvatarProps) => {
18
+ return (
19
+ <div
20
+ id={id}
21
+ className={classNames(
22
+ "gyramais-avatar",
23
+ className,
24
+ )}
25
+ style={{
26
+ width: size,
27
+ height: size,
28
+ fontSize: size / 2,
29
+ }}
30
+ >
31
+ {children}
32
+ </div>
33
+ );
34
+ };
35
+
36
+ export { Avatar };
@@ -0,0 +1,9 @@
1
+ .gyramais-avatar {
2
+ @apply
3
+ flex
4
+ items-center
5
+ justify-center
6
+ rounded-full
7
+ bg-[var(--primary-button-color)]
8
+ text-[var(--primary-button-text-color)];
9
+ }
@@ -0,0 +1 @@
1
+ export * from "./Avatar";
@@ -0,0 +1,99 @@
1
+ import React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { Button, ButtonProps } from "./Button";
4
+
5
+ import PersonIcon from '@mui/icons-material/Person';
6
+
7
+ const meta: Meta<typeof Button> = {
8
+ title: "Library/Components/Button",
9
+ component: Button,
10
+ parameters: {
11
+ layout: 'padded',
12
+ }
13
+ };
14
+
15
+ export default meta;
16
+
17
+ type Story = StoryObj<typeof Button>;
18
+ const baseArgs: ButtonProps = {
19
+ id: '',
20
+ className: '',
21
+ type: 'primary',
22
+ size: 'medium',
23
+ htmlType: 'button',
24
+ link: false,
25
+ block: false,
26
+ loading: false,
27
+ disabled: false,
28
+ onClick: () => alert('Clicou'),
29
+ }
30
+
31
+ export const Normal: Story = {
32
+ args: {
33
+ ...baseArgs,
34
+ type: 'primary',
35
+ children: (
36
+ 'Botão primário'
37
+ ),
38
+ },
39
+ }
40
+
41
+ export const NormalWithIcon: Story = {
42
+ args: {
43
+ ...baseArgs,
44
+ type: 'primary',
45
+ icon: (
46
+ <PersonIcon />
47
+ ),
48
+ children: (
49
+ 'Botão primário'
50
+ ),
51
+ },
52
+ }
53
+
54
+ export const Link: Story = {
55
+ args: {
56
+ ...baseArgs,
57
+ link: true,
58
+ children: (
59
+ 'Botão link'
60
+ ),
61
+ }
62
+ }
63
+
64
+ export const Icon: Story = {
65
+ args: {
66
+ ...baseArgs,
67
+ icon: (<PersonIcon />)
68
+ }
69
+ }
70
+
71
+ export const Block: Story = {
72
+ args: {
73
+ ...baseArgs,
74
+ block: true,
75
+ children: (
76
+ 'Botão bloqueado'
77
+ ),
78
+ }
79
+ }
80
+
81
+ export const Loading: Story = {
82
+ args: {
83
+ ...baseArgs,
84
+ loading: true,
85
+ children: (
86
+ 'Botão carregando'
87
+ ),
88
+ }
89
+ }
90
+
91
+ export const Disabled: Story = {
92
+ args: {
93
+ ...baseArgs,
94
+ disabled: true,
95
+ children: (
96
+ 'Botão desabilitado'
97
+ ),
98
+ }
99
+ }
@@ -0,0 +1,71 @@
1
+ import React from "react";
2
+ import classNames from "classnames";
3
+ import "./index.css";
4
+
5
+ import { Loading } from "../Loading";
6
+
7
+ export type ButtonProps = {
8
+ id?: string;
9
+ className?: string;
10
+ type?: "primary" | "secondary" | "white" | "dark";
11
+ size?: "small" | "medium" | "large";
12
+ htmlType?: "button" | "submit";
13
+ link?: boolean;
14
+ block?: boolean;
15
+ disabled?: boolean;
16
+ loading?: boolean;
17
+ icon?: React.ReactNode;
18
+ onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
19
+ children?: React.ReactNode;
20
+ }
21
+
22
+
23
+ const Button = ({
24
+ id,
25
+ className,
26
+ type = "primary",
27
+ size = "medium",
28
+ htmlType = "button",
29
+ link = false,
30
+ block = false,
31
+ disabled = false,
32
+ loading = false,
33
+ icon,
34
+ onClick,
35
+ children,
36
+ }: ButtonProps) => {
37
+ return (
38
+ <button
39
+ id={id}
40
+ type={htmlType}
41
+ className={classNames(
42
+ "gyramais-button",
43
+ `gyramais-button-${size}`,
44
+ `gyramais-button-${type}`,
45
+ link ? 'gyramais-button-link' : '',
46
+ block ? 'gyramais-button-block' : '',
47
+ loading ? 'gyramais-button-loading' : '',
48
+ icon && !children ? 'gyramais-button-icon' : '',
49
+ className,
50
+ )}
51
+ onClick={!loading ? onClick : () => {}}
52
+ disabled={disabled}
53
+ >
54
+ {loading && (
55
+ <div className="gyramais-button-icon-container">
56
+ <Loading size={24} className="gyramais-button-loading-feedback" />
57
+ </div>
58
+ )}
59
+
60
+ {!loading && icon && (
61
+ <div className="gyramais-button-icon-container">
62
+ {icon}
63
+ </div>
64
+ )}
65
+
66
+ {children}
67
+ </button>
68
+ );
69
+ };
70
+
71
+ export { Button };