@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
@@ -0,0 +1,30 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip"
5
+
6
+ import { cn } from "./lib/utils"
7
+
8
+ const TooltipProvider = TooltipPrimitive.Provider
9
+
10
+ const Tooltip = TooltipPrimitive.Root
11
+
12
+ const TooltipTrigger = TooltipPrimitive.Trigger
13
+
14
+ const TooltipContent = React.forwardRef<
15
+ React.ElementRef<typeof TooltipPrimitive.Content>,
16
+ React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
17
+ >(({ className, sideOffset = 4, ...props }, ref) => (
18
+ <TooltipPrimitive.Content
19
+ ref={ref}
20
+ sideOffset={sideOffset}
21
+ className={cn(
22
+ "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
23
+ className
24
+ )}
25
+ {...props}
26
+ />
27
+ ))
28
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName
29
+
30
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
package/src/theme.ts ADDED
@@ -0,0 +1,123 @@
1
+ interface Colors {
2
+ backgroundColor: string;
3
+ primaryButton: string;
4
+ secondaryButton: string;
5
+ linkButton: string;
6
+ }
7
+
8
+ interface Images {
9
+ whiteLogoUrl: string;
10
+ darkLogoUrl: string;
11
+ iconUrl: string;
12
+ }
13
+
14
+ const isColorDark = (hexColor: string) => {
15
+ const color = hexColor.replace('#', '');
16
+
17
+ const r = parseInt(color.substr(0, 2), 16);
18
+ const g = parseInt(color.substr(2, 2), 16);
19
+ const b = parseInt(color.substr(4, 2), 16);
20
+
21
+ const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
22
+ return (yiq <= 128);
23
+ };
24
+
25
+ const getContrastYIQ = (hexColor: string) => (isColorDark(hexColor) ? '#ffffff' : '#2b2b2b');
26
+
27
+ const getTintedColor: (hexColor: string, v: number) => string = (hexColor, v) => {
28
+ if (hexColor.length > 6) {
29
+ hexColor= hexColor.substring(1, hexColor.length)
30
+ }
31
+
32
+ const rgb = parseInt(hexColor, 16);
33
+
34
+ let r = Math.abs(((rgb >> 16) & 0xFF) + v);
35
+ if (r > 255) {
36
+ r = r - (r - 255);
37
+ }
38
+
39
+ let g = Math.abs(((rgb >> 8) & 0xFF) + v);
40
+ if (g > 255) {
41
+ g = g - (g - 255);
42
+ }
43
+
44
+ let b = Math.abs((rgb & 0xFF) + v);
45
+ if (b > 255) {
46
+ b = b - (b - 255);
47
+ }
48
+
49
+ const rString = (`${Number(r < 0 || isNaN(r)) ? 0 : ((r > 255) ? 255 : r).toString(16)}`).padStart(2, '0');
50
+ const gString = (`${Number(g < 0 || isNaN(g)) ? 0 : ((g > 255) ? 255 : g).toString(16)}`).padStart(2, '0');
51
+ const bString = (`${Number(b < 0 || isNaN(b)) ? 0 : ((b > 255) ? 255 : b).toString(16)}`).padStart(2 ,'0');
52
+
53
+ return "#" + rString + gString + bString;
54
+ }
55
+
56
+ const setTheme = ({ colors, images }: {
57
+ colors: Colors;
58
+ images: Images;
59
+ }) => {
60
+ const {
61
+ backgroundColor,
62
+ primaryButton,
63
+ secondaryButton,
64
+ linkButton,
65
+ } = colors;
66
+
67
+ if (backgroundColor) {
68
+ document.documentElement.style.setProperty('--background-color', backgroundColor);
69
+ document.documentElement.style.setProperty('--background-text-color', getContrastYIQ(backgroundColor));
70
+ }
71
+
72
+ if (primaryButton) {
73
+ document.documentElement.style.setProperty('--primary-button-color', primaryButton);
74
+ document.documentElement.style.setProperty('--primary-button-text-color', getContrastYIQ(primaryButton));
75
+
76
+ document.documentElement.style.setProperty('--dark-button-color', `${primaryButton}66`);
77
+ document.documentElement.style.setProperty('--dark-button-text-color', getContrastYIQ(primaryButton));
78
+
79
+ const primaryButtonIsDark = isColorDark(primaryButton);
80
+ for (let x = 0; x < 5; x += 1) {
81
+ const variant = getTintedColor(primaryButton, ((x * 35) * (primaryButtonIsDark ? 1 : -1)));
82
+
83
+ document.documentElement.style.setProperty(`--primary-button-color-${x}00`, variant);
84
+ }
85
+ }
86
+
87
+ if (secondaryButton) {
88
+ document.documentElement.style.setProperty('--secondary-button-color', secondaryButton);
89
+ document.documentElement.style.setProperty('--secondary-button-text-color', getContrastYIQ(secondaryButton));
90
+ }
91
+
92
+ if (linkButton) {
93
+ document.documentElement.style.setProperty('--link-button-color', linkButton);
94
+ }
95
+
96
+ const {
97
+ darkLogoUrl,
98
+ whiteLogoUrl,
99
+ iconUrl,
100
+ } = images;
101
+
102
+ if (darkLogoUrl) {
103
+ document.documentElement.style.setProperty('--dark-logo-url', `url(${darkLogoUrl})`);
104
+ }
105
+
106
+ if (whiteLogoUrl) {
107
+ document.documentElement.style.setProperty('--white-logo-url', `url(${whiteLogoUrl})`);
108
+ }
109
+
110
+ if (iconUrl) {
111
+ document.documentElement.style.setProperty('--icon-url', `url(${iconUrl})`);
112
+ }
113
+
114
+ if (backgroundColor && darkLogoUrl && whiteLogoUrl) {
115
+ const backgroundColorIsDark = isColorDark(backgroundColor);
116
+
117
+ document.documentElement.style.setProperty('--background-logo-url', `${backgroundColorIsDark ? `url(${whiteLogoUrl})` : `url(${darkLogoUrl})`}`)
118
+ }
119
+ };
120
+
121
+ export default {
122
+ setTheme,
123
+ };
@@ -0,0 +1,9 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: ["./src/**/*.{ts,tsx}"],
4
+ theme: {
5
+ extend: {},
6
+ },
7
+ plugins: [require("tailwindcss-animate")],
8
+ }
9
+
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "outDir": "lib",
5
+ "lib": ["dom", "dom.iterable", "esnext"],
6
+ "declaration": true,
7
+ "declarationDir": "dist",
8
+ "allowJs": true,
9
+ "skipLibCheck": true,
10
+ "esModuleInterop": true,
11
+ "allowSyntheticDefaultImports": true,
12
+ "strict": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "module": "esnext",
15
+ "moduleResolution": "node",
16
+ "resolveJsonModule": true,
17
+ "isolatedModules": true,
18
+ "noEmit": true,
19
+ "jsx": "react",
20
+ "baseUrl": ".",
21
+ "paths": {
22
+ "@/*": ["./*"]
23
+ }
24
+ },
25
+ "include": ["src"],
26
+ "exclude": [
27
+ "node_modules",
28
+ "dist",
29
+ "src/**/*.stories.tsx",
30
+ "src/**/*.test.tsx",
31
+ ]
32
+ }