@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.
- package/.eslintrc.json +14 -0
- package/.storybook/main.ts +20 -0
- package/.storybook/preview.ts +45 -0
- package/README.md +31 -0
- package/dist/index.js +2 -0
- package/package.json +83 -0
- package/postcss.config.js +6 -0
- package/rollup.config.js +104 -0
- package/scripts/build-utils.js +16 -0
- package/src/components/Avatar/Avatar.stories.tsx +26 -0
- package/src/components/Avatar/Avatar.tsx +36 -0
- package/src/components/Avatar/index.css +9 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Button/Button.stories.tsx +99 -0
- package/src/components/Button/Button.tsx +71 -0
- package/src/components/Button/index.css +168 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Card/Card.stories.tsx +126 -0
- package/src/components/Card/Card.tsx +111 -0
- package/src/components/Card/index.css +96 -0
- package/src/components/Card/index.ts +1 -0
- package/src/components/Chart/Chart.stories.tsx +61 -0
- package/src/components/Chart/Chart.tsx +192 -0
- package/src/components/Chart/index.css +15 -0
- package/src/components/Chart/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +46 -0
- package/src/components/Checkbox/Checkbox.tsx +46 -0
- package/src/components/Checkbox/index.css +29 -0
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/Col/Col.stories.tsx +33 -0
- package/src/components/Col/Col.tsx +45 -0
- package/src/components/Col/index.css +57 -0
- package/src/components/Col/index.ts +1 -0
- package/src/components/Collapse/Collapse.stories.tsx +86 -0
- package/src/components/Collapse/Collapse.tsx +34 -0
- package/src/components/Collapse/CollapseIcon.tsx +33 -0
- package/src/components/Collapse/index.css +14 -0
- package/src/components/Collapse/index.ts +2 -0
- package/src/components/Divider/Divider.stories.tsx +45 -0
- package/src/components/Divider/Divider.tsx +42 -0
- package/src/components/Divider/index.css +20 -0
- package/src/components/Divider/index.ts +1 -0
- package/src/components/Drawer/Drawer.stories.tsx +51 -0
- package/src/components/Drawer/Drawer.tsx +40 -0
- package/src/components/Drawer/index.css +15 -0
- package/src/components/Drawer/index.ts +1 -0
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +66 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +91 -0
- package/src/components/DropdownMenu/index.css +18 -0
- package/src/components/DropdownMenu/index.ts +1 -0
- package/src/components/Filter/Filter.stories.tsx +94 -0
- package/src/components/Filter/Filter.tsx +213 -0
- package/src/components/Filter/index.css +81 -0
- package/src/components/Filter/index.ts +1 -0
- package/src/components/Form/Form.tsx +11 -0
- package/src/components/Form/Item.tsx +33 -0
- package/src/components/Form/index.css +4 -0
- package/src/components/Form/index.ts +1 -0
- package/src/components/HoverCard/HoverCard.stories.tsx +48 -0
- package/src/components/HoverCard/HoverCard.tsx +54 -0
- package/src/components/HoverCard/index.css +15 -0
- package/src/components/HoverCard/index.ts +1 -0
- package/src/components/Icon/Icon.stories.tsx +23 -0
- package/src/components/Icon/Icon.tsx +36 -0
- package/src/components/Icon/index.css +3 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/IconDisplay/IconDisplay.stories.tsx +27 -0
- package/src/components/IconDisplay/IconDisplay.tsx +29 -0
- package/src/components/IconDisplay/index.css +18 -0
- package/src/components/IconDisplay/index.ts +1 -0
- package/src/components/Information/Information.stories.tsx +25 -0
- package/src/components/Information/Information.tsx +50 -0
- package/src/components/Information/index.css +34 -0
- package/src/components/Information/index.ts +1 -0
- package/src/components/Input/Input.stories.tsx +38 -0
- package/src/components/Input/Input.tsx +91 -0
- package/src/components/Input/index.css +74 -0
- package/src/components/Input/index.ts +1 -0
- package/src/components/Label/Label.tsx +26 -0
- package/src/components/Label/index.ts +1 -0
- package/src/components/Layout/Content.tsx +29 -0
- package/src/components/Layout/Header.tsx +29 -0
- package/src/components/Layout/Layout.stories.tsx +54 -0
- package/src/components/Layout/Layout.tsx +32 -0
- package/src/components/Layout/Sider.tsx +29 -0
- package/src/components/Layout/index.css +37 -0
- package/src/components/Layout/index.ts +4 -0
- package/src/components/List/List.stories.tsx +58 -0
- package/src/components/List/List.tsx +98 -0
- package/src/components/List/index.css +54 -0
- package/src/components/List/index.ts +1 -0
- package/src/components/Loading/Loading.stories.tsx +23 -0
- package/src/components/Loading/Loading.tsx +51 -0
- package/src/components/Loading/index.css +36 -0
- package/src/components/Loading/index.ts +1 -0
- package/src/components/Logo/Logo.stories.tsx +34 -0
- package/src/components/Logo/Logo.tsx +39 -0
- package/src/components/Logo/index.css +9 -0
- package/src/components/Logo/index.ts +1 -0
- package/src/components/Menubar/Menubar.stories.tsx +55 -0
- package/src/components/Menubar/Menubar.tsx +118 -0
- package/src/components/Menubar/index.css +96 -0
- package/src/components/Menubar/index.ts +1 -0
- package/src/components/Row/Row.stories.tsx +33 -0
- package/src/components/Row/Row.tsx +48 -0
- package/src/components/Row/index.css +116 -0
- package/src/components/Row/index.ts +1 -0
- package/src/components/Switch/Switch.stories.tsx +39 -0
- package/src/components/Switch/Switch.tsx +36 -0
- package/src/components/Switch/index.css +37 -0
- package/src/components/Switch/index.ts +1 -0
- package/src/components/Table/Table.stories.tsx +85 -0
- package/src/components/Table/Table.tsx +123 -0
- package/src/components/Table/index.css +74 -0
- package/src/components/Table/index.ts +1 -0
- package/src/components/Tabs/Tabs.stories.tsx +49 -0
- package/src/components/Tabs/Tabs.tsx +76 -0
- package/src/components/Tabs/index.css +89 -0
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/Tag/Tag.stories.tsx +41 -0
- package/src/components/Tag/Tag.tsx +39 -0
- package/src/components/Tag/index.css +31 -0
- package/src/components/Tag/index.ts +1 -0
- package/src/components/Text/Text.stories.tsx +41 -0
- package/src/components/Toast/Toast.stories.tsx +47 -0
- package/src/components/Toast/Toast.tsx +13 -0
- package/src/components/Toast/index.ts +1 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +44 -0
- package/src/components/Tooltip/Tooltip.tsx +60 -0
- package/src/components/Tooltip/index.css +15 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/index.css +176 -0
- package/src/index.ts +38 -0
- package/src/shadcn/checkbox.tsx +28 -0
- package/src/shadcn/dropdown-menu.tsx +200 -0
- package/src/shadcn/form.tsx +178 -0
- package/src/shadcn/hover-card.tsx +31 -0
- package/src/shadcn/label.tsx +26 -0
- package/src/shadcn/lib/utils.ts +6 -0
- package/src/shadcn/menubar.tsx +248 -0
- package/src/shadcn/switch.tsx +25 -0
- package/src/shadcn/table.tsx +117 -0
- package/src/shadcn/tabs.tsx +55 -0
- package/src/shadcn/tooltip.tsx +30 -0
- package/src/theme.ts +123 -0
- package/tailwind.config.js +9 -0
- 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
|
+
};
|
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
|
+
}
|