@digigov/css 1.0.0-21c8c3dc → 1.0.0-23c81d9f
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/defaultTheme/back-to-top.json +27 -0
- package/defaultTheme/index.js +1 -0
- package/dist/base/index.css +1 -3
- package/dist/base.js +1 -1
- package/dist/components.js +1 -1
- package/dist/digigov.css +3 -5
- package/dist/utilities/index.css +1 -1
- package/dist/utilities.js +1 -1
- package/index.js +1 -1
- package/package.json +9 -10
- package/postcss.config.js +15 -14
- package/src/base/index.css +1 -0
- package/src/base/postcss.config.js +23 -22
- package/src/base/tailwind.config.js +19 -15
- package/src/components/accordion.css +1 -1
- package/src/components/back-to-top.css +29 -0
- package/src/components/button.css +29 -6
- package/src/components/checkboxes.css +49 -11
- package/src/components/copy-to-clipboard.css +13 -5
- package/src/components/drawer.css +44 -4
- package/src/components/dropdown.css +91 -66
- package/src/components/form.css +26 -1
- package/src/components/header.css +3 -5
- package/src/components/index.css +1 -1
- package/src/components/layout.css +38 -5
- package/src/components/modal.css +7 -2
- package/src/components/nav.css +38 -13
- package/src/components/notification-banner.css +14 -3
- package/src/components/pagination.css +3 -0
- package/src/components/panel.css +1 -0
- package/src/components/postcss.config.js +15 -16
- package/src/components/radios.css +20 -1
- package/src/components/stepnav.css +1 -1
- package/src/components/svg-icons.css +2 -3
- package/src/components/tabs.css +33 -1
- package/src/components/tailwind.config.js +12 -6
- package/src/components/typography.css +11 -0
- package/src/components/warning-text.css +6 -2
- package/src/fonts.css +1 -1
- package/src/index.css +0 -2
- package/src/pages/dropdown.js +2 -2
- package/src/utilities/index.css +1 -1
- package/src/utilities/postcss.config.js +15 -16
- package/src/utilities/tailwind.config.js +10 -1
- package/src/utilities/utilities.css +10 -10
- package/tailwind.config.js +17 -30
- package/themes.plugin.js +93 -98
- package/src/components/accessibility-menu.css +0 -76
|
@@ -46,13 +46,12 @@
|
|
|
46
46
|
}
|
|
47
47
|
.govgr-svg-icon--burger {
|
|
48
48
|
fill: var(--color-base-content);
|
|
49
|
-
|
|
50
|
-
@apply transition-all focus:bg-focus;
|
|
49
|
+
@apply transition-transform focus:bg-focus;
|
|
51
50
|
@apply cursor-pointer;
|
|
52
51
|
#govgr-svg-icon--burger__line-1,
|
|
53
52
|
#govgr-svg-icon--burger__line-2,
|
|
54
53
|
#govgr-svg-icon--burger__line-3 {
|
|
55
|
-
@apply transition-
|
|
54
|
+
@apply transition-transform;
|
|
56
55
|
}
|
|
57
56
|
#govgr-svg-icon--burger__line-1 {
|
|
58
57
|
x: 2px;
|
package/src/components/tabs.css
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
@apply md:float-left md:border md:border-base-300 md:bg-base-300 md:rounded-t-sm md:mr-2;
|
|
16
16
|
@apply print:hidden;
|
|
17
17
|
&.govgr-tabs__list-item-selected {
|
|
18
|
-
@apply no-underline md:border-base-400 md:border bg-base-100 md:border-b-0 md:px-5 md:
|
|
18
|
+
@apply no-underline md:border-base-400 md:border bg-base-100 md:border-b-0 md:px-5 md:py-4 md:-mt-1;
|
|
19
19
|
margin-bottom: -1px;
|
|
20
20
|
&:hover {
|
|
21
21
|
text-decoration-thickness: 2px;
|
|
@@ -46,4 +46,36 @@
|
|
|
46
46
|
@apply block;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
&.govgr-tabs--dense, .govgr-dense & {
|
|
50
|
+
.govgr-tabs__list {
|
|
51
|
+
.govgr-tabs__list-item {
|
|
52
|
+
@apply px-3 py-1;
|
|
53
|
+
&.govgr-tabs__list-item-selected {
|
|
54
|
+
@apply md:px-4 md:pb-3 md:pt-2;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
.govgr-tabs__panel {
|
|
59
|
+
@apply pb-2 pt-3;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.govgr-tabs--vertical {
|
|
65
|
+
.govgr-tabs__panel {
|
|
66
|
+
@apply min-h-full pt-4 pl-6;
|
|
67
|
+
}
|
|
68
|
+
.govgr-tabs__list {
|
|
69
|
+
.govgr-tabs__list-item {
|
|
70
|
+
@apply w-full rounded-none mb-1 md:bg-base-200 border-base-200;
|
|
71
|
+
width: calc(100% - 0.25rem);
|
|
72
|
+
&.govgr-tabs__list-item-selected {
|
|
73
|
+
@apply md:border-b md:border-r-0 mb-1 mt-0 px-4 py-2;
|
|
74
|
+
/* margin-right: -1px; */
|
|
75
|
+
width: calc(100% + 1px);
|
|
76
|
+
/* margin-top: 0px; */
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
49
81
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
const plugin = require(
|
|
2
|
-
const tailwindConfig = require(
|
|
1
|
+
const plugin = require("tailwindcss/plugin");
|
|
2
|
+
const tailwindConfig = require("../../tailwind.config");
|
|
3
|
+
|
|
4
|
+
/** @type {import('tailwindcss').Config} */
|
|
3
5
|
module.exports = {
|
|
4
6
|
...tailwindConfig,
|
|
7
|
+
content: {
|
|
8
|
+
files: ["./*.css"],
|
|
9
|
+
relative: true,
|
|
10
|
+
},
|
|
5
11
|
plugins: [
|
|
6
|
-
plugin(function ({
|
|
7
|
-
addUtilities(require(
|
|
8
|
-
})
|
|
12
|
+
plugin(function ({ addUtilities }) {
|
|
13
|
+
addUtilities(require("../../dist/utilities"));
|
|
14
|
+
}),
|
|
9
15
|
],
|
|
10
|
-
}
|
|
16
|
+
};
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
font-weight: var(--heading-xs-font-weight);
|
|
39
39
|
letter-spacing: var(--heading-xs-letter-spacing);
|
|
40
40
|
}
|
|
41
|
+
.govgr-heading--break-words {
|
|
42
|
+
@apply break-words;
|
|
43
|
+
}
|
|
41
44
|
.govgr-caption-xl {
|
|
42
45
|
@apply block mx-0 font-normal;
|
|
43
46
|
color: var(--caption-xl-color);
|
|
@@ -180,6 +183,9 @@
|
|
|
180
183
|
color: var(--hint-color);
|
|
181
184
|
letter-spacing: var(--hint-letter-spacing);
|
|
182
185
|
}
|
|
186
|
+
.govgr-hint--break-words {
|
|
187
|
+
@apply break-words;
|
|
188
|
+
}
|
|
183
189
|
|
|
184
190
|
.govgr-\!-font-weight-regular {
|
|
185
191
|
@apply font-normal !important;
|
|
@@ -290,6 +296,11 @@
|
|
|
290
296
|
}
|
|
291
297
|
}
|
|
292
298
|
}
|
|
299
|
+
button.govgr-link {
|
|
300
|
+
.govgr-svg-icon {
|
|
301
|
+
@apply ml-1;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
293
304
|
.govgr-back-link {
|
|
294
305
|
.govgr-svg-icon--caret {
|
|
295
306
|
fill: var(--color-base-content);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
.govgr-warning-text {
|
|
2
2
|
font-size: var(--warning-text-font-size);
|
|
3
|
-
@apply
|
|
4
|
-
@apply flex pt-4 pb-4 pl-0 pr-0;
|
|
3
|
+
@apply flex py-4 px-0;
|
|
5
4
|
.govgr-warning-text__icon {
|
|
6
5
|
@apply text-base-content-invert font-bold bg-base-content text-3xl leading-10 text-center
|
|
7
6
|
rounded-3xl md:min-h-10 min-w-10 h-fit mr-6 mt-1
|
|
@@ -16,4 +15,9 @@
|
|
|
16
15
|
-webkit-clip-path: inset(50%) !important;
|
|
17
16
|
clip-path: inset(50%) !important;
|
|
18
17
|
}
|
|
18
|
+
&.govgr-warning-text--dense, .govgr-dense & {
|
|
19
|
+
.govgr-warning-text__icon {
|
|
20
|
+
@apply mr-4 md:mr-5;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
19
23
|
}
|
package/src/fonts.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import "@fontsource/roboto/index.css";
|
|
1
|
+
@import "@fontsource/roboto/index.css";
|
package/src/index.css
CHANGED
package/src/pages/dropdown.js
CHANGED
|
@@ -75,7 +75,7 @@ export default function Dropdown() {
|
|
|
75
75
|
</p>
|
|
76
76
|
|
|
77
77
|
<details className="govgr-dropdown">
|
|
78
|
-
<summary className="govgr-dropdown__button govgr-btn govgr-btn-secondary govgr-dropdown__button--
|
|
78
|
+
<summary className="govgr-dropdown__button govgr-btn govgr-btn-secondary govgr-dropdown__button--chevron">
|
|
79
79
|
Ενέργειες
|
|
80
80
|
<svg aria-hidden="true" className="govgr-svg-icon govgr-svg-icon--arrow--down" focusable="false" viewBox="0 0 24 24">
|
|
81
81
|
<path d="M22,8.2l-2.3-2.4L12,13.4L4.4,5.8L2,8.2l10,10L22,8.2z" />
|
|
@@ -143,7 +143,7 @@ export default function Dropdown() {
|
|
|
143
143
|
</details>
|
|
144
144
|
|
|
145
145
|
<details className="govgr-dropdown govgr-dropdown--left govgr-dropdown--up">
|
|
146
|
-
<summary className="govgr-dropdown__button govgr-link govgr-dropdown__button--
|
|
146
|
+
<summary className="govgr-dropdown__button govgr-link govgr-dropdown__button--chevron">
|
|
147
147
|
Ενέργειες
|
|
148
148
|
<svg aria-hidden="true" className="govgr-svg-icon govgr-svg-icon--arrow--down" focusable="false" viewBox="0 0 24 24">
|
|
149
149
|
<path d="M22,8.2l-2.3-2.4L12,13.4L4.4,5.8L2,8.2l10,10L22,8.2z" />
|
package/src/utilities/index.css
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/** @type {import('postcss-load-config').Config} */
|
|
2
|
+
const config = {
|
|
2
3
|
plugins: [
|
|
3
|
-
require(
|
|
4
|
-
require(
|
|
5
|
-
require(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}),
|
|
10
|
-
require('autoprefixer'),
|
|
11
|
-
require('cssnano')({
|
|
12
|
-
"preset": [
|
|
4
|
+
require("postcss-import"),
|
|
5
|
+
require("tailwindcss/nesting"),
|
|
6
|
+
require("tailwindcss")("./src/utilities/tailwind.config.js"),
|
|
7
|
+
require("autoprefixer"),
|
|
8
|
+
require("cssnano")({
|
|
9
|
+
preset: [
|
|
13
10
|
"default",
|
|
14
11
|
{
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
]
|
|
12
|
+
mergeRules: false,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
18
15
|
}),
|
|
19
|
-
]
|
|
20
|
-
}
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = config;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
const tailwindConfig = require("../../tailwind.config");
|
|
2
|
+
|
|
3
|
+
/** @type {import('tailwindcss').Config} */
|
|
4
|
+
module.exports = {
|
|
5
|
+
...tailwindConfig,
|
|
6
|
+
content: {
|
|
7
|
+
files: ["./*.css"],
|
|
8
|
+
relative: true,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@layer utilities {
|
|
3
3
|
.govgr-m-0 {
|
|
4
4
|
@apply m-0 !important;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
6
|
.govgr-m-1 {
|
|
7
7
|
@apply m-1 !important;
|
|
8
8
|
}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
.govgr-mt-0 {
|
|
43
43
|
@apply mt-0 !important;
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
.govgr-mt-1 {
|
|
46
46
|
@apply mt-1 !important;
|
|
47
47
|
}
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
}
|
|
81
81
|
.govgr-mb-0 {
|
|
82
82
|
@apply mb-0 !important;
|
|
83
|
-
}
|
|
83
|
+
}
|
|
84
84
|
.govgr-mb-1 {
|
|
85
85
|
@apply mb-1 !important;
|
|
86
86
|
}
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
}
|
|
120
120
|
.govgr-ml-0 {
|
|
121
121
|
@apply ml-0 !important;
|
|
122
|
-
}
|
|
122
|
+
}
|
|
123
123
|
.govgr-ml-1 {
|
|
124
124
|
@apply ml-1 !important;
|
|
125
125
|
}
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
}
|
|
159
159
|
.govgr-mr-0 {
|
|
160
160
|
@apply mr-0 !important;
|
|
161
|
-
}
|
|
161
|
+
}
|
|
162
162
|
.govgr-mr-1 {
|
|
163
163
|
@apply mr-1 !important;
|
|
164
164
|
}
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
}
|
|
198
198
|
.govgr-p-0 {
|
|
199
199
|
@apply p-0 !important;
|
|
200
|
-
}
|
|
200
|
+
}
|
|
201
201
|
.govgr-p-1 {
|
|
202
202
|
@apply p-1 !important;
|
|
203
203
|
}
|
|
@@ -236,7 +236,7 @@
|
|
|
236
236
|
}
|
|
237
237
|
.govgr-pt-0 {
|
|
238
238
|
@apply pt-0 !important;
|
|
239
|
-
}
|
|
239
|
+
}
|
|
240
240
|
.govgr-pt-1 {
|
|
241
241
|
@apply pt-1 !important;
|
|
242
242
|
}
|
|
@@ -275,7 +275,7 @@
|
|
|
275
275
|
}
|
|
276
276
|
.govgr-pb-0 {
|
|
277
277
|
@apply pb-0 !important;
|
|
278
|
-
}
|
|
278
|
+
}
|
|
279
279
|
.govgr-pb-1 {
|
|
280
280
|
@apply pb-1 !important;
|
|
281
281
|
}
|
|
@@ -314,7 +314,7 @@
|
|
|
314
314
|
}
|
|
315
315
|
.govgr-pl-0 {
|
|
316
316
|
@apply pl-0 !important;
|
|
317
|
-
}
|
|
317
|
+
}
|
|
318
318
|
.govgr-pl-1 {
|
|
319
319
|
@apply pl-1 !important;
|
|
320
320
|
}
|
|
@@ -353,7 +353,7 @@
|
|
|
353
353
|
}
|
|
354
354
|
.govgr-pr-0 {
|
|
355
355
|
@apply pr-0 !important;
|
|
356
|
-
}
|
|
356
|
+
}
|
|
357
357
|
.govgr-pr-1 {
|
|
358
358
|
@apply pr-1 !important;
|
|
359
359
|
}
|
package/tailwind.config.js
CHANGED
|
@@ -64,14 +64,8 @@ const allColors = [
|
|
|
64
64
|
"shadow600",
|
|
65
65
|
];
|
|
66
66
|
|
|
67
|
-
const buildOnly = !process.env["DIGIGOV_CSS_BUILD"]
|
|
68
|
-
? {
|
|
69
|
-
mode: "jit",
|
|
70
|
-
}
|
|
71
|
-
: {};
|
|
72
|
-
|
|
73
67
|
const colorVariables = allColors.reduce((colorVars, color) => {
|
|
74
|
-
if ([
|
|
68
|
+
if (["transparent", "currentColor"].includes(color)) {
|
|
75
69
|
colorVars[color] = color;
|
|
76
70
|
} else {
|
|
77
71
|
colorVars[color] = ({ opacityVariable, opacityValue }) => {
|
|
@@ -87,13 +81,17 @@ const colorVariables = allColors.reduce((colorVars, color) => {
|
|
|
87
81
|
return colorVars;
|
|
88
82
|
}, {});
|
|
89
83
|
|
|
84
|
+
/** @type {import('tailwindcss').Config} */
|
|
90
85
|
module.exports = {
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
darkMode: "class",
|
|
87
|
+
content: {
|
|
88
|
+
files: ["./src/*.css"],
|
|
89
|
+
relative: true,
|
|
90
|
+
},
|
|
93
91
|
themes: {
|
|
94
|
-
light: require.resolve(
|
|
92
|
+
light: require.resolve("./defaultTheme"),
|
|
95
93
|
},
|
|
96
|
-
defaultTheme:
|
|
94
|
+
defaultTheme: "light",
|
|
97
95
|
theme: {
|
|
98
96
|
colors: colorVariables,
|
|
99
97
|
container: {
|
|
@@ -111,11 +109,11 @@ module.exports = {
|
|
|
111
109
|
xl: "1280px",
|
|
112
110
|
"2xl": "1280px",
|
|
113
111
|
print: { raw: "print" },
|
|
114
|
-
xsOnly: {
|
|
115
|
-
smOnly: {
|
|
116
|
-
mdOnly: {
|
|
117
|
-
lgOnly: {
|
|
118
|
-
xlOnly: {
|
|
112
|
+
xsOnly: { min: "0px", max: "639.98px" },
|
|
113
|
+
smOnly: { min: "640px", max: "767.98px" },
|
|
114
|
+
mdOnly: { min: "768px", max: "1023.98px" },
|
|
115
|
+
lgOnly: { min: "1024px", max: "1279.98px" },
|
|
116
|
+
xlOnly: { min: "1280px", max: "1535.98px" },
|
|
119
117
|
},
|
|
120
118
|
fontFamily: {
|
|
121
119
|
sans: ["Roboto", ...defaultTheme.fontFamily.sans],
|
|
@@ -126,8 +124,8 @@ module.exports = {
|
|
|
126
124
|
},
|
|
127
125
|
width: {
|
|
128
126
|
fit: "fit-content",
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
"2xl": "42rem",
|
|
128
|
+
"4xl": "56rem",
|
|
131
129
|
},
|
|
132
130
|
maxWidth: {
|
|
133
131
|
fit: "fit-content",
|
|
@@ -158,6 +156,7 @@ module.exports = {
|
|
|
158
156
|
1: 1,
|
|
159
157
|
2: 2,
|
|
160
158
|
3: 3,
|
|
159
|
+
5: 5,
|
|
161
160
|
},
|
|
162
161
|
opacity: {
|
|
163
162
|
85: "0.85",
|
|
@@ -168,18 +167,6 @@ module.exports = {
|
|
|
168
167
|
boxShadow: {
|
|
169
168
|
thick: "0 0 30px rgba(0, 0, 0, 0.6)",
|
|
170
169
|
},
|
|
171
|
-
borderColor: {
|
|
172
|
-
// TODO: fix this invalid value in the future
|
|
173
|
-
// Read more: https://gitlab.grnet.gr/devs/digigov/digigov-sdk/-/merge_requests/818
|
|
174
|
-
DEFAULT: 'reset',
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
variants: {
|
|
179
|
-
extend: {
|
|
180
|
-
textDecoration: ["active"],
|
|
181
|
-
backgroundColor: ["active"],
|
|
182
|
-
borderColor: ["active"],
|
|
183
170
|
},
|
|
184
171
|
},
|
|
185
172
|
plugins: [plugin(themesPlugin)],
|
package/themes.plugin.js
CHANGED
|
@@ -13,85 +13,13 @@ const mediaQueriesMapping = {
|
|
|
13
13
|
print: "@media print",
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
function hexToRGB(hex) {
|
|
17
|
-
var r = parseInt(hex.slice(1, 3), 16),
|
|
18
|
-
g = parseInt(hex.slice(3, 5), 16),
|
|
19
|
-
b = parseInt(hex.slice(5, 7), 16);
|
|
20
|
-
|
|
21
|
-
return r + ", " + g + ", " + b;
|
|
22
|
-
}
|
|
23
16
|
let hasRun = false;
|
|
24
17
|
|
|
25
|
-
function addThemes({ addBase,
|
|
18
|
+
module.exports = function addThemes({ addBase, config }) {
|
|
26
19
|
if (hasRun) {
|
|
27
20
|
return;
|
|
28
21
|
}
|
|
29
22
|
hasRun = true;
|
|
30
|
-
function extractColorVars(colorObj, colorGroup = "") {
|
|
31
|
-
return Object.keys(colorObj).reduce((vars, colorKey) => {
|
|
32
|
-
const value = colorObj[colorKey];
|
|
33
|
-
const colorName =
|
|
34
|
-
colorKey == "default"
|
|
35
|
-
? `--color${colorGroup}`
|
|
36
|
-
: `--color${colorGroup}-${colorKey}`;
|
|
37
|
-
const newVars =
|
|
38
|
-
typeof value === "string"
|
|
39
|
-
? {
|
|
40
|
-
[colorName]: value,
|
|
41
|
-
[`${colorName}-rgb`]: hexToRGB(value),
|
|
42
|
-
}
|
|
43
|
-
: extractColorVars(value, `-${colorKey}`);
|
|
44
|
-
return { ...vars, ...newVars };
|
|
45
|
-
}, {});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function extractMediaQueriesFromComponentVars(componentObj, customTheme) {
|
|
49
|
-
let mediaObj = {};
|
|
50
|
-
Object.keys(componentObj).forEach((componentClass) => {
|
|
51
|
-
Object.keys(componentObj[componentClass]).forEach((componentAttr) => {
|
|
52
|
-
Object.keys(componentObj[componentClass][componentAttr]).forEach(
|
|
53
|
-
(componentMedia) => {
|
|
54
|
-
const newAttrKey = `--${componentClass}-${componentAttr}`;
|
|
55
|
-
const newAttrValue =
|
|
56
|
-
componentObj[componentClass][componentAttr][componentMedia];
|
|
57
|
-
const newAttr = { [newAttrKey]: newAttrValue };
|
|
58
|
-
const newClass = `.${prefix}-${componentClass}`;
|
|
59
|
-
const newMedia = mediaQueriesMapping[componentMedia];
|
|
60
|
-
const newTheme =
|
|
61
|
-
customTheme === defaultTheme ? "" : `.${customTheme}`;
|
|
62
|
-
|
|
63
|
-
if (mediaObj[newMedia]) {
|
|
64
|
-
if (mediaObj[newMedia][newTheme][newClass]) {
|
|
65
|
-
mediaObj[newMedia][newTheme][newClass][newAttrKey] =
|
|
66
|
-
newAttrValue;
|
|
67
|
-
} else {
|
|
68
|
-
mediaObj[newMedia][newTheme][newClass] = newAttr;
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
mediaObj[newMedia] = { [newTheme]: { [newClass]: newAttr } };
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
return mediaObj;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function extractGlobalVars(globalVarsObj) {
|
|
81
|
-
return Object.keys(globalVarsObj).reduce((vars, varKey) => {
|
|
82
|
-
const value = globalVarsObj[varKey];
|
|
83
|
-
vars[`--${varKey}`] = value;
|
|
84
|
-
return vars;
|
|
85
|
-
}, {});
|
|
86
|
-
}
|
|
87
|
-
function extractVars(themeObj) {
|
|
88
|
-
const colorVars = extractColorVars(themeObj.colors);
|
|
89
|
-
const globalVars =
|
|
90
|
-
themeObj.variables && themeObj.variables.globals
|
|
91
|
-
? extractGlobalVars(themeObj.variables.globals)
|
|
92
|
-
: {};
|
|
93
|
-
return { ...colorVars, ...globalVars };
|
|
94
|
-
}
|
|
95
23
|
|
|
96
24
|
let base = {};
|
|
97
25
|
const themes = config("themes");
|
|
@@ -99,30 +27,20 @@ function addThemes({ addBase, addComponents, theme, config }) {
|
|
|
99
27
|
for (const customTheme in themes) {
|
|
100
28
|
const customThemeObject = require(themes[customTheme]);
|
|
101
29
|
if (customThemeObject.overrides) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
.
|
|
106
|
-
path.resolve(
|
|
107
|
-
path.dirname(themes[customTheme]),
|
|
108
|
-
"overrides/index.css"
|
|
109
|
-
)
|
|
110
|
-
)
|
|
111
|
-
.toString();
|
|
112
|
-
const ctx = {};
|
|
113
|
-
const { plugins, options } = postcssrc.sync(ctx);
|
|
114
|
-
const result = postcss(plugins).process(css, options).root;
|
|
115
|
-
const cssJs = postcssJs.objectify(result);
|
|
116
|
-
base[`.${customTheme}`] = cssJs;
|
|
117
|
-
} else {
|
|
118
|
-
customThemeObject.overrides.forEach((override) => {
|
|
119
|
-
const cssJs = require(path.resolve(
|
|
30
|
+
console.log("Loading theme css from source...");
|
|
31
|
+
const css = fs
|
|
32
|
+
.readFileSync(
|
|
33
|
+
path.resolve(
|
|
120
34
|
path.dirname(themes[customTheme]),
|
|
121
|
-
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
35
|
+
"overrides/index.css",
|
|
36
|
+
),
|
|
37
|
+
)
|
|
38
|
+
.toString();
|
|
39
|
+
const ctx = {};
|
|
40
|
+
const { plugins, options } = postcssrc.sync(ctx);
|
|
41
|
+
const result = postcss(plugins).process(css, options).result.root;
|
|
42
|
+
const cssJs = postcssJs.objectify(result);
|
|
43
|
+
base[`.${customTheme}`] = cssJs;
|
|
126
44
|
}
|
|
127
45
|
if (customTheme === defaultTheme) {
|
|
128
46
|
base[`:root,:root.${customTheme},::before,::after`] =
|
|
@@ -136,7 +54,8 @@ function addThemes({ addBase, addComponents, theme, config }) {
|
|
|
136
54
|
if (customThemeObject.variables && customThemeObject.variables.components) {
|
|
137
55
|
const extractedVariables = extractMediaQueriesFromComponentVars(
|
|
138
56
|
customThemeObject.variables.components,
|
|
139
|
-
customTheme
|
|
57
|
+
customTheme,
|
|
58
|
+
defaultTheme,
|
|
140
59
|
);
|
|
141
60
|
Object.keys(extractedVariables).forEach((key) => {
|
|
142
61
|
if (base[key]) {
|
|
@@ -148,6 +67,82 @@ function addThemes({ addBase, addComponents, theme, config }) {
|
|
|
148
67
|
}
|
|
149
68
|
}
|
|
150
69
|
addBase(base);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function extractVars(themeObj) {
|
|
73
|
+
const colorVars = extractColorVars(themeObj.colors);
|
|
74
|
+
const globalVars =
|
|
75
|
+
themeObj.variables && themeObj.variables.globals
|
|
76
|
+
? extractGlobalVars(themeObj.variables.globals)
|
|
77
|
+
: {};
|
|
78
|
+
return { ...colorVars, ...globalVars };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function extractColorVars(colorObj, colorGroup = "") {
|
|
82
|
+
return Object.keys(colorObj).reduce((vars, colorKey) => {
|
|
83
|
+
const value = colorObj[colorKey];
|
|
84
|
+
const colorName =
|
|
85
|
+
colorKey == "default"
|
|
86
|
+
? `--color${colorGroup}`
|
|
87
|
+
: `--color${colorGroup}-${colorKey}`;
|
|
88
|
+
const newVars =
|
|
89
|
+
typeof value === "string"
|
|
90
|
+
? {
|
|
91
|
+
[colorName]: value,
|
|
92
|
+
[`${colorName}-rgb`]: hexToRGB(value),
|
|
93
|
+
}
|
|
94
|
+
: extractColorVars(value, `-${colorKey}`);
|
|
95
|
+
return { ...vars, ...newVars };
|
|
96
|
+
}, {});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function extractGlobalVars(globalVarsObj) {
|
|
100
|
+
return Object.keys(globalVarsObj).reduce((vars, varKey) => {
|
|
101
|
+
const value = globalVarsObj[varKey];
|
|
102
|
+
vars[`--${varKey}`] = value;
|
|
103
|
+
return vars;
|
|
104
|
+
}, {});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function hexToRGB(hex) {
|
|
108
|
+
const r = parseInt(hex.slice(1, 3), 16),
|
|
109
|
+
g = parseInt(hex.slice(3, 5), 16),
|
|
110
|
+
b = parseInt(hex.slice(5, 7), 16);
|
|
111
|
+
|
|
112
|
+
return r + ", " + g + ", " + b;
|
|
151
113
|
}
|
|
152
114
|
|
|
153
|
-
|
|
115
|
+
function extractMediaQueriesFromComponentVars(
|
|
116
|
+
componentObj,
|
|
117
|
+
customTheme,
|
|
118
|
+
defaultTheme,
|
|
119
|
+
) {
|
|
120
|
+
let mediaObj = {};
|
|
121
|
+
Object.keys(componentObj).forEach((componentClass) => {
|
|
122
|
+
Object.keys(componentObj[componentClass]).forEach((componentAttr) => {
|
|
123
|
+
Object.keys(componentObj[componentClass][componentAttr]).forEach(
|
|
124
|
+
(componentMedia) => {
|
|
125
|
+
const newAttrKey = `--${componentClass}-${componentAttr}`;
|
|
126
|
+
const newAttrValue =
|
|
127
|
+
componentObj[componentClass][componentAttr][componentMedia];
|
|
128
|
+
const newAttr = { [newAttrKey]: newAttrValue };
|
|
129
|
+
const newClass = `.${prefix}-${componentClass}`;
|
|
130
|
+
const newMedia = mediaQueriesMapping[componentMedia];
|
|
131
|
+
const newTheme =
|
|
132
|
+
customTheme === defaultTheme ? "" : `.${customTheme}`;
|
|
133
|
+
|
|
134
|
+
if (mediaObj[newMedia]) {
|
|
135
|
+
if (mediaObj[newMedia][newTheme][newClass]) {
|
|
136
|
+
mediaObj[newMedia][newTheme][newClass][newAttrKey] = newAttrValue;
|
|
137
|
+
} else {
|
|
138
|
+
mediaObj[newMedia][newTheme][newClass] = newAttr;
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
mediaObj[newMedia] = { [newTheme]: { [newClass]: newAttr } };
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
return mediaObj;
|
|
148
|
+
}
|