@automattic/vip-design-system 0.13.0 → 0.14.0

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.
@@ -4,7 +4,7 @@ import { useColorMode } from 'theme-ui';
4
4
 
5
5
  // These need to be updated to import VIP design tokens;
6
6
  const lightBackground = '#ffffff';
7
- const darkBackground = '#333333';
7
+ const darkBackground = '#1C1C1B';
8
8
 
9
9
  export const backgrounds = {
10
10
  default: 'Light',
@@ -21,7 +21,7 @@ export const backgrounds = {
21
21
  };
22
22
 
23
23
  function ThemeChanger( { background } ) {
24
- const [colorMode, setColorMode] = useColorMode();
24
+ const [ colorMode, setColorMode ] = useColorMode();
25
25
  const newColorMode = darkBackground === background ? 'dark' : 'default';
26
26
 
27
27
  useEffect( () => {
@@ -29,7 +29,7 @@ function ThemeChanger( { background } ) {
29
29
  }, [ newColorMode ] );
30
30
 
31
31
  return null;
32
- };
32
+ }
33
33
 
34
34
  export default makeDecorator( {
35
35
  name: 'withColorMode',
@@ -37,9 +37,9 @@ export default makeDecorator( {
37
37
  wrapper: ( storyFn, context ) => {
38
38
  return (
39
39
  <>
40
- <ThemeChanger background={context.globals?.backgrounds?.value} />
41
- {storyFn()}
40
+ <ThemeChanger background={ context.globals?.backgrounds?.value } />
41
+ { storyFn() }
42
42
  </>
43
43
  );
44
- }
44
+ },
45
45
  } );
@@ -30,8 +30,14 @@ var Button = function Button(_ref) {
30
30
  justifyContent: 'center',
31
31
  height: '36px',
32
32
  py: 0,
33
+ '&:focus': function focus(theme) {
34
+ return theme.outline;
35
+ },
36
+ '&:focus-visible': function focusVisible(theme) {
37
+ return theme.outline;
38
+ },
33
39
  '&:disabled': {
34
- opacity: 0.5,
40
+ opacity: 0.7,
35
41
  cursor: 'not-allowed',
36
42
  pointerEvents: 'all'
37
43
  }
@@ -47,6 +47,15 @@ var Toggle = function Toggle(_ref) {
47
47
  backgroundPosition: 'right 2px top 2px',
48
48
  backgroundImage: "url(\n\t\t\t\t'data:image/svg+xml;utf8,<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4.53846 3L3 4.53846L6.46156 8.00001L3.00003 11.4615L4.53848 13L8.00001 9.53847L11.4615 13L13 11.4615L9.53847 8.00001L13 4.53849L11.4615 3.00003L8.00001 6.46156L4.53846 3Z\" fill=\"white\"/></svg>')",
49
49
  WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)',
50
+ '&:focus': function focus(theme) {
51
+ return theme.outline;
52
+ },
53
+ '&:focus-visible': function focusVisible(theme) {
54
+ return theme.outline;
55
+ },
56
+ '&[disabled]': {
57
+ opacity: 0.7
58
+ },
50
59
  '&[data-state="checked"]': {
51
60
  backgroundColor: variant,
52
61
  backgroundPosition: 'left 2px top 2px',
@@ -42,6 +42,10 @@ var Default = function Default(args) {
42
42
  checked: args.checked,
43
43
  defaultChecked: false,
44
44
  "aria-label": "Feature flag 2"
45
+ }), (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)(_.Toggle, {
46
+ "aria-label": "Feature Disabled",
47
+ disabled: true,
48
+ defaultChecked: false
45
49
  })]
46
50
  });
47
51
  };
@@ -33,6 +33,12 @@ var Link = function Link(_ref) {
33
33
  },
34
34
  '&:hover, &:focus': {
35
35
  color: 'heading'
36
+ },
37
+ '&:focus': function focus(theme) {
38
+ return theme.outline;
39
+ },
40
+ '&:focus-visible': function focusVisible(theme) {
41
+ return theme.outline;
36
42
  }
37
43
  }, sx)
38
44
  }));
