@digigov/css 0.29.11 → 0.29.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digigov/css",
3
- "version": "0.29.11",
3
+ "version": "0.29.13",
4
4
  "description": "Digigov CSS - Tailwind CSS Components",
5
5
  "author": "GRNET Devs <devs@lists.grnet.gr>",
6
6
  "license": "BSD-2-Clause",
@@ -24,16 +24,17 @@
24
24
  "dist",
25
25
  "!dist/components",
26
26
  "index.js",
27
+ "defaultTheme.js",
27
28
  "src",
28
29
  "colors",
29
- "color-vars.plugin.js",
30
+ "themes.plugin.js",
30
31
  "postcss.config.js",
31
32
  "tailwind.config.js"
32
33
  ],
33
34
  "publishConfig": {
34
35
  "access": "public",
35
36
  "branches": [
36
- "master"
37
+ "main"
37
38
  ]
38
39
  },
39
40
  "devDependencies": {
@@ -48,8 +49,10 @@
48
49
  "tailwindcss": "2.2.6",
49
50
  "nodemon": "2.0.7",
50
51
  "next": "10.0.9",
51
- "@digigov/postcss-banner": "0.3.18",
52
- "rimraf": "3.0.2"
52
+ "@digigov/postcss-banner": "0.3.19",
53
+ "rimraf": "3.0.2",
54
+ "postcss-js": "4.0.0",
55
+ "postcss-load-config": "3.1.4"
53
56
  },
54
57
  "scripts": {
55
58
  "preutilities": "DIGIGOV_CSS_BUILD=TRUE postcss --config src/utilities src/utilities/index.css --base src --dir dist",
@@ -1,7 +1,6 @@
1
1
  @import "tailwindcss/base";
2
2
   
3
3
  :root {
4
- color-scheme: light !important;
5
4
  accent-color: var(--color-accent);
6
5
  }
7
6
  html{
@@ -1,7 +1,8 @@
1
1
  const plugin = require('tailwindcss/plugin')
2
2
  const tailwindConfig = require('../../tailwind.config.js');
3
- const colorVarsPlugin = require('../../color-vars.plugin')
3
+ const themesPlugin = require('../../themes.plugin')
4
4
 
5
+ tailwindConfig.themes.dark = require.resolve('../../../../themes/govgr-dark');
5
6
  module.exports = {
6
7
  ...tailwindConfig,
7
8
  plugins: [
@@ -9,6 +10,6 @@ module.exports = {
9
10
  addComponents(require('../../dist/components'))
10
11
  addUtilities(require('../../dist/utilities'))
11
12
  }),
12
- plugin(colorVarsPlugin)
13
+ plugin(themesPlugin)
13
14
  ],
14
15
  }
@@ -71,7 +71,7 @@
71
71
  }
72
72
  }
73
73
  .govgr-btn-disabled {
74
- @apply bg-opacity-50 hover:bg-opacity-50 cursor-not-allowed
74
+ @apply opacity-50 hover:bg-opacity-50 cursor-not-allowed
75
75
  print:text-gray200 print:border-opacity-50;
76
76
  }
77
77
  .govgr-btn-link {
@@ -19,13 +19,12 @@
19
19
  -webkit-box-sizing: border-box;
20
20
  box-sizing: border-box;
21
21
  @apply absolute top-0 left-0 w-10 h-10
22
- border-base-content border-2 bg-transparent opacity-100;
22
+ border-solid border-base-content border-2 bg-white opacity-100;
23
23
  }
24
24
  &:after {
25
25
  content: "";
26
- -webkit-box-sizing: border-box;
27
- box-sizing: border-box;
28
- position: absolute;
26
+ @apply absolute bg-transparent opacity-0 box-border
27
+ border-accent border-b-5 border-l-5 border-t-0 border-r-0;
29
28
  top: 11px;
30
29
  left: 9px;
31
30
  width: 23px;
@@ -33,18 +32,10 @@
33
32
  -webkit-transform: rotate(-45deg);
34
33
  -ms-transform: rotate(-45deg);
35
34
  transform: rotate(-45deg);
36
- border: solid;
37
- border-width: 0 0 5px 5px;
38
- border-top-color: transparent;
39
- opacity: 0;
40
- background: transparent;
41
35
  }
