@sk-web-gui/core 0.1.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.
@@ -0,0 +1,109 @@
1
+ function tagOutline(colors) {
2
+ return {
3
+ ".tag-outline": {
4
+ "@apply border bg-transparent border-neutral-200 text-neutral-900": {},
5
+ // dark
6
+ "@apply dark:border-neutral-600 dark:text-neutral-100": {},
7
+
8
+ ...colors.reduce(
9
+ (styles, color) => ({
10
+ ...styles,
11
+ [`&[data-color="${color}"]`]: {
12
+ [`@apply border-${color}-600 text-${color}-600`]: {},
13
+ // dark
14
+ [`@apply dark:border-${color}-400 dark:text-${color}-400`]: {},
15
+ "@apply dark:border-opacity-40": {},
16
+ },
17
+ }),
18
+ {}
19
+ ),
20
+ },
21
+ };
22
+ }
23
+
24
+ function tagSolid(colors) {
25
+ return {
26
+ ".tag-solid": {
27
+ "@apply border bg-neutral-500 border-transparent text-white": {},
28
+ // dark
29
+ "@apply dark:border-neutral-600 dark:text-neutral-100 dark:bg-neutral-700": {},
30
+
31
+ ...colors.reduce(
32
+ (styles, color) => ({
33
+ ...styles,
34
+ [`&[data-color="${color}"]`]: {
35
+ [`@apply bg-${color}-500`]: {},
36
+ // dark
37
+ [`@apply dark:text-${color}-400 dark:border-${color}-500 dark:bg-${color}-500`]: {},
38
+ "@apply dark:bg-opacity-15": {},
39
+ "@apply dark:border-opacity-40": {},
40
+ },
41
+ }),
42
+ {}
43
+ ),
44
+ },
45
+ };
46
+ }
47
+
48
+ function tagLight(colors) {
49
+ return {
50
+ ".tag-light": {
51
+ "@apply text-neutral-900 bg-neutral-100": {},
52
+ // dark
53
+ "@apply dark:text-neutral-100 dark:bg-neutral-700": {},
54
+
55
+ ...colors.reduce(
56
+ (styles, color) => ({
57
+ ...styles,
58
+ [`&[data-color="${color}"]`]: {
59
+ [`@apply text-${color}-800 bg-${color}-100`]: {},
60
+ // dark
61
+ [`@apply dark:text-${color}-400 dark:bg-${color}-500`]: {},
62
+ "@apply dark:bg-opacity-15": {},
63
+ },
64
+ }),
65
+ {}
66
+ ),
67
+ },
68
+ };
69
+ }
70
+
71
+ module.exports = Tag = (colors) => ({
72
+ ".tag": {
73
+ "@apply inline-flex items-center max-h-full rounded-full font-medium outline-none cursor-base whitespace-nowrap": {},
74
+
75
+ "&-sm": {
76
+ "@apply px-2 h-5 text-xs": {},
77
+ minWidth: "1.25rem",
78
+ },
79
+
80
+ "&-md": {
81
+ "@apply px-2 h-6 text-xs": {},
82
+ minWidth: "1.5rem",
83
+ },
84
+
85
+ "&-lg": {
86
+ "@apply px-2.5 h-7 text-sm": {},
87
+ minWidth: "1.75rem",
88
+ },
89
+
90
+ "&-xl": {
91
+ "@apply px-3 h-8 text-base": {},
92
+ minWidth: "2rem",
93
+ },
94
+ },
95
+
96
+ // variants
97
+ ...tagOutline(colors),
98
+ ...tagSolid(colors),
99
+ ...tagLight(colors),
100
+
101
+ ".tag-close-button": {
102
+ "@apply flex items-center justify-center transition-all duration-150 rounded-full outline-none ml-1 -mr-1 opacity-50 cursor-base": {},
103
+ "@apply hover:opacity-80 focus-visible:outline-none active:opacity-100": {},
104
+
105
+ "&-disabled": {
106
+ "@apply disabled:opacity-40 disabled:cursor-not-allowed disabled:shadow-none": {},
107
+ },
108
+ },
109
+ });
package/src/index.js ADDED
@@ -0,0 +1,235 @@
1
+ const plugin = require("tailwindcss/plugin");
2
+
3
+ const colors = require("./colors");
4
+ const withOpacity = require("./with-opacity");
5
+ // components
6
+ const Alert = require("./components/alert");
7
+ const Breadcrumb = require("./components/breadcrumb");
8
+ const ButtonGroup = require("./components/button-group");
9
+
10
+ const Checkbox = require("./components/checkbox");
11
+ const Dot = require("./components/dot");
12
+ const Forms = require("./components/forms");
13
+ const IconButton = require("./components/icon-button");
14
+ const Icon = require("./components/icon");
15
+ const Link = require("./components/link");
16
+ const Message = require("./components/message");
17
+ const Notification = require("./components/notification");
18
+ const Radio = require("./components/radio");
19
+ const Switch = require("./components/switch");
20
+
21
+ const Button = require("./components/button");
22
+ const Accordion = require("./components/accordion");
23
+ const Card = require('./components/card');
24
+ const Table = require('./components/table');
25
+
26
+ const Modal = require('./components/modal');
27
+ const CookieConsent = require('./components/cookie-consent');
28
+
29
+ const components = [
30
+ Alert,
31
+ Breadcrumb,
32
+ ButtonGroup,
33
+ Button,
34
+ Checkbox,
35
+ Dot,
36
+ Forms,
37
+ IconButton,
38
+ Icon,
39
+ Link,
40
+ Message,
41
+ Notification,
42
+ Radio,
43
+ Switch,
44
+
45
+ Table,
46
+ CookieConsent,
47
+ Modal,
48
+
49
+ Accordion,
50
+ Card,
51
+ ];
52
+
53
+ const defaultColors = ["primary", "secondary"];
54
+
55
+ module.exports = plugin.withOptions(
56
+ function(options = { colors: [], cssBase: true }) {
57
+ return function({
58
+ addComponents,
59
+ addVariant,
60
+ addBase,
61
+ variants,
62
+ e,
63
+ theme,
64
+ addUtilities,
65
+ }) {
66
+ const optionColors = [...defaultColors, ...(options.colors || [])];
67
+
68
+ active({ addVariant, variants, e, theme, addUtilities });
69
+ selected({ addVariant, variants, e, theme, addUtilities });
70
+ disabled({ addVariant, variants, e, theme, addUtilities });
71
+
72
+ addComponents(
73
+ components.map((component) => component(optionColors, theme)),
74
+ {
75
+ respectPrefix: false,
76
+ }
77
+ );
78
+
79
+ if (options.cssBase) {
80
+ addBase({
81
+ html: {
82
+ "@apply text-foreground antialiased bg-base": {},
83
+ fontSize: "62.5%",
84
+ lineHeight: "1.5",
85
+ textRendering: "optimizeLegibility",
86
+ textSizeAdjust: "100%",
87
+ touchAction: "manipulation",
88
+ },
89
+ body: {
90
+ "@apply text-base leading-base": {},
91
+ position: "relative",
92
+ minHeight: "100%",
93
+ fontFeatureSettings: "'kern'",
94
+ },
95
+ "h1,h2,h3,h4,h5,h6": {
96
+ "@apply font-bold": {},
97
+ },
98
+ h1: { "@apply text-5xl leading-5xl": {} },
99
+ h2: { "@apply text-4xl leading-4xl": {} },
100
+ h3: { "@apply text-3xl leading-3xl": {} },
101
+ h4: { "@apply text-2xl leading-2xl": {} },
102
+ h5: { "@apply text-xl leading-xl": {} },
103
+ h6: { "@apply text-lg leading-lg": {} },
104
+ p: { "@apply my-4": {} },
105
+ });
106
+ }
107
+ };
108
+ },
109
+ function() {
110
+ return {
111
+ theme: {
112
+ fontSize: {
113
+ 'tiny': '1rem',
114
+ 'xs': '1.2rem',
115
+ 'sm': '1.4rem',
116
+ 'base': '1.6rem',
117
+ 'lg': '1.8rem',
118
+ 'xl': '2.0rem',
119
+ '2xl': '2.4rem',
120
+ '3xl': '3.2rem',
121
+ '4xl': '4.0rem',
122
+ '5xl': '5.2rem',
123
+ },
124
+ extend: {
125
+ colors: {
126
+ ...colors,
127
+ gray: {
128
+ DEFAULT: "#4b4b4b",
129
+ stroke: "#939393",
130
+ light: "#F4F4F4",
131
+ lighter: "#F9F9F9",
132
+ },
133
+ hover: {
134
+ DEFAULT: "#2B76B0",
135
+ },
136
+ },
137
+ cursor: {
138
+ base: "var(--vc-cursor)",
139
+ },
140
+ spacing: {
141
+ sm: '8px',
142
+ md: '16px',
143
+ lg: '24px',
144
+ xl: '48px',
145
+ },
146
+ lineHeight: {
147
+ 'tiny': '1.4rem',
148
+ 'xs': '1.6rem',
149
+ 'sm': '2rem',
150
+ 'base': '2.4rem',
151
+ 'lg': '2.4rem',
152
+ 'xl': '3.2rem',
153
+ '2xl': '3.2rem',
154
+ '3xl': '4rem',
155
+ '4xl': '4.8rem',
156
+ '5xl': '5.8rem',
157
+ },
158
+ opacity: {
159
+ 15: "0.15",
160
+ },
161
+ backgroundColor: {
162
+ base: withOpacity("--vc-colors-bg-base"),
163
+ fill: withOpacity("--vc-colors-bg-fill"),
164
+ },
165
+ textColor: {
166
+ foreground: withOpacity("--vc-colors-text-foreground"),
167
+ muted: withOpacity("--vc-colors-text-muted"),
168
+ },
169
+ borderRadius: {
170
+ base: "var(--vc-rounded)",
171
+ },
172
+ zIndex: {
173
+ hide: -1,
174
+ none: 0,
175
+ base: 1,
176
+ docked: 10,
177
+ dropdown: 1000,
178
+ sticky: 1100,
179
+ banner: 1200,
180
+ overlay: 1300,
181
+ modal: 1400,
182
+ popover: 1500,
183
+ skipLink: 1600,
184
+ toast: 1700,
185
+ tooltip: 1800,
186
+ },
187
+ },
188
+ },
189
+ variants: {
190
+ extend: {
191
+ boxShadow: ["disabled"],
192
+ cursor: ["disabled"],
193
+ opacity: ["active", "disabled"],
194
+ textColor: ["active", "disabled:hover"],
195
+ textDecoration: ["disabled"],
196
+ backgroundColor: ["disabled"],
197
+ borderColor: ["disabled"],
198
+ },
199
+ },
200
+ };
201
+ }
202
+ );
203
+
204
+ function active({ addVariant, e }) {
205
+ addVariant("active", ({ modifySelectors, separator }) => {
206
+ modifySelectors(({ className }) => {
207
+ return `.${e(`active${separator}${className}`)}:active, .${e(
208
+ `active${separator}${className}`
209
+ )}[data-active=true]`;
210
+ });
211
+ });
212
+ }
213
+
214
+ function selected({ addVariant, e }) {
215
+ addVariant("selected", ({ modifySelectors, separator }) => {
216
+ modifySelectors(({ className }) => {
217
+ return `.${e(`selected${separator}${className}`)}[aria-selected=true]`;
218
+ });
219
+ });
220
+ }
221
+
222
+ function disabled({ addVariant, e }) {
223
+ addVariant("disabled", ({ modifySelectors, separator }) => {
224
+ modifySelectors(({ className }) => {
225
+ return `.${e(`disabled${separator}${className}`)}[aria-disabled=true]`;
226
+ });
227
+ });
228
+ addVariant("disabled:hover", ({ modifySelectors, separator }) => {
229
+ modifySelectors(({ className }) => {
230
+ return `.${e(
231
+ `disabled:hover${separator}${className}`
232
+ )}[aria-disabled=true]`;
233
+ });
234
+ });
235
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = function withOpacity(variableName) {
2
+ return ({ opacityValue }) => {
3
+ if (opacityValue) return `rgba(var(${variableName}), ${opacityValue})`;
4
+ return `rgb(var(${variableName}))`;
5
+ };
6
+ };