@dhis2-ui/css 9.11.0 → 9.11.1-beta.10
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/build/cjs/css-reset/css-reset.js +2 -8
- package/build/cjs/css-reset/{css-reset.stories.js → css-reset.prod.stories.js} +10 -10
- package/build/cjs/css-reset/index.js +0 -1
- package/build/cjs/css-variables/css-variables.e2e.stories.js +58 -0
- package/build/cjs/css-variables/css-variables.js +17 -22
- package/build/cjs/css-variables/{css-variables.stories.js → css-variables.prod.stories.js} +9 -14
- package/build/cjs/css-variables/features/sets_variables/index.js +0 -1
- package/build/cjs/css-variables/index.js +0 -1
- package/build/cjs/index.js +0 -2
- package/build/es/css-reset/css-reset.js +1 -3
- package/build/es/css-reset/{css-reset.stories.js → css-reset.prod.stories.js} +9 -2
- package/build/es/css-variables/{css-variables.stories.e2e.js → css-variables.e2e.stories.js} +13 -7
- package/build/es/css-variables/css-variables.js +14 -12
- package/build/es/css-variables/{css-variables.stories.js → css-variables.prod.stories.js} +6 -2
- package/package.json +5 -5
- package/build/cjs/css-variables/css-variables.stories.e2e.js +0 -47
|
@@ -4,18 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CssReset = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
11
|
const CssReset = () => /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
17
12
|
id: "3745978156",
|
|
18
13
|
dynamic: [_uiConstants.theme.fonts, _uiConstants.theme.fonts]
|
|
19
|
-
}, ["html{line-height:1.15;-webkit-text-size-adjust:100%;box-sizing:border-box;}",
|
|
20
|
-
|
|
14
|
+
}, ["html{line-height:1.15;-webkit-text-size-adjust:100%;box-sizing:border-box;}", `*,*:before,*:after{font-family:${_uiConstants.theme.fonts};box-sizing:inherit;}`, `body{margin:0;font-family:${_uiConstants.theme.fonts};}`, "main{display:block;}", "h1{font-size:2em;margin:0.67em 0;}", "hr{box-sizing:content-box;height:0;overflow:visible;}", "pre{font-family:monospace,monospace;font-size:1em;}", "a{background-color:transparent;}", "abbr[title]{border-bottom:none;-webkit-text-decoration:underline;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;}", "b,strong{font-weight:bolder;}", "code,kbd,samp{font-family:monospace,monospace;font-size:1em;}", "small{font-size:80%;}", "sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}", "sub{bottom:-0.25em;}", "sup{top:-0.5em;}", "img{border-style:none;}", "button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}", "button,input{overflow:visible;}", "button,select{text-transform:none;}", "button,[type='button'],[type='reset'],[type='submit']{-webkit-appearance:button;}", "button::-moz-focus-inner,[type='button']::-moz-focus-inner,[type='reset']::-moz-focus-inner,[type='submit']::-moz-focus-inner{border-style:none;padding:0;}", "button:-moz-focusring,[type='button']:-moz-focusring,[type='reset']:-moz-focusring,[type='submit']:-moz-focusring{outline:1px dotted ButtonText;}", "fieldset{padding:0.35em 0.75em 0.625em;}", "legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}", "progress{vertical-align:baseline;}", "textarea{overflow:auto;}", "[type='checkbox'],[type='radio']{box-sizing:border-box;padding:0;}", "[type='number']::-webkit-inner-spin-button,[type='number']::-webkit-outer-spin-button{height:auto;}", "[type='search']{-webkit-appearance:textfield;outline-offset:-2px;}", "[type='search']::-webkit-search-decoration{-webkit-appearance:none;}", "::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}", "details{display:block;}", "summary{display:list-item;}", "template{display:none;}", "[hidden]{display:none;}"]);
|
|
21
15
|
exports.CssReset = CssReset;
|
|
@@ -4,23 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.Default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _index = require("./index.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const description = `
|
|
11
|
+
A tool for adding a global normalization stylesheet into the DOM that applies DHIS2 styles.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const description = "\nA tool for adding a global normalization stylesheet into the DOM that applies DHIS2 styles.\n\n- https://github.com/necolas/normalize.css\n- https://www.paulirish.com/2012/box-sizing-border-box-ftw/\n\n```js\nimport { CssReset } from '@dhis2/ui'\n```\n";
|
|
13
|
+
- https://github.com/necolas/normalize.css
|
|
14
|
+
- https://www.paulirish.com/2012/box-sizing-border-box-ftw/
|
|
15
15
|
|
|
16
|
+
\`\`\`js
|
|
17
|
+
import { CssReset } from '@dhis2/ui'
|
|
18
|
+
\`\`\`
|
|
19
|
+
`;
|
|
16
20
|
const App = _ref => {
|
|
17
21
|
let {
|
|
18
22
|
children
|
|
19
23
|
} = _ref;
|
|
20
24
|
return /*#__PURE__*/_react.default.createElement("div", null, children);
|
|
21
25
|
};
|
|
22
|
-
|
|
23
|
-
var _default = {
|
|
26
|
+
var _default = exports.default = {
|
|
24
27
|
title: 'CSS Reset',
|
|
25
28
|
component: _index.CssReset,
|
|
26
29
|
parameters: {
|
|
@@ -31,8 +34,5 @@ var _default = {
|
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
};
|
|
34
|
-
exports.default = _default;
|
|
35
|
-
|
|
36
37
|
const Default = args => /*#__PURE__*/_react.default.createElement(App, null, /*#__PURE__*/_react.default.createElement(_index.CssReset, args), /*#__PURE__*/_react.default.createElement("p", null, "The ", /*#__PURE__*/_react.default.createElement("code", null, "CssReset"), " component injects a global normalization stylesheet into the DOM that sets the DHIS2 application defaults."), /*#__PURE__*/_react.default.createElement("p", null, "This also sets the ", /*#__PURE__*/_react.default.createElement("code", null, "font-family"), " on the ", /*#__PURE__*/_react.default.createElement("code", null, "body"), ' ', "element to the DHIS2 font, which allows it to trickle down to the components as well."), /*#__PURE__*/_react.default.createElement("p", null, "Just include the component in your application, preferably as early as possible to avoid FOUC.", ' '));
|
|
37
|
-
|
|
38
38
|
exports.Default = Default;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithTheme = exports.WithSpacers = exports.WithLayers = exports.WithElevations = exports.WithColors = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _index = require("./index.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
var _default = exports.default = {
|
|
11
|
+
title: 'CssVariables'
|
|
12
|
+
};
|
|
13
|
+
const WithColors = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.CssVariables, {
|
|
14
|
+
colors: true
|
|
15
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
16
|
+
id: "custom",
|
|
17
|
+
style: {
|
|
18
|
+
backgroundColor: 'var(--colors-blue900)'
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
exports.WithColors = WithColors;
|
|
22
|
+
const WithTheme = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.CssVariables, {
|
|
23
|
+
theme: true
|
|
24
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
25
|
+
id: "custom",
|
|
26
|
+
style: {
|
|
27
|
+
backgroundColor: 'var(--theme-primary900)'
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
30
|
+
exports.WithTheme = WithTheme;
|
|
31
|
+
const WithLayers = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.CssVariables, {
|
|
32
|
+
layers: true
|
|
33
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
34
|
+
id: "custom",
|
|
35
|
+
style: {
|
|
36
|
+
zIndex: 'var(--layers-alert)',
|
|
37
|
+
position: 'absolute'
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
exports.WithLayers = WithLayers;
|
|
41
|
+
const WithSpacers = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.CssVariables, {
|
|
42
|
+
spacers: true
|
|
43
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
44
|
+
id: "custom",
|
|
45
|
+
style: {
|
|
46
|
+
margin: 'var(--spacers-dp4)'
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
exports.WithSpacers = WithSpacers;
|
|
50
|
+
const WithElevations = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.CssVariables, {
|
|
51
|
+
elevations: true
|
|
52
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
53
|
+
id: "custom",
|
|
54
|
+
style: {
|
|
55
|
+
boxShadow: 'var(--elevations-e100)'
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
exports.WithElevations = WithElevations;
|
|
@@ -4,32 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CssVariables = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var theme = _interopRequireWildcard(require("@dhis2/ui-constants"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const toPrefixedThemeSection = themeSectionKey => Object.entries(theme[themeSectionKey]).reduce((prefixed, _ref) => {
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const toPrefixedThemeSection = themeSectionKey =>
|
|
15
|
+
// eslint-disable-next-line import/namespace
|
|
16
|
+
Object.entries(theme[themeSectionKey]).reduce((prefixed, _ref) => {
|
|
23
17
|
let [key, value] = _ref;
|
|
24
|
-
prefixed[
|
|
18
|
+
prefixed[`${themeSectionKey}-${key}`] = value;
|
|
25
19
|
return prefixed;
|
|
26
20
|
}, {});
|
|
27
|
-
|
|
28
21
|
const toCustomPropertyString = themeSection => Object.entries(themeSection).map(_ref2 => {
|
|
29
22
|
let [key, value] = _ref2;
|
|
30
|
-
return
|
|
23
|
+
return `--${key}: ${value};`;
|
|
31
24
|
}).join('\n');
|
|
32
|
-
|
|
33
25
|
const CssVariables = _ref3 => {
|
|
34
26
|
let {
|
|
35
27
|
colors,
|
|
@@ -45,17 +37,20 @@ const CssVariables = _ref3 => {
|
|
|
45
37
|
spacers,
|
|
46
38
|
elevations
|
|
47
39
|
};
|
|
48
|
-
const variables = Object.keys(allowedProps)
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
|
|
40
|
+
const variables = Object.keys(allowedProps)
|
|
41
|
+
// Filter all props that are false
|
|
42
|
+
.filter(prop => allowedProps[prop])
|
|
43
|
+
// Map props to corresponding theme section and prefixes keys with section name
|
|
44
|
+
.map(toPrefixedThemeSection)
|
|
45
|
+
// Map each section to a single string of css custom property declarations
|
|
46
|
+
.map(toCustomPropertyString)
|
|
47
|
+
// Join all the sections to a single string
|
|
52
48
|
.join('\n');
|
|
53
49
|
return /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
54
50
|
id: "3443925957",
|
|
55
51
|
dynamic: [variables]
|
|
56
|
-
}, [
|
|
52
|
+
}, [`html{${variables};}`]);
|
|
57
53
|
};
|
|
58
|
-
|
|
59
54
|
exports.CssVariables = CssVariables;
|
|
60
55
|
CssVariables.defaultProps = {
|
|
61
56
|
colors: false,
|
|
@@ -4,23 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.NoVariables = exports.AllVariables = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _index = require("./index.js");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const description = `
|
|
11
|
+
A utility for adding DHIS2 theme variables to global CSS variables.
|
|
12
|
+
|
|
13
|
+
\`\`\`js
|
|
14
|
+
import { CssVariables } from '@dhis2/ui'
|
|
15
|
+
\`\`\`
|
|
16
|
+
`;
|
|
16
17
|
const App = _ref => {
|
|
17
18
|
let {
|
|
18
19
|
children
|
|
19
20
|
} = _ref;
|
|
20
21
|
return /*#__PURE__*/_react.default.createElement("div", null, children);
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
-
var _default = {
|
|
23
|
+
var _default = exports.default = {
|
|
24
24
|
title: 'CSS Variables',
|
|
25
25
|
component: _index.CssVariables,
|
|
26
26
|
parameters: {
|
|
@@ -31,8 +31,6 @@ var _default = {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
exports.default = _default;
|
|
35
|
-
|
|
36
34
|
const AllVariables = args => /*#__PURE__*/_react.default.createElement(App, null, /*#__PURE__*/_react.default.createElement(_index.CssVariables, args), /*#__PURE__*/_react.default.createElement("p", null, "The sections of the theme that should be inserted can be toggled with flags, which allows the theme variables to be used as regular CSS custom properties. So this", ' ', /*#__PURE__*/_react.default.createElement("span", {
|
|
37
35
|
style: {
|
|
38
36
|
color: 'var(--colors-red500)'
|
|
@@ -42,7 +40,6 @@ const AllVariables = args => /*#__PURE__*/_react.default.createElement(App, null
|
|
|
42
40
|
color: 'var(--colors-blue500)'
|
|
43
41
|
}
|
|
44
42
|
}, "custom properties"), ' ', "set by the CssVariables component."));
|
|
45
|
-
|
|
46
43
|
exports.AllVariables = AllVariables;
|
|
47
44
|
AllVariables.args = {
|
|
48
45
|
colors: true,
|
|
@@ -51,7 +48,5 @@ AllVariables.args = {
|
|
|
51
48
|
spacers: true,
|
|
52
49
|
elevations: true
|
|
53
50
|
};
|
|
54
|
-
|
|
55
51
|
const NoVariables = args => /*#__PURE__*/_react.default.createElement(App, null, /*#__PURE__*/_react.default.createElement(_index.CssVariables, args), /*#__PURE__*/_react.default.createElement("p", null, "By default no custom properties are inserted."));
|
|
56
|
-
|
|
57
52
|
exports.NoVariables = NoVariables;
|
package/build/cjs/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
2
|
import { theme } from '@dhis2/ui-constants';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
|
|
5
4
|
const CssReset = () => /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
6
5
|
id: "3745978156",
|
|
7
6
|
dynamic: [theme.fonts, theme.fonts]
|
|
8
|
-
}, ["html{line-height:1.15;-webkit-text-size-adjust:100%;box-sizing:border-box;}",
|
|
9
|
-
|
|
7
|
+
}, ["html{line-height:1.15;-webkit-text-size-adjust:100%;box-sizing:border-box;}", `*,*:before,*:after{font-family:${theme.fonts};box-sizing:inherit;}`, `body{margin:0;font-family:${theme.fonts};}`, "main{display:block;}", "h1{font-size:2em;margin:0.67em 0;}", "hr{box-sizing:content-box;height:0;overflow:visible;}", "pre{font-family:monospace,monospace;font-size:1em;}", "a{background-color:transparent;}", "abbr[title]{border-bottom:none;-webkit-text-decoration:underline;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;}", "b,strong{font-weight:bolder;}", "code,kbd,samp{font-family:monospace,monospace;font-size:1em;}", "small{font-size:80%;}", "sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}", "sub{bottom:-0.25em;}", "sup{top:-0.5em;}", "img{border-style:none;}", "button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}", "button,input{overflow:visible;}", "button,select{text-transform:none;}", "button,[type='button'],[type='reset'],[type='submit']{-webkit-appearance:button;}", "button::-moz-focus-inner,[type='button']::-moz-focus-inner,[type='reset']::-moz-focus-inner,[type='submit']::-moz-focus-inner{border-style:none;padding:0;}", "button:-moz-focusring,[type='button']:-moz-focusring,[type='reset']:-moz-focusring,[type='submit']:-moz-focusring{outline:1px dotted ButtonText;}", "fieldset{padding:0.35em 0.75em 0.625em;}", "legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}", "progress{vertical-align:baseline;}", "textarea{overflow:auto;}", "[type='checkbox'],[type='radio']{box-sizing:border-box;padding:0;}", "[type='number']::-webkit-inner-spin-button,[type='number']::-webkit-outer-spin-button{height:auto;}", "[type='search']{-webkit-appearance:textfield;outline-offset:-2px;}", "[type='search']::-webkit-search-decoration{-webkit-appearance:none;}", "::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}", "details{display:block;}", "summary{display:list-item;}", "template{display:none;}", "[hidden]{display:none;}"]);
|
|
10
8
|
export { CssReset };
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CssReset } from './index.js';
|
|
3
|
-
const description =
|
|
3
|
+
const description = `
|
|
4
|
+
A tool for adding a global normalization stylesheet into the DOM that applies DHIS2 styles.
|
|
4
5
|
|
|
6
|
+
- https://github.com/necolas/normalize.css
|
|
7
|
+
- https://www.paulirish.com/2012/box-sizing-border-box-ftw/
|
|
8
|
+
|
|
9
|
+
\`\`\`js
|
|
10
|
+
import { CssReset } from '@dhis2/ui'
|
|
11
|
+
\`\`\`
|
|
12
|
+
`;
|
|
5
13
|
const App = _ref => {
|
|
6
14
|
let {
|
|
7
15
|
children
|
|
8
16
|
} = _ref;
|
|
9
17
|
return /*#__PURE__*/React.createElement("div", null, children);
|
|
10
18
|
};
|
|
11
|
-
|
|
12
19
|
export default {
|
|
13
20
|
title: 'CSS Reset',
|
|
14
21
|
component: CssReset,
|
package/build/es/css-variables/{css-variables.stories.e2e.js → css-variables.e2e.stories.js}
RENAMED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { storiesOf } from '@storybook/react';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { CssVariables } from './index.js';
|
|
4
|
-
|
|
3
|
+
export default {
|
|
4
|
+
title: 'CssVariables'
|
|
5
|
+
};
|
|
6
|
+
export const WithColors = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CssVariables, {
|
|
5
7
|
colors: true
|
|
6
8
|
}), /*#__PURE__*/React.createElement("div", {
|
|
7
9
|
id: "custom",
|
|
8
10
|
style: {
|
|
9
11
|
backgroundColor: 'var(--colors-blue900)'
|
|
10
12
|
}
|
|
11
|
-
}))
|
|
13
|
+
}));
|
|
14
|
+
export const WithTheme = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CssVariables, {
|
|
12
15
|
theme: true
|
|
13
16
|
}), /*#__PURE__*/React.createElement("div", {
|
|
14
17
|
id: "custom",
|
|
15
18
|
style: {
|
|
16
19
|
backgroundColor: 'var(--theme-primary900)'
|
|
17
20
|
}
|
|
18
|
-
}))
|
|
21
|
+
}));
|
|
22
|
+
export const WithLayers = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CssVariables, {
|
|
19
23
|
layers: true
|
|
20
24
|
}), /*#__PURE__*/React.createElement("div", {
|
|
21
25
|
id: "custom",
|
|
@@ -23,18 +27,20 @@ storiesOf('CssVariables', module).add('With colors', () => /*#__PURE__*/React.cr
|
|
|
23
27
|
zIndex: 'var(--layers-alert)',
|
|
24
28
|
position: 'absolute'
|
|
25
29
|
}
|
|
26
|
-
}))
|
|
30
|
+
}));
|
|
31
|
+
export const WithSpacers = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CssVariables, {
|
|
27
32
|
spacers: true
|
|
28
33
|
}), /*#__PURE__*/React.createElement("div", {
|
|
29
34
|
id: "custom",
|
|
30
35
|
style: {
|
|
31
36
|
margin: 'var(--spacers-dp4)'
|
|
32
37
|
}
|
|
33
|
-
}))
|
|
38
|
+
}));
|
|
39
|
+
export const WithElevations = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CssVariables, {
|
|
34
40
|
elevations: true
|
|
35
41
|
}), /*#__PURE__*/React.createElement("div", {
|
|
36
42
|
id: "custom",
|
|
37
43
|
style: {
|
|
38
44
|
boxShadow: 'var(--elevations-e100)'
|
|
39
45
|
}
|
|
40
|
-
}))
|
|
46
|
+
}));
|
|
@@ -2,18 +2,17 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import * as theme from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const toPrefixedThemeSection = themeSectionKey =>
|
|
6
|
+
// eslint-disable-next-line import/namespace
|
|
7
|
+
Object.entries(theme[themeSectionKey]).reduce((prefixed, _ref) => {
|
|
7
8
|
let [key, value] = _ref;
|
|
8
|
-
prefixed[
|
|
9
|
+
prefixed[`${themeSectionKey}-${key}`] = value;
|
|
9
10
|
return prefixed;
|
|
10
11
|
}, {});
|
|
11
|
-
|
|
12
12
|
const toCustomPropertyString = themeSection => Object.entries(themeSection).map(_ref2 => {
|
|
13
13
|
let [key, value] = _ref2;
|
|
14
|
-
return
|
|
14
|
+
return `--${key}: ${value};`;
|
|
15
15
|
}).join('\n');
|
|
16
|
-
|
|
17
16
|
const CssVariables = _ref3 => {
|
|
18
17
|
let {
|
|
19
18
|
colors,
|
|
@@ -29,17 +28,20 @@ const CssVariables = _ref3 => {
|
|
|
29
28
|
spacers,
|
|
30
29
|
elevations
|
|
31
30
|
};
|
|
32
|
-
const variables = Object.keys(allowedProps)
|
|
33
|
-
|
|
34
|
-
.
|
|
35
|
-
|
|
31
|
+
const variables = Object.keys(allowedProps)
|
|
32
|
+
// Filter all props that are false
|
|
33
|
+
.filter(prop => allowedProps[prop])
|
|
34
|
+
// Map props to corresponding theme section and prefixes keys with section name
|
|
35
|
+
.map(toPrefixedThemeSection)
|
|
36
|
+
// Map each section to a single string of css custom property declarations
|
|
37
|
+
.map(toCustomPropertyString)
|
|
38
|
+
// Join all the sections to a single string
|
|
36
39
|
.join('\n');
|
|
37
40
|
return /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
38
41
|
id: "3443925957",
|
|
39
42
|
dynamic: [variables]
|
|
40
|
-
}, [
|
|
43
|
+
}, [`html{${variables};}`]);
|
|
41
44
|
};
|
|
42
|
-
|
|
43
45
|
CssVariables.defaultProps = {
|
|
44
46
|
colors: false,
|
|
45
47
|
theme: false,
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CssVariables } from './index.js';
|
|
3
|
-
const description =
|
|
3
|
+
const description = `
|
|
4
|
+
A utility for adding DHIS2 theme variables to global CSS variables.
|
|
4
5
|
|
|
6
|
+
\`\`\`js
|
|
7
|
+
import { CssVariables } from '@dhis2/ui'
|
|
8
|
+
\`\`\`
|
|
9
|
+
`;
|
|
5
10
|
const App = _ref => {
|
|
6
11
|
let {
|
|
7
12
|
children
|
|
8
13
|
} = _ref;
|
|
9
14
|
return /*#__PURE__*/React.createElement("div", null, children);
|
|
10
15
|
};
|
|
11
|
-
|
|
12
16
|
export default {
|
|
13
17
|
title: 'CSS Variables',
|
|
14
18
|
component: CssVariables,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/css",
|
|
3
|
-
"version": "9.11.
|
|
3
|
+
"version": "9.11.1-beta.10",
|
|
4
4
|
"description": "UI CSS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"start": "
|
|
25
|
+
"start": "storybook dev -c ../../storybook/config --port 5000",
|
|
26
26
|
"build": "d2-app-scripts build",
|
|
27
27
|
"test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"react": "^16.
|
|
31
|
-
"react-dom": "^16.
|
|
30
|
+
"react": "^16.13",
|
|
31
|
+
"react-dom": "^16.13",
|
|
32
32
|
"styled-jsx": "^4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@dhis2/prop-types": "^3.1.2",
|
|
36
|
-
"@dhis2/ui-constants": "9.11.
|
|
36
|
+
"@dhis2/ui-constants": "9.11.1-beta.10",
|
|
37
37
|
"classnames": "^2.3.1",
|
|
38
38
|
"prop-types": "^15.7.2"
|
|
39
39
|
},
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _index = require("./index.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
(0, _react.storiesOf)('CssVariables', module).add('With colors', () => /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement(_index.CssVariables, {
|
|
12
|
-
colors: true
|
|
13
|
-
}), /*#__PURE__*/_react2.default.createElement("div", {
|
|
14
|
-
id: "custom",
|
|
15
|
-
style: {
|
|
16
|
-
backgroundColor: 'var(--colors-blue900)'
|
|
17
|
-
}
|
|
18
|
-
}))).add('With theme', () => /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement(_index.CssVariables, {
|
|
19
|
-
theme: true
|
|
20
|
-
}), /*#__PURE__*/_react2.default.createElement("div", {
|
|
21
|
-
id: "custom",
|
|
22
|
-
style: {
|
|
23
|
-
backgroundColor: 'var(--theme-primary900)'
|
|
24
|
-
}
|
|
25
|
-
}))).add('With layers', () => /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement(_index.CssVariables, {
|
|
26
|
-
layers: true
|
|
27
|
-
}), /*#__PURE__*/_react2.default.createElement("div", {
|
|
28
|
-
id: "custom",
|
|
29
|
-
style: {
|
|
30
|
-
zIndex: 'var(--layers-alert)',
|
|
31
|
-
position: 'absolute'
|
|
32
|
-
}
|
|
33
|
-
}))).add('With spacers', () => /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement(_index.CssVariables, {
|
|
34
|
-
spacers: true
|
|
35
|
-
}), /*#__PURE__*/_react2.default.createElement("div", {
|
|
36
|
-
id: "custom",
|
|
37
|
-
style: {
|
|
38
|
-
margin: 'var(--spacers-dp4)'
|
|
39
|
-
}
|
|
40
|
-
}))).add('With elevations', () => /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement(_index.CssVariables, {
|
|
41
|
-
elevations: true
|
|
42
|
-
}), /*#__PURE__*/_react2.default.createElement("div", {
|
|
43
|
-
id: "custom",
|
|
44
|
-
style: {
|
|
45
|
-
boxShadow: 'var(--elevations-e100)'
|
|
46
|
-
}
|
|
47
|
-
})));
|