42
36
  &:checked {
43
37
  &:after {
44
- opacity: 1;
45
- }
46
- &:before {
47
- background-color: white;
38
+ @apply opacity-100;
48
39
  }
49
40
  }
50
41
  &:focus {
@@ -52,7 +43,7 @@
52
43
  outline-offset: 1px;
53
44
  box-shadow: 0 0 0 4px var(--color-focus);
54
45
  &:before {
55
- border-width: 4px;
46
+ @apply border-4;
56
47
  }
57
48
  }
58
49
  }
@@ -0,0 +1,10 @@
1
+ /* Experimental css file. */
2
+
3
+ .dark {
4
+ /*
5
+ Here we can experiment with dark theme.
6
+ Storybook does not need restart when writing here.
7
+ Final styling should then go to themes/govgr-dark/overrides/index.css
8
+ */
9
+
10
+ }
@@ -93,7 +93,7 @@
93
93
  }
94
94
  .govgr-header, .govgr-admin-header {
95
95
  .govgr-dropdown__button.govgr-link {
96
- @apply text-lg text-white focus:text-base-content print:text-gray600;
96
+ @apply text-lg text-header-content focus:text-base-content print:text-gray600;
97
97
  }
98
98
  .govgr-dropdown {
99
99
  @apply print:hidden;
@@ -1,8 +1,7 @@
1
1
  .govgr-footer {
2
2
  @apply border-0 border-solid font-normal text-base py-4 md:py-8
3
3
  border-t-4 border-secondary600 text-gray600 bg-gray50 w-full
4
- print:py-2 print:bg-white print:border-t-2
5
- dark:border-secondary800 dark:text-gray800;
4
+ print:py-2 print:bg-white print:border-t-2;
6
5
  .govgr-section-break {
7
6
  @apply print:hidden;
8
7
  }
@@ -32,8 +31,12 @@
32
31
  @apply mr-0;
33
32
  }
34
33
  }
34
+ .govgr-footer__government-logo-inverted {
35
+ @apply max-w-full h-auto w-52 min-w-52 hidden;
36
+
37
+ }
35
38
  .govgr-footer__logo, .govgr-footer__government-logo {
36
- @apply max-w-full h-auto w-52 min-w-52;
39
+ @apply max-w-full h-auto w-52 min-w-52 block;
37
40
  }
38
41
  .govgr-footer__licence-description {
39
42
  @apply mt-6 print:mt-4;
@@ -15,9 +15,12 @@
15
15
  print:gap-1;
16
16
  }
17
17
  .govgr-header-title {
18
- @apply text-base100 font-bold text-2xl leading-10 tracking-wide no-underline
19
- w-auto align-middle hover:text-base100 hover:no-underline
18
+ @apply text-header-content font-bold text-2xl leading-10 tracking-wide no-underline
19
+ w-auto align-middle hover:no-underline
20
20
  print:text-base-content;
21
+ &:hover {
22
+ @apply text-header-content
23
+ }
21
24
  }
22
25
  .govgr-header-title:focus {
23
26
  text-decoration:none;
@@ -37,4 +37,5 @@
37
37
  @import "./skiplink.css";
38
38
  @import "./timeline.css";
39
39
  @import "./task-list.css";
40
- @import "./stepnav.css"
40
+ @import "./stepnav.css";
41
+ @import "./dev-theme.css";
@@ -43,10 +43,10 @@
43
43
  }
44
44
  }
45
45
  .govgr-section-break {
46
- @apply m-auto px-4 py-2 border-0 w-full;
46
+ @apply m-auto px-4 py-2 border-0 w-full bg-white;
47
47
  }