@@ -58,10 +58,11 @@ var DialogClose = /*#__PURE__*/_react["default"].forwardRef(function (props, for
58
58
  outlineColor: 'primary',
59
59
  outlineWidth: '2px'
60
60
  },
61
- '&:focus': {
62
- outlineStyle: 'solid',
63
- outlineColor: 'primary',
64
- outlineWidth: '2px'
61
+ '&:focus': function focus(theme) {
62
+ return theme.outline;
63
+ },
64
+ '&:focus-visible': function focusVisible(theme) {
65
+ return theme.outline;
65
66
  }
66
67
  },
67
68
  children: (0, _jsxRuntime.jsx)(_io.IoClose, {
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.getColor = void 0;
7
+
8
+ var _valetColor = _interopRequireDefault(require("../../../tokens/valet-color.json"));
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ var ThemeColors = _valetColor["default"]['productive-color-wpvip'];
14
+ var CoreColors = _valetColor["default"]['valet-core'];
15
+
16
+ var getColor = function getColor(color, variant) {
17
+ if (variant === void 0) {
18
+ variant = 'default';
19
+ }
20
+
21
+ if (!ThemeColors[color]) {
22
+ return '#000000';
23
+ }
24
+
25
+ var colorValue = ThemeColors[color][variant].value;
26
+
27
+ if (colorValue.startsWith('{')) {
28
+ var _colorValue$replace$s = colorValue.replace(/[{}]/g, '').split('.'),
29
+ name = _colorValue$replace$s[0],
30
+ number = _colorValue$replace$s[1]; // Some colors are flat, there is no sub values.
31
+
32
+
33
+ if (CoreColors[name][number]) {
34
+ return CoreColors[name][number].value;
35
+ }
36
+
37
+ return CoreColors[name].value;
38
+ }
39
+
40
+ return colorValue;
41
+ };
42
+
43
+ exports.getColor = getColor;
@@ -9,6 +9,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
 
10
10
  var _colors = require("./colors");
11
11
 
12
+ var _getColor = require("./getColor");
13
+
12
14
  /**
13
15
  * Internal dependencies
14
16
  */
@@ -59,7 +61,14 @@ var textStyles = {
59
61
  letterSpacing: '.05em'
60
62
  }
61
63
  };
64
+ var outline = {
65
+ outlineStyle: 'solid',
66
+ outlineColor: '#ffffff',
67
+ outlineWidth: '1px',
68
+ boxShadow: "0 0 0 1px #fff, 0 0 0 3px " + (0, _getColor.getColor)('focus')
69
+ };
62
70
  var _default = {
71
+ outline: outline,
63
72
  space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
64
73
  fonts: {
65
74
  body: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif',
@@ -86,8 +95,8 @@ var _default = {
86
95
  },
87
96
  initialColorModeName: 'light',
88
97
  colors: (0, _extends2["default"])({
89
- text: _colors.light.grey['90'],
90
- heading: _colors.light.grey['100'],
98
+ text: (0, _getColor.getColor)('text', 'secondary'),
99
+ heading: (0, _getColor.getColor)('text', 'primary'),
91
100
  background: '#fdfdfd',
92
101
  backgroundSecondary: _colors.light.grey['10'],
93
102
  primary: _colors.light.brand['70'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "main": "build/system/index.js",
5
5
  "scripts": {
6
6
  "build-storybook": "build-storybook",
@@ -16,8 +16,10 @@ const Button = ( { sx, ...props } ) => (
16
16
  justifyContent: 'center',
17
17
  height: '36px',
18
18
  py: 0,
19
+ '&:focus': theme => theme.outline,
20
+ '&:focus-visible': theme => theme.outline,
19
21
  '&:disabled': {
20
- opacity: 0.5,
22
+ opacity: 0.7,
21
23
  cursor: 'not-allowed',
22
24
  pointerEvents: 'all',
23
25
  },
@@ -34,6 +34,11 @@ export const Toggle = ( {
34
34
  'data:image/svg+xml;utf8,<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.53846 3L3 4.53846L6.46156 8.00001L3.00003 11.4615L4.53848 13L8.00001 9.53847L11.4615 13L13 11.4615L9.53847 8.00001L13 4.53849L11.4615 3.00003L8.00001 6.46156L4.53846 3Z" fill="white"/></svg>')`,
35
35
  WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)',
36
36
 
37
+ '&:focus': theme => theme.outline,
38
+ '&:focus-visible': theme => theme.outline,
39
+ '&[disabled]': {
40
+ opacity: 0.7,
41
+ },
37
42
  '&[data-state="checked"]': {
38
43
  backgroundColor: variant,
39
44
  backgroundPosition: 'left 2px top 2px',
@@ -33,6 +33,11 @@ const Default = args => (
33
33
  <br />
34
34
 
35
35
  <Toggle checked={ args.checked } defaultChecked={ false } aria-label="Feature flag 2" />
36
+
37
+ <br />
38
+ <br />
39
+
40
+ <Toggle aria-label="Feature Disabled" disabled defaultChecked={ false } />
36
41
  </form>
37
42
  );
38
43
 
@@ -20,6 +20,8 @@ const Link = ( { active = false, sx, ...props } ) => (
20
20
  '&:hover, &:focus': {
21
21
  color: 'heading',
22
22
  },
23
+ '&:focus': theme => theme.outline,
24
+ '&:focus-visible': theme => theme.outline,
23
25
  ...sx,
24
26
  } }
25
27
  />
@@ -34,7 +34,8 @@ export const DialogClose = React.forwardRef( ( props, forwardedRef ) => (
34
34
  outlineColor: 'primary',
35
35
  outlineWidth: '2px',
36
36
  },
37
- '&:focus': { outlineStyle: 'solid', outlineColor: 'primary', outlineWidth: '2px' },
37
+ '&:focus': theme => theme.outline,
38
+ '&:focus-visible': theme => theme.outline,
38
39
  } }
39
40
  >
40
41
  <IoClose aria-hidden="true" />
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+
5
+ import Valet from '../../../tokens/valet-color.json';
6
+
7
+ const ThemeColors = Valet[ 'productive-color-wpvip' ];
8
+ const CoreColors = Valet[ 'valet-core' ];
9
+
10
+ export const getColor = ( color, variant = 'default' ) => {
11
+ if ( ! ThemeColors[ color ] ) {
12
+ return '#000000';
13
+ }
14
+
15
+ const colorValue = ThemeColors[ color ][ variant ].value;
16
+
17
+ if ( colorValue.startsWith( '{' ) ) {
18
+ const [ name, number ] = colorValue.replace( /[{}]/g, '' ).split( '.' );
19
+
20
+ // Some colors are flat, there is no sub values.
21
+ if ( CoreColors[ name ][ number ] ) {
22
+ return CoreColors[ name ][ number ].value;
23
+ }
24
+
25
+ return CoreColors[ name ].value;
26
+ }
27
+
28
+ return colorValue;
29
+ };
@@ -2,6 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import { light, dark } from './colors';
5
+ import { getColor } from './getColor';
5
6
 
6
7
  const textStyles = {
7
8
  h1: {
@@ -51,7 +52,15 @@ const textStyles = {
51
52
  },
52
53
  };
53
54
 
55
+ const outline = {
56
+ outlineStyle: 'solid',
57
+ outlineColor: '#ffffff',
58
+ outlineWidth: '1px',
59
+ boxShadow: `0 0 0 1px #fff, 0 0 0 3px ${ getColor( 'focus' ) }`,
60
+ };
61
+
54
62
  export default {
63
+ outline,
55
64
  space: [ 0, 4, 8, 16, 32, 64, 128, 256, 512 ],
56
65
  fonts: {
57
66
  body: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif',
@@ -78,8 +87,8 @@ export default {
78
87
  },
79
88
  initialColorModeName: 'light',
80
89
  colors: {
81
- text: light.grey[ '90' ],
82
- heading: light.grey[ '100' ],
90
+ text: getColor( 'text', 'secondary' ),
91
+ heading: getColor( 'text', 'primary' ),
83
92
  background: '#fdfdfd',
84
93
  backgroundSecondary: light.grey[ '10' ],
85
94
  primary: light.brand[ '70' ],