@pareto-engineering/design-system 4.0.0-alpha.17 → 4.0.0-alpha.18

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.
Files changed (33) hide show
  1. package/dist/cjs/a/AnimatedGradient/AnimatedGradient.js +5 -1
  2. package/dist/cjs/a/AppContext/useTheme.js +0 -4
  3. package/dist/cjs/b/Button/Button.js +6 -1
  4. package/dist/cjs/b/Button/styles.scss +5 -0
  5. package/dist/cjs/b/Page/Page.js +5 -1
  6. package/dist/cjs/b/Page/common/Section/Section.js +2 -2
  7. package/dist/cjs/b/ThemeSelector/ThemeSelector.js +3 -10
  8. package/dist/cjs/b/ThemeSelector/styles.scss +3 -2
  9. package/dist/cjs/f/fields/TextInput/TextInput.js +12 -3
  10. package/dist/cjs/f/fields/TextInput/styles.scss +20 -0
  11. package/dist/es/a/AnimatedGradient/AnimatedGradient.js +5 -1
  12. package/dist/es/a/AppContext/useTheme.js +0 -4
  13. package/dist/es/b/Button/Button.js +6 -1
  14. package/dist/es/b/Button/styles.scss +5 -0
  15. package/dist/es/b/Page/Page.js +5 -1
  16. package/dist/es/b/Page/common/Section/Section.js +2 -2
  17. package/dist/es/b/ThemeSelector/ThemeSelector.js +3 -10
  18. package/dist/es/b/ThemeSelector/styles.scss +3 -2
  19. package/dist/es/f/fields/TextInput/TextInput.js +12 -3
  20. package/dist/es/f/fields/TextInput/styles.scss +20 -0
  21. package/package.json +3 -3
  22. package/src/stories/f/TextInput.stories.jsx +7 -0
  23. package/src/ui/a/AnimatedGradient/AnimatedGradient.jsx +5 -1
  24. package/src/ui/a/AppContext/useTheme.js +0 -4
  25. package/src/ui/b/Button/Button.jsx +7 -0
  26. package/src/ui/b/Button/styles.scss +5 -0
  27. package/src/ui/b/Page/Page.jsx +4 -0
  28. package/src/ui/b/Page/common/Section/Section.jsx +2 -2
  29. package/src/ui/b/ThemeSelector/ThemeSelector.jsx +3 -10
  30. package/src/ui/b/ThemeSelector/styles.scss +3 -2
  31. package/src/ui/f/fields/TextInput/TextInput.jsx +12 -1
  32. package/src/ui/f/fields/TextInput/styles.scss +20 -0
  33. package/tests/__snapshots__/Storyshots.test.js.snap +88 -18