48
48
  .govgr-section-break--visible {
49
- @apply border-t border-gray100;
49
+ @apply border-t border-gray100 border-solid ;
50
50
  }
51
51
  .govgr-section-break--m {
52
52
  @apply mb-5;
@@ -1,6 +1,6 @@
1
1
  .govgr-header {
2
2
  .govgr-burger-icon {
3
- fill: var(--color-white) ;
3
+ fill: var(--color-header-content) ;
4
4
  }
5
5
  }
6
6
  .govgr-burger-icon {
@@ -71,14 +71,14 @@
71
71
  }
72
72
  }
73
73
  .govgr-horizontal-nav__item {
74
- @apply p-1 text-xl
74
+ @apply p-1 text-xl text-base-content
75
75
  sm:py-1 sm:px-1 sm:text-base
76
76
  no-underline hover:underline;
77
77
  }
78
78
  .govgr-horizontal-nav__item:focus {
79
79
  @apply bg-focus text-base-content outline-none;
80
80
  box-shadow: 0 -2px var(--color-focus), 0 4px var(--color-base-content);
81
- }
81
+ }
82
82
  .govgr-horizontal-nav__item-active, .govgr-vertical-nav__item--active {
83
83
  @apply font-semibold;
84
84
  }
@@ -15,7 +15,7 @@
15
15
  @apply table-cell text-base-content;
16
16
  }
17
17
  .govgr-header .govgr-phase-banner__text, .govgr-masthead .govgr-phase-banner__text {
18
- @apply text-white print:text-base-content;
18
+ @apply text-header-content print:text-base-content;
19
19
  }
20
20
  .govgr-phase-banner_header {
21
21
  @apply bg-focus top-0 z-30
@@ -1,5 +1,5 @@
1
1
  .govgr-radios__item {
2
- @apply block relative mb-4 pl-12;
2
+ @apply block relative mb-4 pl-12;
3
3
  min-height: 40px;
4
4
  }
5
5
  .govgr-radios--inline {
@@ -13,35 +13,30 @@
13
13
  }
14
14
  }
15
15
  .govgr-radios__label {
16
- @apply inline-block py-1 px-2 cursor-pointer text-lg ;
16
+ @apply inline-block py-1 px-2 cursor-pointer text-lg;
17
17
  }
18
18
  .govgr-radios__input {
19
19
  @apply absolute z-1 left-0.5 -top-1 m-0 rounded-3xl
20
- w-10 h-10 opacity-100 cursor-pointer;
20
+ w-10 h-10 opacity-100 cursor-pointer
21
+ bg-white m-0;
21
22
  appearance: none;
22
- background-color: #fff;
23
- margin: 0;
24
23
  width: 40px;
25
24
  height: 40px;
26
25
  border: 2px solid currentColor;
27
26
  border-radius: 50%;
28
27
  &::before {
29
28
  content: "";
30
- position: absolute;
29
+ @apply absolute bg-white opacity-0 w-0 h-0;
31
30
  top: 6px;
32
31
  left: 6px;
33
- width: 0;
34
- height: 0;
35
32
  border: 12px solid currentColor;
36
33
  border-radius: 50%;
37
- opacity: 0;
38
- background: currentColor;
39
34
  }
40
- &:checked {
35
+ &:checked {
41
36
  &::before {
42
- opacity: 1;
37
+ @apply opacity-100;
43
38
  }
44
- }
39
+ }
45
40
  &:focus {
46
41
  outline: 3px solid transparent;
47
42
  outline-offset: 1px;
@@ -52,4 +47,4 @@
52
47
  left: 4px;
53
48
  }
54
49
  }
