@digigov/css 1.0.0-290a96e2 → 1.0.0-47312a12
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 +4 -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/card.css +13 -1
- 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/footer.css +1 -0
- package/src/components/form.css +19 -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/misc.css +9 -1
- 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 +12 -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/task-list.css +8 -0
- package/src/components/timeline.css +14 -6
- package/src/components/typography.css +24 -1
- 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 +94 -99
- package/src/components/accessibility-menu.css +0 -76
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,44 +27,35 @@ 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`] =
|
|
129
47
|
extractVars(customThemeObject);
|
|
130
48
|
} else {
|
|
131
49
|
base[
|
|
132
|
-
`:root.${customTheme},.${customTheme} *::before,.${customTheme} *::after`
|
|
50
|
+
`:root.${customTheme},.${customTheme},.${customTheme} *::before,.${customTheme} *::after`
|
|
133
51
|
] = extractVars(customThemeObject);
|
|
134
52
|
}
|
|
135
53
|
|
|
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
|
+
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
.govgr-accessibility-menu {}
|
|
2
|
-
.govgr-accessibility-menu--left {
|
|
3
|
-
.govgr-accessibility-menu__btn {
|
|
4
|
-
@apply left-4;
|
|
5
|
-
}
|
|
6
|
-
.govgr-accessibility-menu__content {
|
|
7
|
-
@apply left-0;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
.govgr-accessibility-menu--right {
|
|
11
|
-
.govgr-accessibility-menu__btn {
|
|
12
|
-
@apply right-4;
|
|
13
|
-
}
|
|
14
|
-
.govgr-accessibility-menu__content {
|
|
15
|
-
@apply right-0;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
.govgr-accessibility-menu__btn {
|
|
19
|
-
@apply absolute bottom-4 bg-base-300;
|
|
20
|
-
@apply p-4 rounded-full !important;
|
|
21
|
-
box-shadow: 0px 2px 5px rgba(var(--color-base-900-rgb), 0.3);
|
|
22
|
-
&:hover {
|
|
23
|
-
@apply bg-base-400;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
.govgr-accessibility-menu__content {
|
|
27
|
-
@apply bg-base-200 absolute top-0 bottom-0 p-4 flex flex-col max-w-md;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.govgr-accessibility-menu__header {
|
|
31
|
-
@apply inline-flex justify-between items-center mb-6 gap-2;
|
|
32
|
-
}
|
|
33
|
-
.govgr-accessibility-menu__header-btn {
|
|
34
|
-
@apply flex flex-nowrap;
|
|
35
|
-
}
|
|
36
|
-
.govgr-accessibility-menu__body {
|
|
37
|
-
@apply overflow-y-scroll p-3 flex-grow;
|
|
38
|
-
}
|
|
39
|
-
.govgr-accessibility-menu__list {
|
|
40
|
-
@apply grid grid-cols-1 sm:grid-cols-2 gap-5;
|
|
41
|
-
}
|
|
42
|
-
.govgr-accessibility-menu__list-item {
|
|
43
|
-
@apply col-span-1;
|
|
44
|
-
}
|
|
45
|
-
.govgr-accessibility-menu__option-btn {
|
|
46
|
-
@apply flex flex-col gap-2;
|
|
47
|
-
@apply bg-base-100 border-base-100 border-2;
|
|
48
|
-
@apply w-full sm:w-fit leading-tight m-0 !important;
|
|
49
|
-
padding: calc(1rem + 2px) !important;
|
|
50
|
-
&:hover {
|
|
51
|
-
@apply border-base-content;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
.govgr-accessibility-menu__option-btn--selected {
|
|
55
|
-
@apply border-success border-4 text-success p-4 !important;
|
|
56
|
-
.govgr-accessibility-menu__steps {
|
|
57
|
-
@apply opacity-100;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
.govgr-accessibility-menu__steps {
|
|
61
|
-
@apply flex flex-nowrap w-full gap-2 h-1 mt-2 opacity-0;
|
|
62
|
-
}
|
|
63
|
-
.govgr-accessibility-menu__step {
|
|
64
|
-
@apply bg-base-300 w-full;
|
|
65
|
-
}
|
|
66
|
-
.govgr-accessibility-menu__step--active {
|
|
67
|
-
@apply bg-success;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* overrides */
|
|
71
|
-
|
|
72
|
-
.govgr-accessibility-menu__option-btn--selected {
|
|
73
|
-
.govgr-svg-icon {
|
|
74
|
-
fill: var(--color-success) !important;
|
|
75
|
-
}
|
|
76
|
-
}
|