@@ -7,6 +7,7 @@ exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
10
+ var _ = require("./..");
10
11
  var _webGIRenderer = require("./webGIRenderer");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -27,6 +28,9 @@ const AnimatedGradient = _ref => {
27
28
  (0, React.useInsertionEffect)(() => {
28
29
  Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
29
30
  }, []);
31
+ const {
32
+ userTheme
33
+ } = (0, _.useApp)();
30
34
  const isClient = typeof window !== 'undefined';
31
35
  (0, React.useEffect)(() => {
32
36
  // Only initialize the Gradient if we're in the browser
@@ -34,7 +38,7 @@ const AnimatedGradient = _ref => {
34
38
  const gradient = new _webGIRenderer.Gradient();
35
39
  gradient.initGradient('#gradient-canvas');
36
40
  }
37
- }, []);
41
+ }, [userTheme]);
38
42
  return /*#__PURE__*/React.createElement("canvas", {
39
43
  id: "gradient-canvas",
40
44
  "data-transition-in": true,
@@ -14,19 +14,15 @@ var _default = function _default(initialTheme) {
14
14
  const storage = window.localStorage;
15
15
  if (isClient) {
16
16
  const storedTheme = window.localStorage.getItem(storageKey);
17
- // console.log(storedTheme, storedTheme != userTheme)
18
17
  if (storedTheme && storedTheme !== userTheme) {
19
- // console.warn('Theme load')
20
18
  setPreferredTheme(storedTheme);
21
19
  setUserTheme(storedTheme);
22
20
  } else if (preferredTheme && preferredTheme.length && preferredTheme !== 'system') {
23
21
  setUserTheme(preferredTheme);
24
22
  storage.setItem(storageKey, preferredTheme);
25
- // console.warn('theme change', preferredTheme)
26
23
  } else {
27
24
  setUserTheme(window.matchMedia('(prefers-color-scheme:dark)').matches ? 'dark' : 'light');
28
25
  storage.removeItem(storageKey);
29
- // console.warn('theme reset')
30
26
  }
31
27
  } else {
32
28
  setUserTheme('light');
@@ -29,6 +29,7 @@ const Button = _ref => {
29
29
  isGhost,
30
30
  isSimple,
31
31
  isGradient,
32
+ isSpaced,
32
33
  arrowDirection,
33
34
  ...otherProps
34
35
  } = _ref;
@@ -37,7 +38,7 @@ const Button = _ref => {
37
38
  }, []);
38
39
  return /*#__PURE__*/React.createElement("button", _extends({
39
40
  id: id,
40
- className: [baseClassName, componentClassName, userClassName, `x-${color}`, isGhost && _exports.default.modifierGhost, isCompact && _exports.default.modifierCompact, isSimple && _exports.default.modifierSimple, isGradient && _exports.default.modifierGradient, arrowDirection && `arrow-${arrowDirection}`].filter(e => e).join(' '),
41
+ className: [baseClassName, componentClassName, userClassName, `x-${color}`, isGhost && _exports.default.modifierGhost, isCompact && _exports.default.modifierCompact, isSimple && _exports.default.modifierSimple, isGradient && _exports.default.modifierGradient, isSpaced && _exports.default.modifierSpaced, arrowDirection && `arrow-${arrowDirection}`].filter(e => e).join(' '),
41
42
  style: style,
42
43
  type: "button"
43
44
  }, otherProps), isLoading ? /*#__PURE__*/React.createElement(_.LoadingCircle, {
@@ -80,6 +81,10 @@ Button.propTypes = {
80
81
  * Should this button have a gradient
81
82
  */
82
83
  isGradient: _propTypes.default.bool,
84
+ /**
85
+ * Should this button be spaced
86
+ */
87
+ isSpaced: _propTypes.default.bool,
83
88
  /**
84
89
  * The button color
85
90
  */
@@ -104,6 +104,11 @@ $default-animation-time: .31s;
104
104
  }
105
105
  }
106
106
 
107
+ &.#{bem.$modifier-spaced} {
108
+ margin-bottom: var(--spacing-2);
109
+ margin-top: var(--spacing-2);
110
+ }
111
+
107
112
  &.#{bem.$modifier-simple} {
108
113
  background: transparent;
109
114
  border: 1px solid transparent;
@@ -7,6 +7,7 @@ exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
10
+ var _a = require("../../a");
10
11
  var _common = require("./common");
11
12
  var _Context = _interopRequireDefault(require("./Context"));
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -37,6 +38,9 @@ const Page = _ref => {
37
38
  (0, React.useInsertionEffect)(() => {
38
39
  Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
39
40
  }, []);
41
+ const {
42
+ userTheme
43
+ } = (0, _a.useApp)();
40
44
  (0, React.useEffect)(() => {
41
45
  // If we're on the client, we make sure to scroll up when the page loads
42
46
  // This is a necessary transform to make react apt for website pages
@@ -51,7 +55,7 @@ const Page = _ref => {
51
55
  }
52
56
  }, /*#__PURE__*/React.createElement(Wrapper, _extends({
53
57
  id: id,
54
- className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
58
+ className: [baseClassName, componentClassName, userClassName, userTheme && `ui-${userTheme}`].filter(e => e).join(' '),
55
59
  style: style,
56
60
  itemType: itemType,
57
61
  itemScope: itemType && ' '
@@ -20,7 +20,7 @@ const Section = _ref => {
20
20
  className: userClassName,
21
21
  style,
22
22
  children,
23
- spaced,
23
+ isSpaced,
24
24
  padded,
25
25
  ...otherProps
26
26
  } = _ref;
@@ -30,7 +30,7 @@ const Section = _ref => {
30
30
  const sectionId = userId && `${pageId}_${userId}`;
31
31
  return /*#__PURE__*/React.createElement("section", _extends({
32
32
  id: sectionId,
33
- className: [baseClassName, componentClassName, userClassName, spaced && _exports.default.modifierSpaced, padded && 'padded', 'grid'].filter(e => e).join(' '),
33
+ className: [baseClassName, componentClassName, userClassName, isSpaced && _exports.default.modifierSpaced, padded && 'padded', 'grid'].filter(e => e).join(' '),
34
34
  style: style
35
35
  }, otherProps), children);
36
36
  };
@@ -24,8 +24,6 @@ const ThemeSelector = _ref => {
24
24
  id,
25
25
  className: userClassName,
26
26
  style,
27
- // children
28
-
29
27
  themes,
30
28
  iconMap
31
29
  } = _ref;
@@ -47,7 +45,7 @@ const ThemeSelector = _ref => {
47
45
  style: style,
48
46
  onClick: loopThemes
49
47
  }, /*#__PURE__*/React.createElement("span", {
50
- className: "v0 m-v icon"
48
+ className: "icon"
51
49
  }, iconMap[userTheme]), /*#__PURE__*/React.createElement("span", null, userTheme));
52
50
  };
53
51
  ThemeSelector.propTypes = {
@@ -63,11 +61,6 @@ ThemeSelector.propTypes = {
63
61
  * The React-written, css properties for this element.
64
62
  */
65
63
  style: _propTypes.default.objectOf(_propTypes.default.string),
66
- /**
67
- * The children JSX
68
- */
69
- // children: PropTypes.node,
70
-
71
64
  /**
72
65
  * The themes and the order in which they appear
73
66
  */
@@ -80,9 +73,9 @@ ThemeSelector.propTypes = {
80
73
  ThemeSelector.defaultProps = {
81
74
  themes: ['light', 'dark'],
82
75
  iconMap: {
83
- dark: 'n',
76
+ dark: 'd',
84
77
  // sun,
85
- light: 'm' // moon,
78
+ light: 'T' // moon,
86
79
  }
87
80
  };
88
81
  var _default = ThemeSelector;
@@ -5,10 +5,11 @@
5
5
  $default-color:var(--x, var(--contrast));
6
6
 
7
7
  .#{bem.$base}.theme-selector {
8
+ align-items: center;
8
9
  background: transparent;
9
10
  border: none;
10
11
  color: $default-color;
11
12
  cursor: pointer;
13
+ display: flex;
14
+ gap: var(--gap);
12
15
  }
13
-
14
-
@@ -37,7 +37,8 @@ const TextInput = _ref => {
37
37
  disabled,
38
38
  placeholder,
39
39
  optional,
40
- autoComplete
40
+ autoComplete,
41
+ symbol
41
42
  // ...otherProps
42
43
  } = _ref;
43
44
  (0, React.useInsertionEffect)(() => {
@@ -47,6 +48,9 @@ const TextInput = _ref => {
47
48
  name,
48
49
  validate
49
50
  });
51
+ const symbolStyle = symbol ? {
52
+ '--symbol': symbol
53
+ } : {};
50
54
  return /*#__PURE__*/React.createElement("div", {
51
55
  id: id,
52
56
  className: [baseClassName, componentClassName, userClassName, `y-${color}`].filter(e => e).join(' '),
@@ -58,7 +62,8 @@ const TextInput = _ref => {
58
62
  color: labelColor,
59
63
  optional: optional
60
64
  }, label), /*#__PURE__*/React.createElement("div", {
61
- className: "input-wrapper with-faded-border"
65
+ className: `input-wrapper with-faded-border ${symbol ? 'has-symbol' : ''}`,
66
+ style: symbolStyle
62
67
  }, /*#__PURE__*/React.createElement("input", _extends({
63
68
  id: name,
64
69
  className: "input",
@@ -133,7 +138,11 @@ TextInput.propTypes = {
133
138
  * The autoComplete value that the browser should watch for the input
134
139
  * `https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete`
135
140
  */
136
- autoComplete: _propTypes.default.string
141
+ autoComplete: _propTypes.default.string,
142
+ /**
143
+ * A symbol to be set inside the input field
144
+ */
145
+ symbol: _propTypes.default.string
137
146
  };
138
147
  TextInput.defaultProps = {
139
148
  type: 'text',
@@ -4,6 +4,12 @@
4
4
  @use "../../../form.scss";
5
5
 
6
6
  $default-padding: .75em .75em .55em;
7
+ $default-symbol-left: 3em;
8
+ $default-padding-with-symbol:
9
+ .75em
10
+ calc($default-symbol-left - 1em)
11
+ .55em
12
+ calc($default-symbol-left + 1em);
7
13
  $default-input-border-radius: var(--theme-default-input-border-radius);
8
14
 
9
15
 
@@ -18,6 +24,20 @@ $default-input-border-radius: var(--theme-default-input-border-radius);
18
24
  border-radius: $default-input-border-radius;
19
25
  }
20
26
 
27
+ &.has-symbol {
28
+ &::before {
29
+ color: var(--interactive);
30
+ content: var(--symbol);
31
+ left: $default-symbol-left;
32
+ position: absolute;
33
+ top: .5em;
34
+ }
35
+
36
+ input {
37
+ padding: $default-padding-with-symbol;
38
+ }
39
+ }
40
+
21
41
  > input {
22
42
  background-color: var(--background-inputs);
23
43
  border-radius: $default-input-border-radius;
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  import { useEffect, useInsertionEffect } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import styleNames from '@pareto-engineering/bem/exports';
6
+ import { useApp } from "./..";
6
7
  import { Gradient } from "./webGIRenderer";
7
8
 
8
9
  // Local Definitions
@@ -20,6 +21,9 @@ const AnimatedGradient = ({
20
21
  useInsertionEffect(() => {
21
22
  import("./styles.scss");
22
23
  }, []);
24
+ const {
25
+ userTheme
26
+ } = useApp();
23
27
  const isClient = typeof window !== 'undefined';
24
28
  useEffect(() => {
25
29
  // Only initialize the Gradient if we're in the browser
@@ -27,7 +31,7 @@ const AnimatedGradient = ({
27
31
  const gradient = new Gradient();
28
32
  gradient.initGradient('#gradient-canvas');
29
33
  }
30
- }, []);
34
+ }, [userTheme]);
31
35
  return /*#__PURE__*/React.createElement("canvas", {
32
36
  id: "gradient-canvas",
33
37
  "data-transition-in": true,
@@ -7,19 +7,15 @@ export default ((initialTheme, storageKey = 'theme') => {
7
7
  const storage = window.localStorage;
8
8
  if (isClient) {
9
9
  const storedTheme = window.localStorage.getItem(storageKey);
10
- // console.log(storedTheme, storedTheme != userTheme)
11
10
  if (storedTheme && storedTheme !== userTheme) {
12
- // console.warn('Theme load')
13
11
  setPreferredTheme(storedTheme);
14
12
  setUserTheme(storedTheme);
15
13
  } else if (preferredTheme && preferredTheme.length && preferredTheme !== 'system') {
16
14
  setUserTheme(preferredTheme);
17
15
  storage.setItem(storageKey, preferredTheme);
18
- // console.warn('theme change', preferredTheme)
19
16
  } else {
20
17
  setUserTheme(window.matchMedia('(prefers-color-scheme:dark)').matches ? 'dark' : 'light');
21
18
  storage.removeItem(storageKey);
22
- // console.warn('theme reset')
23
19
  }
24
20
  } else {
25
21
  setUserTheme('light');
@@ -24,6 +24,7 @@ const Button = ({
24
24
  isGhost,
25
25
  isSimple,
26
26
  isGradient,
27
+ isSpaced,
27
28
  arrowDirection,
28
29
  ...otherProps
29
30
  }) => {
@@ -32,7 +33,7 @@ const Button = ({
32
33
  }, []);
33
34
  return /*#__PURE__*/React.createElement("button", _extends({
34
35
  id: id,
35
- className: [baseClassName, componentClassName, userClassName, `x-${color}`, isGhost && styleNames.modifierGhost, isCompact && styleNames.modifierCompact, isSimple && styleNames.modifierSimple, isGradient && styleNames.modifierGradient, arrowDirection && `arrow-${arrowDirection}`].filter(e => e).join(' '),
36
+ className: [baseClassName, componentClassName, userClassName, `x-${color}`, isGhost && styleNames.modifierGhost, isCompact && styleNames.modifierCompact, isSimple && styleNames.modifierSimple, isGradient && styleNames.modifierGradient, isSpaced && styleNames.modifierSpaced, arrowDirection && `arrow-${arrowDirection}`].filter(e => e).join(' '),
36
37
  style: style,
37
38
  type: "button"
38
39
  }, otherProps), isLoading ? /*#__PURE__*/React.createElement(LoadingCircle, {
@@ -75,6 +76,10 @@ Button.propTypes = {
75
76
  * Should this button have a gradient
76
77
  */
77
78
  isGradient: PropTypes.bool,
79
+ /**
80
+ * Should this button be spaced
81
+ */
82
+ isSpaced: PropTypes.bool,
78
83
  /**
79
84
  * The button color
80
85
  */
@@ -104,6 +104,11 @@ $default-animation-time: .31s;
104
104
  }
105
105
  }
106
106
 
107
+ &.#{bem.$modifier-spaced} {
108
+ margin-bottom: var(--spacing-2);
109
+ margin-top: var(--spacing-2);
110
+ }
111
+
107
112
  &.#{bem.$modifier-simple} {
108
113
  background: transparent;
109
114
  border: 1px solid transparent;
@@ -4,6 +4,7 @@ import * as React from 'react';
4
4
  import { useInsertionEffect, useEffect } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import styleNames from '@pareto-engineering/bem/exports';
7
+ import { useApp } from "../../a";
7
8
 
8
9
  // Imports from the component folder
9
10
  import { PageHelmet, Section } from "./common";
@@ -33,6 +34,9 @@ const Page = ({
33
34
  useInsertionEffect(() => {
34
35
  import("./styles.scss");
35
36
  }, []);
37
+ const {
38
+ userTheme
39
+ } = useApp();
36
40
  useEffect(() => {
37
41
  // If we're on the client, we make sure to scroll up when the page loads
38
42
  // This is a necessary transform to make react apt for website pages
@@ -47,7 +51,7 @@ const Page = ({
47
51
  }
48
52
  }, /*#__PURE__*/React.createElement(Wrapper, _extends({
49
53
  id: id,
50
- className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
54
+ className: [baseClassName, componentClassName, userClassName, userTheme && `ui-${userTheme}`].filter(e => e).join(' '),
51
55
  style: style,
52
56
  itemType: itemType,
53
57
  itemScope: itemType && ' '
@@ -13,7 +13,7 @@ const Section = ({
13
13
  className: userClassName,
14
14
  style,
15
15
  children,
16
- spaced,
16
+ isSpaced,
17
17
  padded,
18
18
  ...otherProps
19
19
  }) => {
@@ -23,7 +23,7 @@ const Section = ({
23
23
  const sectionId = userId && `${pageId}_${userId}`;
24
24
  return /*#__PURE__*/React.createElement("section", _extends({
25
25
  id: sectionId,
26
- className: [baseClassName, componentClassName, userClassName, spaced && styleNames.modifierSpaced, padded && 'padded', 'grid'].filter(e => e).join(' '),
26
+ className: [baseClassName, componentClassName, userClassName, isSpaced && styleNames.modifierSpaced, padded && 'padded', 'grid'].filter(e => e).join(' '),
27
27
  style: style
28
28
  }, otherProps), children);
29
29
  };
@@ -17,8 +17,6 @@ const ThemeSelector = ({
17
17
  id,
18
18
  className: userClassName,
19
19
  style,
20
- // children
21
-
22
20
  themes,
23
21
  iconMap
24
22
  }) => {
@@ -40,7 +38,7 @@ const ThemeSelector = ({
40
38
  style: style,
41
39
  onClick: loopThemes
42
40
  }, /*#__PURE__*/React.createElement("span", {
43
- className: "v0 m-v icon"
41
+ className: "icon"
44
42
  }, iconMap[userTheme]), /*#__PURE__*/React.createElement("span", null, userTheme));
45
43
  };
46
44
  ThemeSelector.propTypes = {
@@ -56,11 +54,6 @@ ThemeSelector.propTypes = {
56
54
  * The React-written, css properties for this element.
57
55
  */
58
56
  style: PropTypes.objectOf(PropTypes.string),
59
- /**
60
- * The children JSX
61
- */
62
- // children: PropTypes.node,
63
-
64
57
  /**
65
58
  * The themes and the order in which they appear
66
59
  */
@@ -73,9 +66,9 @@ ThemeSelector.propTypes = {
73
66
  ThemeSelector.defaultProps = {
74
67
  themes: ['light', 'dark'],
75
68
  iconMap: {
76
- dark: 'n',
69
+ dark: 'd',
77
70
  // sun,
78
- light: 'm' // moon,
71
+ light: 'T' // moon,
79
72
  }
80
73
  };
81
74
 
@@ -5,10 +5,11 @@
5
5
  $default-color:var(--x, var(--contrast));
6
6
 
7
7
  .#{bem.$base}.theme-selector {
8
+ align-items: center;
8
9
  background: transparent;
9
10
  border: none;
10
11
  color: $default-color;
11
12
  cursor: pointer;
13
+ display: flex;
14
+ gap: var(--gap);
12
15
  }
13
-
14
-
@@ -30,7 +30,8 @@ const TextInput = ({
30
30
  disabled,
31
31
  placeholder,
32
32
  optional,
33
- autoComplete
33
+ autoComplete,
34
+ symbol
34
35
  // ...otherProps
35
36
  }) => {
36
37
  useInsertionEffect(() => {
@@ -40,6 +41,9 @@ const TextInput = ({
40
41
  name,
41
42
  validate
42
43
  });
44
+ const symbolStyle = symbol ? {
45
+ '--symbol': symbol
46
+ } : {};
43
47
  return /*#__PURE__*/React.createElement("div", {
44
48
  id: id,
45
49
  className: [baseClassName, componentClassName, userClassName, `y-${color}`].filter(e => e).join(' '),
@@ -51,7 +55,8 @@ const TextInput = ({
51
55
  color: labelColor,
52
56
  optional: optional
53
57
  }, label), /*#__PURE__*/React.createElement("div", {
54
- className: "input-wrapper with-faded-border"
58
+ className: `input-wrapper with-faded-border ${symbol ? 'has-symbol' : ''}`,
59
+ style: symbolStyle
55
60
  }, /*#__PURE__*/React.createElement("input", _extends({
56
61
  id: name,
57
62
  className: "input",
@@ -126,7 +131,11 @@ TextInput.propTypes = {
126
131
  * The autoComplete value that the browser should watch for the input
127
132
  * `https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete`
128
133
  */
129
- autoComplete: PropTypes.string
134
+ autoComplete: PropTypes.string,
135
+ /**
136
+ * A symbol to be set inside the input field
137
+ */
138
+ symbol: PropTypes.string
130
139
  };
131
140
  TextInput.defaultProps = {
132
141
  type: 'text',
@@ -4,6 +4,12 @@
4
4
  @use "../../../form.scss";
5
5
 
6
6
  $default-padding: .75em .75em .55em;
7
+ $default-symbol-left: 3em;
8
+ $default-padding-with-symbol:
9
+ .75em
10
+ calc($default-symbol-left - 1em)
11
+ .55em
12
+ calc($default-symbol-left + 1em);
7
13
  $default-input-border-radius: var(--theme-default-input-border-radius);
8
14
 
9
15
 
@@ -18,6 +24,20 @@ $default-input-border-radius: var(--theme-default-input-border-radius);
18
24
  border-radius: $default-input-border-radius;
19
25
  }
20
26
 
27
+ &.has-symbol {
28
+ &::before {
29
+ color: var(--interactive);
30
+ content: var(--symbol);
31
+ left: $default-symbol-left;
32
+ position: absolute;
33
+ top: .5em;
34
+ }
35
+
36
+ input {
37
+ padding: $default-padding-with-symbol;
38
+ }
39
+ }
40
+
21
41
  > input {
22
42
  background-color: var(--background-inputs);
23
43
  border-radius: $default-input-border-radius;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "4.0.0-alpha.17",
3
+ "version": "4.0.0-alpha.18",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -52,7 +52,7 @@
52
52
  "dependencies": {
53
53
  "@pareto-engineering/assets": "^4.0.0-alpha.11",
54
54
  "@pareto-engineering/bem": "^4.0.0-alpha.11",
55
- "@pareto-engineering/styles": "^4.0.0-alpha.16",
55
+ "@pareto-engineering/styles": "^4.0.0-alpha.18",
56
56
  "date-fns": "^2.29.3",
57
57
  "downshift": "^6.1.12",
58
58
  "formik": "^2.2.9",
@@ -67,5 +67,5 @@
67
67
  "relay-test-utils": "^15.0.0"
68
68
  },
69
69
  "browserslist": "> 2%",
70
- "gitHead": "54fc8906a8d9b0d73d38468ac42f433873317458"
70
+ "gitHead": "e1735bceb078ee7d063407d7f6fcd36ff11d0ef9"
71
71
  }
@@ -34,6 +34,7 @@ export default {
34
34
  name :{ control: 'text' },
35
35
  label :{ control: 'text' },
36
36
  optional :{ control: 'boolean' },
37
+ symbol :{ control: 'text' },
37
38
  },
38
39
  }
39
40
 
@@ -104,3 +105,9 @@ Time.args = {
104
105
  name :'time',
105
106
  label:'Select time',
106
107
  }
108
+
109
+ export const HasSymbol = Template.bind({})
110
+ HasSymbol.args = {
111
+ ...Base.args,
112
+ symbol:"'$'",
113
+ }
@@ -10,6 +10,8 @@ import PropTypes from 'prop-types'
10
10
 
11
11
  import styleNames from '@pareto-engineering/bem/exports'
12
12
 
13
+ import { useApp } from 'ui/a'
14
+
13
15
  import { Gradient } from './webGIRenderer'
14
16
 
15
17
  // Local Definitions
@@ -29,6 +31,8 @@ const AnimatedGradient = ({
29
31
  import('./styles.scss')
30
32
  }, [])
31
33
 
34
+ const { userTheme } = useApp()
35
+
32
36
  const isClient = typeof window !== 'undefined'
33
37
 
34
38
  useEffect(() => {
@@ -37,7 +41,7 @@ const AnimatedGradient = ({
37
41
  const gradient = new Gradient()
38
42
  gradient.initGradient('#gradient-canvas')
39
43
  }
40
- }, [])
44
+ }, [userTheme])
41
45
 
42
46
  return (
43
47
  <canvas
@@ -14,9 +14,7 @@ export default (
14
14
  const storage = window.localStorage
15
15
  if (isClient) {
16
16
  const storedTheme = window.localStorage.getItem(storageKey)
17
- // console.log(storedTheme, storedTheme != userTheme)
18
17
  if (storedTheme && (storedTheme !== userTheme)) {
19
- // console.warn('Theme load')
20
18
  setPreferredTheme(storedTheme)
21
19
  setUserTheme(storedTheme)
22
20
  } else if (preferredTheme && preferredTheme.length && preferredTheme !== 'system') {
@@ -25,11 +23,9 @@ export default (
25
23
  storageKey,
26
24
  preferredTheme,
27
25
  )
28
- // console.warn('theme change', preferredTheme)
29
26
  } else {
30
27
  setUserTheme(window.matchMedia('(prefers-color-scheme:dark)').matches ? 'dark' : 'light')
31
28
  storage.removeItem(storageKey)
32
- // console.warn('theme reset')
33
29
  }
34
30
  } else {
35
31
  setUserTheme('light')
@@ -24,6 +24,7 @@ const Button = ({
24
24
  isGhost,
25
25
  isSimple,
26
26
  isGradient,
27
+ isSpaced,
27
28
  arrowDirection,
28
29
  ...otherProps
29
30
  }) => {
@@ -43,6 +44,7 @@ const Button = ({
43
44
  isCompact && styleNames.modifierCompact,
44
45
  isSimple && styleNames.modifierSimple,
45
46
  isGradient && styleNames.modifierGradient,
47
+ isSpaced && styleNames.modifierSpaced,
46
48
  arrowDirection && `arrow-${arrowDirection}`,
47
49
  ]
48
50
  .filter((e) => e)
@@ -104,6 +106,11 @@ Button.propTypes = {
104
106
  */
105
107
  isGradient:PropTypes.bool,
106
108
 
109
+ /**
110
+ * Should this button be spaced
111
+ */
112
+ isSpaced:PropTypes.bool,
113
+
107
114
  /**
108
115
  * The button color
109
116
  */
@@ -104,6 +104,11 @@ $default-animation-time: .31s;
104
104
  }
105
105
  }
106
106
 
107
+ &.#{bem.$modifier-spaced} {
108
+ margin-bottom: var(--spacing-2);
109
+ margin-top: var(--spacing-2);
110
+ }
111
+
107
112
  &.#{bem.$modifier-simple} {
108
113
  background: transparent;
109
114
  border: 1px solid transparent;
@@ -3,6 +3,7 @@ import * as React from 'react'
3
3
  import { useInsertionEffect, useEffect } from 'react'
4
4
  import PropTypes from 'prop-types'
5
5
  import styleNames from '@pareto-engineering/bem/exports'
6
+ import { useApp } from 'ui/a'
6
7
 
7
8
  // Imports from the component folder
8
9
  import { PageHelmet, Section } from './common'
@@ -33,6 +34,8 @@ const Page = ({
33
34
  import('./styles.scss')
34
35
  }, [])
35
36
 
37
+ const { userTheme } = useApp()
38
+
36
39
  useEffect(() => {
37
40
  // If we're on the client, we make sure to scroll up when the page loads
38
41
  // This is a necessary transform to make react apt for website pages
@@ -54,6 +57,7 @@ const Page = ({
54
57
  baseClassName,
55
58
  componentClassName,
56
59
  userClassName,
60
+ userTheme && `ui-${userTheme}`,
57
61
  ]
58
62
  .filter((e) => e)
59
63
  .join(' ')}
@@ -14,7 +14,7 @@ const Section = ({
14
14
  className:userClassName,
15
15
  style,
16
16
  children,
17
- spaced,
17
+ isSpaced,
18
18
  padded,
19
19
  ...otherProps
20
20
  }) => {
@@ -30,7 +30,7 @@ const Section = ({
30
30
  baseClassName,
31
31
  componentClassName,
32
32
  userClassName,
33
- spaced && styleNames.modifierSpaced,
33
+ isSpaced && styleNames.modifierSpaced,
34
34
  padded && 'padded',
35
35
  'grid',
36
36
  ]
@@ -19,8 +19,6 @@ const ThemeSelector = ({
19
19
  id,
20
20
  className:userClassName,
21
21
  style,
22
- // children
23
-
24
22
  themes,
25
23
  iconMap,
26
24
  }) => {
@@ -53,7 +51,7 @@ const ThemeSelector = ({
53
51
  style={style}
54
52
  onClick={loopThemes}
55
53
  >
56
- <span className="v0 m-v icon">
54
+ <span className="icon">
57
55
  { iconMap[userTheme] }
58
56
  </span>
59
57
  <span>
@@ -79,11 +77,6 @@ ThemeSelector.propTypes = {
79
77
  */
80
78
  style:PropTypes.objectOf(PropTypes.string),
81
79
 
82
- /**
83
- * The children JSX
84
- */
85
- // children: PropTypes.node,
86
-
87
80
  /**
88
81
  * The themes and the order in which they appear
89
82
  */
@@ -99,8 +92,8 @@ ThemeSelector.propTypes = {
99
92
  ThemeSelector.defaultProps = {
100
93
  themes :['light', 'dark'],
101
94
  iconMap:{
102
- dark :'n', // sun,
103
- light:'m', // moon,
95
+ dark :'d', // sun,
96
+ light:'T', // moon,
104
97
  },
105
98
  }
106
99
 
@@ -5,10 +5,11 @@
5
5
  $default-color:var(--x, var(--contrast));
6
6
 
7
7
  .#{bem.$base}.theme-selector {
8
+ align-items: center;
8
9
  background: transparent;
9
10
  border: none;
10
11
  color: $default-color;
11
12
  cursor: pointer;
13
+ display: flex;
14
+ gap: var(--gap);
12
15
  }
13
-
14
-
@@ -36,6 +36,7 @@ const TextInput = ({
36
36
  placeholder,
37
37
  optional,
38
38
  autoComplete,
39
+ symbol,
39
40
  // ...otherProps
40
41
  }) => {
41
42
  useInsertionEffect(() => {
@@ -43,6 +44,9 @@ const TextInput = ({
43
44
  }, [])
44
45
 
45
46
  const [field] = useField({ name, validate })
47
+ const symbolStyle = symbol
48
+ ? { '--symbol': symbol }
49
+ : {}
46
50
 
47
51
  return (
48
52
  <div
@@ -68,7 +72,10 @@ const TextInput = ({
68
72
  >
69
73
  { label }
70
74
  </FormLabel>
71
- <div className="input-wrapper with-faded-border">
75
+ <div
76
+ className={`input-wrapper with-faded-border ${symbol ? 'has-symbol' : ''}`}
77
+ style={symbolStyle}
78
+ >
72
79
  <input
73
80
  id={name}
74
81
  className="input"
@@ -171,6 +178,10 @@ TextInput.propTypes = {
171
178
  * `https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete`
172
179
  */
173
180
  autoComplete:PropTypes.string,
181
+ /**
182
+ * A symbol to be set inside the input field
183
+ */
184
+ symbol :PropTypes.string,
174
185
  }
175
186
 
176
187
  TextInput.defaultProps = {
@@ -4,6 +4,12 @@
4
4
  @use "../../../form.scss";
5
5
 
6
6
  $default-padding: .75em .75em .55em;
7
+ $default-symbol-left: 3em;
8
+ $default-padding-with-symbol:
9
+ .75em
10
+ calc($default-symbol-left - 1em)
11
+ .55em
12
+ calc($default-symbol-left + 1em);
7
13
  $default-input-border-radius: var(--theme-default-input-border-radius);
8
14
 
9
15
 
@@ -18,6 +24,20 @@ $default-input-border-radius: var(--theme-default-input-border-radius);
18
24
  border-radius: $default-input-border-radius;
19
25
  }
20
26
 
27
+ &.has-symbol {
28
+ &::before {
29
+ color: var(--interactive);
30
+ content: var(--symbol);
31
+ left: $default-symbol-left;
32
+ position: absolute;
33
+ top: .5em;
34
+ }
35
+
36
+ input {
37
+ padding: $default-padding-with-symbol;
38
+ }
39
+ }
40
+
21
41
  > input {
22
42
  background-color: var(--background-inputs);
23
43
  border-radius: $default-input-border-radius;
@@ -13336,8 +13336,9 @@ exports[`Storyshots b/Page With Sections 1`] = `
13336
13336
  Section 1
13337
13337
  </section>
13338
13338
  <section
13339
- className="base section x-main b-x modifierSpaced padded grid"
13339
+ className="base section x-main b-x padded grid"
13340
13340
  id="with-sections_s2"
13341
+ spaced={true}
13341
13342
  >
13342
13343
  Section 2. This section is spaced
13343
13344
  </section>
@@ -13463,7 +13464,7 @@ exports[`Storyshots b/ThemeSelector Base 1`] = `
13463
13464
  type="button"
13464
13465
  >
13465
13466
  <span
13466
- className="v0 m-v icon"
13467
+ className="icon"
13467
13468
  />
13468
13469
  <span />
13469
13470
  </button>
@@ -14287,7 +14288,8 @@ exports[`Storyshots f/FormInput Base 1`] = `
14287
14288
  What's your first name ?
14288
14289
  </label>
14289
14290
  <div
14290
- className="input-wrapper with-faded-border"
14291
+ className="input-wrapper with-faded-border "
14292
+ style={{}}
14291
14293
  >
14292
14294
  <input
14293
14295
  className="input"
@@ -14311,7 +14313,8 @@ exports[`Storyshots f/FormInput Base 1`] = `
14311
14313
  What's your last name ?
14312
14314
  </label>
14313
14315
  <div
14314
- className="input-wrapper with-faded-border"
14316
+ className="input-wrapper with-faded-border "
14317
+ style={{}}
14315
14318
  >
14316
14319
  <input
14317
14320
  className="input"
@@ -14518,7 +14521,8 @@ exports[`Storyshots f/FormInput Disabled Form Input 1`] = `
14518
14521
  What's your first name ?
14519
14522
  </label>
14520
14523
  <div
14521
- className="input-wrapper with-faded-border"
14524
+ className="input-wrapper with-faded-border "
14525
+ style={{}}
14522
14526
  >
14523
14527
  <input
14524
14528
  className="input"
@@ -14542,7 +14546,8 @@ exports[`Storyshots f/FormInput Disabled Form Input 1`] = `
14542
14546
  What's your last name ?
14543
14547
  </label>
14544
14548
  <div
14545
- className="input-wrapper with-faded-border"
14549
+ className="input-wrapper with-faded-border "
14550
+ style={{}}
14546
14551
  >
14547
14552
  <input
14548
14553
  className="input"
@@ -14729,7 +14734,8 @@ exports[`Storyshots f/FormInput Extensible Form Input 1`] = `
14729
14734
  Extended type input
14730
14735
  </label>
14731
14736
  <div
14732
- className="input-wrapper with-faded-border"
14737
+ className="input-wrapper with-faded-border "
14738
+ style={{}}
14733
14739
  >
14734
14740
  <input
14735
14741
  className="input"
@@ -14772,7 +14778,8 @@ exports[`Storyshots f/FormInput With Prefetched Query Select 1`] = `
14772
14778
  What's your first name ?
14773
14779
  </label>
14774
14780
  <div
14775
- className="input-wrapper with-faded-border"
14781
+ className="input-wrapper with-faded-border "
14782
+ style={{}}
14776
14783
  >
14777
14784
  <input
14778
14785
  className="input"
@@ -14918,7 +14925,8 @@ exports[`Storyshots f/FormInput With Query Combobox 1`] = `
14918
14925
  What's your first name ?
14919
14926
  </label>
14920
14927
  <div
14921
- className="input-wrapper with-faded-border"
14928
+ className="input-wrapper with-faded-border "
14929
+ style={{}}
14922
14930
  >
14923
14931
  <input
14924
14932
  className="input"
@@ -15128,7 +15136,8 @@ exports[`Storyshots f/FormInput With Ratings Input 1`] = `
15128
15136
  What's your first name ?
15129
15137
  </label>
15130
15138
  <div
15131
- className="input-wrapper with-faded-border"
15139
+ className="input-wrapper with-faded-border "
15140
+ style={{}}
15132
15141
  >
15133
15142
  <input
15134
15143
  className="input"
@@ -18978,7 +18987,8 @@ exports[`Storyshots f/fields/TextInput Base 1`] = `
18978
18987
  How can we reach you ?
18979
18988
  </label>
18980
18989
  <div
18981
- className="input-wrapper with-faded-border"
18990
+ className="input-wrapper with-faded-border "
18991
+ style={{}}
18982
18992
  >
18983
18993
  <input
18984
18994
  className="input"
@@ -19026,7 +19036,8 @@ exports[`Storyshots f/fields/TextInput Date 1`] = `
19026
19036
  Select date
19027
19037
  </label>
19028
19038
  <div
19029
- className="input-wrapper with-faded-border"
19039
+ className="input-wrapper with-faded-border "
19040
+ style={{}}
19030
19041
  >
19031
19042
  <input
19032
19043
  className="input"
@@ -19054,6 +19065,59 @@ exports[`Storyshots f/fields/TextInput Date 1`] = `
19054
19065
  </form>
19055
19066
  `;
19056
19067
 
19068
+ exports[`Storyshots f/fields/TextInput Has Symbol 1`] = `
19069
+ <form
19070
+ action="#"
19071
+ onReset={[Function]}
19072
+ onSubmit={[Function]}
19073
+ >
19074
+ <div
19075
+ className=" u2 pb-u"
19076
+ >
19077
+ <div
19078
+ className="base text-input y-background2"
19079
+ >
19080
+ <label
19081
+ className="base form-label v50 mb-v x-main2"
19082
+ htmlFor="email"
19083
+ >
19084
+ How can we reach you ?
19085
+ </label>
19086
+ <div
19087
+ className="input-wrapper with-faded-border has-symbol"
19088
+ style={
19089
+ {
19090
+ "--symbol": "'$'",
19091
+ }
19092
+ }
19093
+ >
19094
+ <input
19095
+ className="input"
19096
+ disabled={false}
19097
+ id="email"
19098
+ name="email"
19099
+ onBlur={[Function]}
19100
+ onChange={[Function]}
19101
+ type="text"
19102
+ value=""
19103
+ />
19104
+ </div>
19105
+ </div>
19106
+ <div
19107
+ className="debugger"
19108
+ >
19109
+ <button
19110
+ className="base button x-main2"
19111
+ onClick={[Function]}
19112
+ type="button"
19113
+ >
19114
+ Open FormDebugger
19115
+ </button>
19116
+ </div>
19117
+ </div>
19118
+ </form>
19119
+ `;
19120
+
19057
19121
  exports[`Storyshots f/fields/TextInput Optional 1`] = `
19058
19122
  <form
19059
19123
  action="#"
@@ -19074,7 +19138,8 @@ exports[`Storyshots f/fields/TextInput Optional 1`] = `
19074
19138
  (Optional)
19075
19139
  </label>
19076
19140
  <div
19077
- className="input-wrapper with-faded-border"
19141
+ className="input-wrapper with-faded-border "
19142
+ style={{}}
19078
19143
  >
19079
19144
  <input
19080
19145
  className="input"
@@ -19122,7 +19187,8 @@ exports[`Storyshots f/fields/TextInput Time 1`] = `
19122
19187
  Select time
19123
19188
  </label>
19124
19189
  <div
19125
- className="input-wrapper with-faded-border"
19190
+ className="input-wrapper with-faded-border "
19191
+ style={{}}
19126
19192
  >
19127
19193
  <input
19128
19194
  className="input"
@@ -19169,7 +19235,8 @@ exports[`Storyshots f/fields/TextInput With Auto Complete Off 1`] = `
19169
19235
  How can we reach you ?
19170
19236
  </label>
19171
19237
  <div
19172
- className="input-wrapper with-faded-border"
19238
+ className="input-wrapper with-faded-border "
19239
+ style={{}}
19173
19240
  >
19174
19241
  <input
19175
19242
  autoComplete="off"
@@ -19218,7 +19285,8 @@ exports[`Storyshots f/fields/TextInput With Disabled 1`] = `
19218
19285
  How can we reach you ?
19219
19286
  </label>
19220
19287
  <div
19221
- className="input-wrapper with-faded-border"
19288
+ className="input-wrapper with-faded-border "
19289
+ style={{}}
19222
19290
  >
19223
19291
  <input
19224
19292
  className="input"
@@ -19266,7 +19334,8 @@ exports[`Storyshots f/fields/TextInput With Placeholder 1`] = `
19266
19334
  How can we reach you ?
19267
19335
  </label>
19268
19336
  <div
19269
- className="input-wrapper with-faded-border"
19337
+ className="input-wrapper with-faded-border "
19338
+ style={{}}
19270
19339
  >
19271
19340
  <input
19272
19341
  className="input"
@@ -19315,7 +19384,8 @@ exports[`Storyshots f/fields/TextInput With Validation 1`] = `
19315
19384
  How can we reach you ?
19316
19385
  </label>
19317
19386
  <div
19318
- className="input-wrapper with-faded-border"
19387
+ className="input-wrapper with-faded-border "
19388
+ style={{}}
19319
19389
  >
19320
19390
  <input
19321
19391
  className="input"