55
- }
50
+ }
@@ -43,11 +43,11 @@
43
43
  .govgr-header, .govgr-admin-header {
44
44
  .govgr-link {
45
45
  .govgr-svg-icon {
46
- fill:var(--color-gray50);
46
+ fill:var(--color-header-content);
47
47
  }
48
48
  &:hover {
49
49
  .govgr-svg-icon {
50
- fill:var(--color-gray50);
50
+ fill:var(--color-header-content);
51
51
  }
52
52
  }
53
53
  &:focus {
@@ -116,10 +116,10 @@
116
116
  }
117
117
  .govgr-header {
118
118
  .govgr-header__container > .govgr-link {
119
- @apply text-gray50 focus:text-link-active print:text-base-content;
119
+ @apply text-header-content focus:text-link-active print:text-base-content;
120
120
  }
121
121
  .govgr-header__content > .govgr-link {
122
- @apply text-gray50 focus:text-link-active print:text-base-content;
122
+ @apply text-header-content focus:text-link-active print:text-base-content;
123
123
  }
124
124
  }
125
125
  .govgr-link--no-underline {
@@ -1,23 +1,98 @@
1
1
  const plugin = require("tailwindcss/plugin");
2
2
  const defaultTheme = require("tailwindcss/defaultTheme");
3
- const colors = require("./colors");
4
- const colorVarsPlugin = require("./color-vars.plugin");
3
+ const themesPlugin = require("./themes.plugin");
4
+
5
+ const allColors = [
6
+ "transparent",
7
+ "current",
8
+ "primary",
9
+ "primary-focus",
10
+ "primary200",
11
+ "secondary50",
12
+ "secondary200",
13
+ "secondary",
14
+ "secondary-focus",
15
+ "secondary400",
16
+ "secondary600",
17
+ "secondary800",
18
+ "content-dark",
19
+ "content",
20
+ "content-secondary",
21
+ "accent",
22
+ "accent-focus",
23
+ "accent-content",
24
+ "neutral",
25
+ "neutral-focus",
26
+ "neutral-content",
27
+ "header-content",
28
+ "base100",
29
+ "base150",
30
+ "base200",
31
+ "base300",
32
+ "base300-content",
33
+ "base-content",
34
+ "base-content-secondary",
35
+ "base-content-invert",
36
+ "info",
37
+ "success",
38
+ "success-hover",
39
+ "warning",
40
+ "error",
41
+ "error-hover",
42
+ "focus",
43
+ "link",
44
+ "link-hover",
45
+ "link-visited",
46
+ "link-active",
47
+ "white",
48
+ "gray50",
49
+ "gray100",
50
+ "gray200",
51
+ "base-bg",
52
+ "gray300",
53
+ "gray400",
54
+ "gray500",
55
+ "gray600",
56
+ "gray700",
57
+ "gray800",
58
+ "gray900",
59
+ "black",
60
+ "shadow200",
61
+ "shadow600",
62
+ ];
5
63
 
6
64
  const buildOnly = !process.env["DIGIGOV_CSS_BUILD"]
7
65
  ? {
8
66
  mode: "jit",
9
67
  }
10
68
  : {};
11
- const colorVariables = Object.keys(colors.light).reduce((allColors, color) => {
12
- allColors[color] = `var(--color-${color})`;
13
- return allColors;
69
+
70
+ const colorVariables = allColors.reduce((colorVars, color) => {
71
+ if(['transparent', 'currentColor'].includes(color)) {
72
+ colorVars[color] = color;
73
+ } else {
74
+ colorVars[color] = ({opacityVariable, opacityValue}) => {
75
+ if(opacityValue !== undefined) {
76
+ return `rgba(var(--color-${color}-rgb), ${opacityValue})`;
77
+ }
78
+ if(opacityVariable !== undefined) {
79
+ return `rgba(var(--color-${color}-rgb), var(${opacityVariable}, 1))`;
80
+ }
81
+ return `rgb(var(--color-${color}-rgb))`;
82
+ };
83
+ }
84
+ return colorVars;
14
85
  }, {});
86
+
15
87
  module.exports = {
16
88
  ...buildOnly,
17
89
  darkMode: 'class',
90
+ themes: {
91
+ light: require.resolve('./defaultTheme'),
92
+ },
93
+ defaultTheme: 'light',
18
94
  theme: {
19
- colors: colors.light,
20
- themes: colors,
95
+ colors: colorVariables,
21
96
  container: {
22
97
  center: true,
23
98
  },
@@ -32,14 +107,11 @@ module.exports = {
32
107
  lg: "1024px",
33
108
  xl: "1280px",
34
109
  "2xl": "1280px",
35
- print: { raw: "print" },
110
+ print: {raw: "print"},
36
111
  },
37
112
  fontFamily: {
38
113
  sans: ["Roboto", ...defaultTheme.fontFamily.sans],
39
114
  },
40
- borderColor: colorVariables,
41
- backgroundColor: colorVariables,
42
- textColor: colorVariables,
43
115
  extend: {
44
116
  height: {
45
117
  fit: "fit-content",
@@ -93,5 +165,5 @@ module.exports = {
93
165
  borderColor: ["active"],
94
166
  },
95
167
  },
96
- plugins: [plugin(colorVarsPlugin)],
168
+ plugins: [plugin(themesPlugin)],
97
169
  };
@@ -0,0 +1,74 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const postcss = require('postcss');
4
+ const postcssrc = require('postcss-load-config');
5
+ const postcssJs = require('postcss-js');
6
+
7
+ function hexToRGB(hex) {
8
+ var r = parseInt(hex.slice(1, 3), 16),
9
+ g = parseInt(hex.slice(3, 5), 16),
10
+ b = parseInt(hex.slice(5, 7), 16);
11
+
12
+ return r + ", " + g + ", " + b;
13
+ }
14
+ let hasRun = false;
15
+
16
+ function addThemes({ addBase, addComponents, theme,config }) {
17
+ if(hasRun){
18
+ return
19
+ }
20
+ hasRun = true;
21
+ function extractColorVars(colorObj, colorGroup = "") {
22
+ return Object.keys(colorObj).reduce(
23
+ (vars, colorKey) => {
24
+ const value = colorObj[colorKey];
25
+
26
+ const newVars =
27
+ typeof value === "string"
28
+ ? {
29
+ [`--color${colorGroup}-${colorKey}`]: value,
30
+ [`--color${colorGroup}-${colorKey}-rgb`]: hexToRGB(value),
31
+ }
32
+ : extractColorVars(value, `-${colorKey}`);
33
+
34
+ return { ...vars, ...newVars };
35
+ },
36
+ { }
37
+ );
38
+ }
39
+ const base = {
40
+ }
41
+
42
+
43
+ const themes = config("themes");
44
+ const defaultTheme = config('defaultTheme');
45
+ for (const customTheme in themes) {
46
+
47
+ const customThemeObject = require(themes[customTheme]);
48
+ if (customThemeObject.overrides) {
49
+ if(config('mode') === 'jit'){
50
+ console.log('Loading theme css from source!')
51
+ const css = fs.readFileSync(path.resolve(path.dirname(themes[customTheme]),'overrides/index.css')).toString();
52
+ const ctx = { };
53
+ const {plugins, options} = postcssrc.sync(ctx)
54
+ const result = postcss(plugins)
55
+ .process(css, options).root;
56
+ const cssJs = postcssJs.objectify(result);
57
+ addComponents({[`.${customTheme}`]: cssJs});
58
+ }else{
59
+ customThemeObject.overrides.forEach(async(override) => {
60
+ const cssJs = require(path.resolve(path.dirname(themes[customTheme]),override));
61
+ addComponents({[`.${customTheme}`]: cssJs});
62
+ });
63
+ }
64
+ }
65
+ if (customTheme === defaultTheme) {
66
+ base[`:root,:root.${customTheme},::before,::after`] = extractColorVars(customThemeObject.colors);
67
+ } else {
68
+ base[`:root.${customTheme},.${customTheme} *::before,.${customTheme} *::after`] = extractColorVars(customThemeObject.colors);
69
+ }
70
+ }
71
+ addBase(base);
72
+ }
73
+
74
+ module.exports = addThemes;
@@ -1,21 +0,0 @@
1
-
2
- function addColorVars ({ addBase, theme }) {
3
- function extractColorVars(colorObj, colorGroup = '') {
4
- return Object.keys(colorObj).reduce((vars, colorKey) => {
5
- const value = colorObj[colorKey];
6
-
7
- const newVars =
8
- typeof value === 'string'
9
- ? { [`--color${colorGroup}-${colorKey}`]: value }
10
- : extractColorVars(value, `-${colorKey}`);
11
-
12
- return { ...vars, ...newVars };
13
- }, {});
14
- }
15
- addBase({
16
- ':root,:root.light': extractColorVars(theme('themes').light),
17
- ':root.dark': extractColorVars(theme('themes').dark),
18
- });
19
- }
20
-
21
- module.exports = addColorVars;
@@ -1,68 +0,0 @@
1
- module.exports = {
2
- name: 'dark',
3
- colors: {
4
- "primary": "#003375",
5
- "primary-focus": "#004594",
6
- "primary200": "#002152",
7
-
8
- "secondary50": "#4dd5ff",
9
- "secondary200": "#00b0f0",
10
- "secondary": "#00b0f0",
11
- "secondary-focus": "#0081d6",
12
- "secondary400": "#0081d6",
13
- "secondary600": "#0065b3",
14
- "secondary800": "#004594",
15
-
16
- "content-dark": "#fff",
17
- "content": "#212930",
18
- "content-secondary":"#56565d",
19
-
20
- "accent": "#212930", /* Accent sets the color for user-interface controls generated by some elements (checkbox, radio, range input, progress tag).*/
21
- "accent-focus": "#2aa79b",
22
- "accent-content": "#fff",
23
- "neutral": "#43454c",
24
- "neutral-focus": "#31363f",
25
- "neutral-content": "#fff",
26
-
27
- "base100": "#56565d",
28
- "base150": "#99989a",
29
- "base200": "#b3b2b3",
30
- "base300": "#ebebeb",
31
- "base300-content": "#fff",
32
- "base-content": "#fff",
33
- "base-content-secondary": "#56565d",
34
- "base-content-invert": "#1B2127",
35
-
36
- "info": "#00b0f0",
37
- "success": "#07CA4D",
38
- "success-hover": "#118f1e",
39
- "warning": "#f90",
40
- "error": "#FF3838",
41
- "error-hover": "#B60202",
42
- "focus": "#fd0",
43
- "link": "#00b0f0",
44
- "link-hover": "#0081d6",
45
- "link-visited": "#9772FD",
46
- "link-active": "#0065b3",
47
-
48
- "white": "#1B2127",
49
- "gray50": "#212930",
50
- "gray100": "#31363f",
51
- "gray200": "#43454c",
52
- "base-bg": "#43454c",
53
- "gray300": "#56565d",
54
- "gray400": "#6c6a71",
55
- "gray500": "#828085",
56
- "gray600": "#99989a",
57
- "gray700": "#b3b2b3",
58
- "gray800": "#ccc",
59
- "gray900": "#ebebeb",
60
- "black": "#fff",
61
-
62
- "shadow200" : "#21293033",
63
- "shadow600" :"#21293099",
64
- }
65
-
66
- }
67
-
68
-
package/colors/index.js DELETED
@@ -1,17 +0,0 @@
1
- const colorValuesLight = require('./color-values.light');
2
- const colorValuesDark = require('./color-values.dark');
3
- const themeObject = {};
4
- const themes = [ colorValuesLight, colorValuesDark];
5
-
6
- themes.forEach((theme)=> {
7
- const colorObject = {
8
- "transparent": "transparent",
9
- "current": "currentColor",
10
- }
11
- for (const [key, value] of Object.entries(theme.colors)) {
12
- colorObject[key] = value.startsWith('#')?value:value.startsWith('rgb')?value:`hsl(${value})`
13
- }
14
- themeObject[theme.name] = colorObject;
15
- })
16
-
17
- module.exports = {...themeObject};