@automattic/vip-design-system 2.0.0 → 2.2.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.
@@ -5,7 +5,6 @@
5
5
  import { Argument } from 'classnames';
6
6
  import { ImageProps, ThemeUIStyleObject } from 'theme-ui';
7
7
  export interface AvatarProps {
8
- isVIP?: boolean;
9
8
  size?: number;
10
9
  src?: string;
11
10
  name?: string;
@@ -7,7 +7,7 @@ var _react = require("react");
7
7
  var _themeUi = require("theme-ui");
8
8
  var _ = require("..");
9
9
  var _jsxRuntime = require("theme-ui/jsx-runtime");
10
- var _excluded = ["isVIP", "name", "size", "src", "className", "sx"];
10
+ var _excluded = ["name", "size", "src", "className", "sx"];
11
11
  /**
12
12
  * External dependencies
13
13
  */
@@ -18,9 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
18
18
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
19
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
20
  var Avatar = exports.Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
21
- var _ref$isVIP = _ref.isVIP,
22
- isVIP = _ref$isVIP === void 0 ? false : _ref$isVIP,
23
- name = _ref.name,
21
+ var name = _ref.name,
24
22
  _ref$size = _ref.size,
25
23
  size = _ref$size === void 0 ? 32 : _ref$size,
26
24
  src = _ref.src,
@@ -31,21 +29,15 @@ var Avatar = exports.Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
31
29
  return (0, _jsxRuntime.jsx)(_.Box, _extends({
32
30
  sx: _extends({
33
31
  borderRadius: '100%',
34
- height: size + 2,
35
- // +2 to compensate padding on both sides
36
- width: size + 2,
37
- // +2 to compensate padding on both sides
38
- borderWidth: '2px',
39
- borderStyle: 'solid',
40
- borderColor: isVIP || isVIP === undefined ? 'primary' : 'transparent',
32
+ height: size,
33
+ width: size,
41
34
  overflow: 'hidden',
42
- backgroundColor: 'primary',
35
+ border: 'none',
36
+ backgroundColor: 'icon.primary',
43
37
  display: 'inline-flex',
44
38
  alignItems: 'center',
45
39
  justifyContent: 'center',
46
- color: 'white',
47
- padding: '1px',
48
- // this should probably be replaced with a token
40
+ color: 'inverse',
49
41
  textAlign: 'center'
50
42
  }, sx),
51
43
  className: (0, _classnames["default"])('vip-avatar-component', className),
@@ -63,10 +55,10 @@ var Avatar = exports.Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
63
55
  }) : (0, _jsxRuntime.jsx)(_.Text, {
64
56
  as: "span",
65
57
  sx: {
66
- color: 'white',
58
+ color: 'icon.inverse',
67
59
  mb: 0,
68
60
  fontWeight: 'bold',
69
- fontSize: 0,
61
+ fontSize: 2,
70
62
  textTransform: 'uppercase'
71
63
  },
72
64
  children: name ? name.charAt(0) : null
@@ -13,4 +13,5 @@ declare const _default: {
13
13
  };
14
14
  export default _default;
15
15
  type Story = StoryObj<typeof Avatar>;
16
- export declare const Default: Story;
16
+ export declare const Default: () => import("react").JSX.Element;
17
+ export declare const WithName: Story;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports["default"] = exports.Default = void 0;
4
+ exports["default"] = exports.WithName = exports.Default = void 0;
5
5
  var _ = require("..");
6
+ var _jsxRuntime = require("theme-ui/jsx-runtime");
6
7
  /**
7
8
  * External dependencies
8
9
  */
@@ -13,4 +14,20 @@ var _default = exports["default"] = {
13
14
  title: 'Avatar',
14
15
  component: _.Avatar
15
16
  };
16
- var Default = exports.Default = {};
17
+ var COMMON_SIZES = [128, 64, 48, 32, 24, 16];
18
+ var Default = exports.Default = function Default() {
19
+ return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
20
+ children: COMMON_SIZES.map(function (size) {
21
+ return (0, _jsxRuntime.jsx)(_.Avatar, {
22
+ size: size,
23
+ src: "https://i.pravatar.cc/100"
24
+ }, size);
25
+ })
26
+ });
27
+ };
28
+ var WithName = exports.WithName = {
29
+ args: {
30
+ name: 'Kitty',
31
+ size: 30
32
+ }
33
+ };
@@ -3,7 +3,7 @@
3
3
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
4
4
  export interface CheckboxProps extends CheckboxPrimitive.CheckboxProps {
5
5
  disabled?: boolean;
6
- variant?: 'primary' | 'success' | 'error' | 'warning' | 'info' | 'disabled';
6
+ variant?: 'primary' | 'success' | 'brand' | 'disabled';
7
7
  }
8
8
  declare const Checkbox: ({ disabled, onCheckedChange, variant, ...props }: CheckboxProps) => import("react").JSX.Element;
9
9
  export { Checkbox };
@@ -39,9 +39,6 @@ var Checkbox = exports.Checkbox = function Checkbox(_ref3) {
39
39
  variant = 'disabled';
40
40
  }
41
41
  return (0, _jsxRuntime.jsx)(StyledCheckbox, _extends({
42
- sx: {
43
- opacity: disabled ? 0.4 : 1
44
- },
45
42
  onCheckedChange: disabled ? undefined : onCheckedChange,
46
43
  "aria-disabled": disabled,
47
44
  variant: variant
@@ -33,7 +33,7 @@ var Default = exports.Default = function Default() {
33
33
  checked2 = _useState2[0],
34
34
  setChecked2 = _useState2[1];
35
35
  return (0, _jsxRuntime.jsxs)(_.Form.Root, {
36
- children: [['primary', 'success', 'error', 'warning', 'info'].map(function (variant) {
36
+ children: [['primary', 'brand'].map(function (variant) {
37
37
  return (0, _jsxRuntime.jsxs)(_.Form.Fieldset, {
38
38
  children: [(0, _jsxRuntime.jsxs)(_.Form.Legend, {
39
39
  children: ["Tell me your ", variant, " prefereces"]
@@ -49,10 +49,6 @@ var Default = exports.Default = function Default() {
49
49
  onCheckedChange: setChecked
50
50
  }), (0, _jsxRuntime.jsx)(_Label.Label, {
51
51
  clickable: true,
52
- sx: {
53
- m: 0,
54
- ml: 2
55
- },
56
52
  htmlFor: "check1-" + variant,
57
53
  id: "label-check1-" + variant,
58
54
  children: "This option"
@@ -69,10 +65,6 @@ var Default = exports.Default = function Default() {
69
65
  onCheckedChange: setChecked2
70
66
  }), (0, _jsxRuntime.jsx)(_Label.Label, {
71
67
  clickable: true,
72
- sx: {
73
- m: 0,
74
- ml: 2
75
- },
76
68
  htmlFor: "check2-" + variant,
77
69
  id: "label-check2-" + variant,
78
70
  children: "This option too"
@@ -95,10 +87,6 @@ var Default = exports.Default = function Default() {
95
87
  onCheckedChange: setChecked
96
88
  }), (0, _jsxRuntime.jsx)(_Label.Label, {
97
89
  clickable: true,
98
- sx: {
99
- m: 0,
100
- ml: 2
101
- },
102
90
  htmlFor: "check1-disabled",
103
91
  id: "label-check1-disabled",
104
92
  children: "This option"
@@ -115,10 +103,6 @@ var Default = exports.Default = function Default() {
115
103
  onCheckedChange: setChecked2
116
104
  }), (0, _jsxRuntime.jsx)(_Label.Label, {
117
105
  clickable: true,
118
- sx: {
119
- m: 0,
120
- ml: 2
121
- },
122
106
  htmlFor: "check2-disabled",
123
107
  id: "label-check2-disabled",
124
108
  children: "This option too"
@@ -136,7 +120,7 @@ var Indeterminate = exports.Indeterminate = function Indeterminate() {
136
120
  }
137
121
  }, [checkRef]);
138
122
  return (0, _jsxRuntime.jsxs)(_.Form.Root, {
139
- children: [['primary', 'success', 'error', 'warning', 'info'].map(function (variant) {
123
+ children: [['primary', 'brand'].map(function (variant) {
140
124
  return (0, _jsxRuntime.jsxs)(_.Form.Fieldset, {
141
125
  children: [(0, _jsxRuntime.jsxs)(_.Form.Legend, {
142
126
  children: ["Indeterminate state ", variant]
@@ -150,10 +134,6 @@ var Indeterminate = exports.Indeterminate = function Indeterminate() {
150
134
  "aria-labelledby": "label-check1-" + variant,
151
135
  checked: 'indeterminate'
152
136
  }), (0, _jsxRuntime.jsx)(_Label.Label, {
153
- sx: {
154
- m: 0,
155
- ml: 2
156
- },
157
137
  htmlFor: "check1-" + variant,
158
138
  id: "label-check1-" + variant,
159
139
  children: "This option"
@@ -173,10 +153,6 @@ var Indeterminate = exports.Indeterminate = function Indeterminate() {
173
153
  "aria-labelledby": "label-check1-disabled",
174
154
  checked: 'indeterminate'
175
155
  }), (0, _jsxRuntime.jsx)(_Label.Label, {
176
- sx: {
177
- m: 0,
178
- ml: 2
179
- },
180
156
  htmlFor: "check1-disabled",
181
157
  id: "label-check1-disabled",
182
158
  children: "This option"
@@ -7,6 +7,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
7
7
  // The output willl be 16px because of the 1px border.
8
8
  var CHECKBOX_SIZE = 14;
9
9
  var checkboxStyle = exports.checkboxStyle = function checkboxStyle(variant) {
10
+ var variantColor = variant === 'disabled' ? 'input.background.disabled' : variant;
10
11
  return _extends({
11
12
  all: 'unset',
12
13
  position: 'relative',
@@ -14,7 +15,7 @@ var checkboxStyle = exports.checkboxStyle = function checkboxStyle(variant) {
14
15
  }, _Input.baseControlBorderStyle, _Input.baseControlFocusStyle, {
15
16
  width: CHECKBOX_SIZE,
16
17
  height: CHECKBOX_SIZE,
17
- borderRadius: 1,
18
+ borderRadius: 0,
18
19
  display: 'flex',
19
20
  justifyContent: 'center',
20
21
  '&[aria-disabled="true"]': {
@@ -22,30 +23,40 @@ var checkboxStyle = exports.checkboxStyle = function checkboxStyle(variant) {
22
23
  cursor: 'not-allowed',
23
24
  pointerEvents: 'none'
24
25
  },
25
- '&[data-state=checked]': {
26
- backgroundColor: variant,
27
- color: variant,
28
- borderColor: variant
26
+ '&[data-state=checked], &[data-state=indeterminate]': {
27
+ backgroundColor: variantColor,
28
+ color: variantColor,
29
+ borderColor: variantColor
30
+ },
31
+ '& ~ label': {
32
+ fontWeight: 'regular',
33
+ color: _Input.inputBaseText,
34
+ m: 0,
35
+ ml: 2
29
36
  },
30
37
  svg: {
31
38
  position: 'absolute',
39
+ fill: 'currentColor',
32
40
  top: 0,
33
41
  left: 0
34
42
  }
35
43
  });
36
44
  };
37
45
  var checkboxIndicatorStyle = exports.checkboxIndicatorStyle = function checkboxIndicatorStyle(variant) {
46
+ var backgroundColor = variant === 'disabled' ? 'icon.inverse-disabled' : 'icon.inverse';
38
47
  return {
39
48
  width: 14,
40
49
  height: 14,
41
- backgroundImage: "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='1 1 14 14' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M13.9259 4.9995L6.15142 12.4008L2.92603 9.33023L4.2591 7.92994L6.15142 9.73143L12.5928 3.59921L13.9259 4.9995Z' fill='white'/%3E%3C/svg%3E\")",
50
+ backgroundColor: backgroundColor,
51
+ maskImage: "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='1 1 14 14' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M13.9259 4.9995L6.15142 12.4008L2.92603 9.33023L4.2591 7.92994L6.15142 9.73143L12.5928 3.59921L13.9259 4.9995Z' fill='currentcolor'/%3E%3C/svg%3E\")",
42
52
  '&[data-state=indeterminate]': {
43
- marginTop: '6px',
44
- backgroundImage: 'none',
45
- backgroundColor: variant,
53
+ maskImage: 'none',
54
+ backgroundColor: backgroundColor,
46
55
  position: 'absolute',
47
- width: 10,
48
- height: 2
56
+ top: '50%',
57
+ width: 8,
58
+ height: 2,
59
+ marginTop: '-1px'
49
60
  }
50
61
  };
51
62
  };
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import { RadioOptionOptionProps } from './RadioOption';
4
4
  export declare const VIP_RADIO = "vip-radio-component";
5
5
  export type RadioProps = {
6
- variant?: 'primary' | 'success' | 'error' | 'warning' | 'info' | 'disabled';
6
+ variant?: 'primary' | 'success' | 'brand' | 'disabled';
7
7
  disabled?: boolean | undefined;
8
8
  defaultValue?: string | number;
9
9
  onChange?: (e: React.ChangeEvent<HTMLInputElement>, option?: RadioOptionOptionProps) => void;
@@ -32,7 +32,7 @@ var Default = exports.Default = function Default() {
32
32
  setChecked(_extends({}, checked, (_extends2 = {}, _extends2[radioName] = value, _extends2)));
33
33
  };
34
34
  return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
35
- children: [['primary', 'success', 'error', 'warning', 'info'].map(function (variant) {
35
+ children: [['primary', 'brand'].map(function (variant) {
36
36
  return (0, _jsxRuntime.jsxs)(_2.Box, {
37
37
  children: [(0, _jsxRuntime.jsx)(_2.Heading, {
38
38
  as: "h2",
@@ -64,7 +64,7 @@ var Default = exports.Default = function Default() {
64
64
  sx: {
65
65
  textTransform: 'capitalize'
66
66
  },
67
- children: "Disabled"
67
+ children: "disabled"
68
68
  }), (0, _jsxRuntime.jsx)(_Radio.Radio, {
69
69
  disabled: true,
70
70
  name: "the_option_",
@@ -169,7 +169,7 @@ var AcessibleExamples = exports.AcessibleExamples = function AcessibleExamples()
169
169
  fontSize: 2,
170
170
  fontWeight: 'bold'
171
171
  },
172
- children: "All Disabled options"
172
+ children: "All disabled options"
173
173
  }), (0, _jsxRuntime.jsx)(_Flex.Flex, {
174
174
  sx: {
175
175
  alignItems: 'center'
@@ -2,13 +2,16 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.labelStyle = exports.itemStyle = exports.inputStyle = void 0;
5
- var _ScreenReaderText = require("../../ScreenReaderText/ScreenReaderText");
6
5
  var _Input = require("../Input.styles");
7
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
8
6
  // The output willl be 18px because of the 1px border.
9
7
  var RADIO_SIZE = 16;
10
8
  var inputStyle = exports.inputStyle = function inputStyle(variant) {
11
- return _extends({}, _ScreenReaderText.screenReaderTextClass, {
9
+ return {
10
+ position: 'absolute',
11
+ top: 0,
12
+ left: 0,
13
+ clip: 'rect(1px, 1px, 1px, 1px)',
14
+ clipPath: 'inset(50%)',
12
15
  width: RADIO_SIZE,
13
16
  height: RADIO_SIZE,
14
17
  '&:focus ~ label:before': {
@@ -16,7 +19,7 @@ var inputStyle = exports.inputStyle = function inputStyle(variant) {
16
19
  content: '""',
17
20
  border: '1px solid',
18
21
  borderColor: _Input.baseControlBorderStyle.borderColor,
19
- left: -5
22
+ left: 0
20
23
  },
21
24
  '&:checked ~ label::after': {
22
25
  borderColor: variant,
@@ -26,22 +29,20 @@ var inputStyle = exports.inputStyle = function inputStyle(variant) {
26
29
  backgroundColor: variant,
27
30
  borderColor: variant
28
31
  }
29
- });
32
+ };
30
33
  };
31
34
  var labelStyle = exports.labelStyle = function labelStyle(variant) {
32
35
  return {
36
+ display: 'flex',
33
37
  cursor: 'pointer',
34
38
  position: 'relative',
35
- marginLeft: 5,
36
39
  marginBottom: 0,
37
40
  userSelect: 'none',
38
41
  color: _Input.inputBaseText,
39
- lineHeight: 'body',
42
+ fontWeight: 'regular',
43
+ lineHeight: 'normal',
40
44
  '&:before, &:after': {
41
45
  borderRadius: '100%',
42
- position: 'absolute',
43
- top: 1,
44
- left: -5,
45
46
  transition: 'all .3s ease-out',
46
47
  width: RADIO_SIZE,
47
48
  height: RADIO_SIZE
@@ -49,9 +50,13 @@ var labelStyle = exports.labelStyle = function labelStyle(variant) {
49
50
  '&::before': {
50
51
  content: '""',
51
52
  border: '1px solid',
52
- borderColor: _Input.baseControlBorderStyle.borderColor
53
+ borderColor: _Input.baseControlBorderStyle.borderColor,
54
+ marginRight: 2
53
55
  },
54
56
  '&::after': {
57
+ position: 'absolute',
58
+ top: 0,
59
+ left: 0,
55
60
  content: '""',
56
61
  backgroundColor: variant,
57
62
  backgroundSize: '100%',
@@ -66,5 +71,6 @@ var labelStyle = exports.labelStyle = function labelStyle(variant) {
66
71
  var itemStyle = exports.itemStyle = {
67
72
  display: 'flex',
68
73
  alignItems: 'center',
69
- my: 2
74
+ my: 2,
75
+ position: 'relative'
70
76
  };
@@ -38,6 +38,7 @@ const RadioOption = ( {
38
38
  backgroundColor: 'input.radio-box.background.default',
39
39
  cursor: 'pointer',
40
40
  borderRadius: 2,
41
+ minWidth: 220,
41
42
  textAlign: 'left',
42
43
  border: '1px solid',
43
44
  borderColor: 'input.radio-box.border.default',
@@ -82,7 +82,6 @@ var VIPDashboardLike = exports.VIPDashboardLike = {
82
82
  children: [(0, _jsxRuntime.jsx)(_.Toolbar.Separator, {}), (0, _jsxRuntime.jsxs)("a", {
83
83
  href: "/",
84
84
  children: [(0, _jsxRuntime.jsx)(_system.Avatar, {
85
- isVIP: true,
86
85
  name: "John Doe",
87
86
  src: "https://i.pravatar.cc/80"
88
87
  }), (0, _jsxRuntime.jsx)(_ScreenReaderText["default"], {
@@ -6,6 +6,5 @@
6
6
 
7
7
  export default theme => ( {
8
8
  ...theme.color,
9
- brand: theme.color.gold,
10
9
  grey: theme.color.gray,
11
10
  } );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "main": "build/system/index.js",
5
5
  "scripts": {
6
6
  "build-storybook": "storybook build",
@@ -16,4 +16,18 @@ export default {
16
16
 
17
17
  type Story = StoryObj< typeof Avatar >;
18
18
 
19
- export const Default: Story = {};
19
+ const COMMON_SIZES = [ 128, 64, 48, 32, 24, 16 ];
20
+
21
+ export const Default = () => (
22
+ <>
23
+ { COMMON_SIZES.map( size => (
24
+ <Avatar key={ size } size={ size } src="https://i.pravatar.cc/100" />
25
+ ) ) }
26
+ </>
27
+ );
28
+ export const WithName: Story = {
29
+ args: {
30
+ name: 'Kitty',
31
+ size: 30,
32
+ },
33
+ };
@@ -11,7 +11,6 @@ import { Image, ImageProps, ThemeUIStyleObject } from 'theme-ui';
11
11
  import { Box, Text } from '..';
12
12
 
13
13
  export interface AvatarProps {
14
- isVIP?: boolean;
15
14
  size?: number;
16
15
  src?: string;
17
16
  name?: string;
@@ -23,24 +22,21 @@ type AvatarImageProps = AvatarProps & ImageProps;
23
22
 
24
23
  export const Avatar = forwardRef< HTMLElement, AvatarImageProps >(
25
24
  (
26
- { isVIP = false, name, size = 32, src, className, sx = {}, ...props }: AvatarImageProps,
25
+ { name, size = 32, src, className, sx = {}, ...props }: AvatarImageProps,
27
26
  ref: Ref< HTMLElement >
28
27
  ) => (
29
28
  <Box
30
29
  sx={ {
31
30
  borderRadius: '100%',
32
- height: size + 2, // +2 to compensate padding on both sides
33
- width: size + 2, // +2 to compensate padding on both sides
34
- borderWidth: '2px',
35
- borderStyle: 'solid',
36
- borderColor: isVIP || isVIP === undefined ? 'primary' : 'transparent',
31
+ height: size,
32
+ width: size,
37
33
  overflow: 'hidden',
38
- backgroundColor: 'primary',
34
+ border: 'none',
35
+ backgroundColor: 'icon.primary',
39
36
  display: 'inline-flex',
40
37
  alignItems: 'center',
41
38
  justifyContent: 'center',
42
- color: 'white',
43
- padding: '1px', // this should probably be replaced with a token
39
+ color: 'inverse',
44
40
  textAlign: 'center',
45
41
  ...sx,
46
42
  } }
@@ -63,10 +59,10 @@ export const Avatar = forwardRef< HTMLElement, AvatarImageProps >(
63
59
  <Text
64
60
  as="span"
65
61
  sx={ {
66
- color: 'white',
62
+ color: 'icon.inverse',
67
63
  mb: 0,
68
64
  fontWeight: 'bold',
69
- fontSize: 0,
65
+ fontSize: 2,
70
66
  textTransform: 'uppercase',
71
67
  } }
72
68
  >
@@ -61,9 +61,7 @@ export const Default = () => {
61
61
 
62
62
  return (
63
63
  <Form.Root>
64
- { (
65
- [ 'primary', 'success', 'error', 'warning', 'info' ] as CheckboxProps[ 'variant' ][]
66
- ).map( variant => (
64
+ { ( [ 'primary', 'brand' ] as CheckboxProps[ 'variant' ][] ).map( variant => (
67
65
  <Form.Fieldset key={ variant }>
68
66
  <Form.Legend>Tell me your { variant } prefereces</Form.Legend>
69
67
 
@@ -75,12 +73,7 @@ export const Default = () => {
75
73
  aria-labelledby={ `label-check1-${ variant }` }
76
74
  onCheckedChange={ setChecked }
77
75
  />
78
- <Label
79
- clickable
80
- sx={ { m: 0, ml: 2 } }
81
- htmlFor={ `check1-${ variant }` }
82
- id={ `label-check1-${ variant }` }
83
- >
76
+ <Label clickable htmlFor={ `check1-${ variant }` } id={ `label-check1-${ variant }` }>
84
77
  This option
85
78
  </Label>
86
79
  </Flex>
@@ -93,12 +86,7 @@ export const Default = () => {
93
86
  aria-labelledby={ `label-check2-${ variant }` }
94
87
  onCheckedChange={ setChecked2 }
95
88
  />
96
- <Label
97
- clickable
98
- sx={ { m: 0, ml: 2 } }
99
- htmlFor={ `check2-${ variant }` }
100
- id={ `label-check2-${ variant }` }
101
- >
89
+ <Label clickable htmlFor={ `check2-${ variant }` } id={ `label-check2-${ variant }` }>
102
90
  This option too
103
91
  </Label>
104
92
  </Flex>
@@ -117,12 +105,7 @@ export const Default = () => {
117
105
  aria-labelledby={ `label-check1-disabled` }
118
106
  onCheckedChange={ setChecked }
119
107
  />
120
- <Label
121
- clickable
122
- sx={ { m: 0, ml: 2 } }
123
- htmlFor={ `check1-disabled` }
124
- id={ `label-check1-disabled` }
125
- >
108
+ <Label clickable htmlFor={ `check1-disabled` } id={ `label-check1-disabled` }>
126
109
  This option
127
110
  </Label>
128
111
  </Flex>
@@ -135,12 +118,7 @@ export const Default = () => {
135
118
  aria-labelledby={ `label-check2-disabled` }
136
119
  onCheckedChange={ setChecked2 }
137
120
  />
138
- <Label
139
- clickable
140
- sx={ { m: 0, ml: 2 } }
141
- htmlFor={ `check2-disabled` }
142
- id={ `label-check2-disabled` }
143
- >
121
+ <Label clickable htmlFor={ `check2-disabled` } id={ `label-check2-disabled` }>
144
122
  This option too
145
123
  </Label>
146
124
  </Flex>
@@ -161,9 +139,7 @@ export const Indeterminate = () => {
161
139
 
162
140
  return (
163
141
  <Form.Root>
164
- { (
165
- [ 'primary', 'success', 'error', 'warning', 'info' ] as CheckboxProps[ 'variant' ][]
166
- ).map( variant => (
142
+ { ( [ 'primary', 'brand' ] as CheckboxProps[ 'variant' ][] ).map( variant => (
167
143
  <Form.Fieldset key={ variant }>
168
144
  <Form.Legend>Indeterminate state { variant }</Form.Legend>
169
145
 
@@ -174,11 +150,8 @@ export const Indeterminate = () => {
174
150
  aria-labelledby={ `label-check1-${ variant }` }
175
151
  checked={ 'indeterminate' }
176
152
  />
177
- <Label
178
- sx={ { m: 0, ml: 2 } }
179
- htmlFor={ `check1-${ variant }` }
180
- id={ `label-check1-${ variant }` }
181
- >
153
+
154
+ <Label htmlFor={ `check1-${ variant }` } id={ `label-check1-${ variant }` }>
182
155
  This option
183
156
  </Label>
184
157
  </Flex>
@@ -195,11 +168,7 @@ export const Indeterminate = () => {
195
168
  aria-labelledby={ `label-check1-disabled` }
196
169
  checked={ 'indeterminate' }
197
170
  />
198
- <Label
199
- sx={ { m: 0, ml: 2 } }
200
- htmlFor={ `check1-disabled` }
201
- id={ `label-check1-disabled` }
202
- >
171
+ <Label htmlFor={ `check1-disabled` } id={ `label-check1-disabled` }>
203
172
  This option
204
173
  </Label>
205
174
  </Flex>
@@ -7,7 +7,7 @@ import { RadioOptionProps } from '../Radio/RadioOption';
7
7
 
8
8
  export interface CheckboxProps extends CheckboxPrimitive.CheckboxProps {
9
9
  disabled?: boolean;
10
- variant?: 'primary' | 'success' | 'error' | 'warning' | 'info' | 'disabled';
10
+ variant?: 'primary' | 'success' | 'brand' | 'disabled';
11
11
  }
12
12
 
13
13
  const StyledCheckbox = ( { variant = 'primary', ...rest }: CheckboxProps ) => (
@@ -34,9 +34,6 @@ const Checkbox = ( {
34
34
 
35
35
  return (
36
36
  <StyledCheckbox
37
- sx={ {
38
- opacity: disabled ? 0.4 : 1,
39
- } }
40
37
  onCheckedChange={ disabled ? undefined : onCheckedChange }
41
38
  aria-disabled={ disabled }
42
39
  variant={ variant }
@@ -4,50 +4,68 @@ import {
4
4
  baseControlBorderStyle,
5
5
  baseControlFocusStyle,
6
6
  inputBaseBackground,
7
+ inputBaseText,
7
8
  } from '../Input.styles';
8
9
 
9
10
  // The output willl be 16px because of the 1px border.
10
11
  const CHECKBOX_SIZE = 14;
11
12
 
12
- export const checkboxStyle = ( variant: string ): ThemeUIStyleObject => ( {
13
- all: 'unset',
14
- position: 'relative',
15
- backgroundColor: inputBaseBackground,
16
- ...baseControlBorderStyle,
17
- ...baseControlFocusStyle,
18
- width: CHECKBOX_SIZE,
19
- height: CHECKBOX_SIZE,
20
- borderRadius: 1,
21
- display: 'flex',
22
- justifyContent: 'center',
23
- '&[aria-disabled="true"]': {
24
- opacity: 0.7,
25
- cursor: 'not-allowed',
26
- pointerEvents: 'none',
27
- },
28
- '&[data-state=checked]': {
29
- backgroundColor: variant,
30
- color: variant,
31
- borderColor: variant,
32
- },
33
- svg: {
34
- position: 'absolute',
35
- top: 0,
36
- left: 0,
37
- },
38
- } );
13
+ export const checkboxStyle = ( variant: string ): ThemeUIStyleObject => {
14
+ const variantColor = variant === 'disabled' ? 'input.background.disabled' : variant;
39
15
 
40
- export const checkboxIndicatorStyle = ( variant: string ): ThemeUIStyleObject => ( {
41
- width: 14,
42
- height: 14,
43
- backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='1 1 14 14' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M13.9259 4.9995L6.15142 12.4008L2.92603 9.33023L4.2591 7.92994L6.15142 9.73143L12.5928 3.59921L13.9259 4.9995Z' fill='white'/%3E%3C/svg%3E")`,
16
+ return {
17
+ all: 'unset',
18
+ position: 'relative',
19
+ backgroundColor: inputBaseBackground,
20
+ ...baseControlBorderStyle,
21
+ ...baseControlFocusStyle,
22
+ width: CHECKBOX_SIZE,
23
+ height: CHECKBOX_SIZE,
24
+ borderRadius: 0,
25
+ display: 'flex',
26
+ justifyContent: 'center',
27
+ '&[aria-disabled="true"]': {
28
+ opacity: 0.7,
29
+ cursor: 'not-allowed',
30
+ pointerEvents: 'none',
31
+ },
32
+ '&[data-state=checked], &[data-state=indeterminate]': {
33
+ backgroundColor: variantColor,
34
+ color: variantColor,
35
+ borderColor: variantColor,
36
+ },
37
+ '& ~ label': {
38
+ fontWeight: 'regular',
39
+ color: inputBaseText,
40
+ m: 0,
41
+ ml: 2,
42
+ },
43
+ svg: {
44
+ position: 'absolute',
45
+ fill: 'currentColor',
46
+ top: 0,
47
+ left: 0,
48
+ },
49
+ };
50
+ };
44
51
 
45
- '&[data-state=indeterminate]': {
46
- marginTop: '6px',
47
- backgroundImage: 'none',
48
- backgroundColor: variant,
49
- position: 'absolute',
50
- width: 10,
51
- height: 2,
52
- },
53
- } );
52
+ export const checkboxIndicatorStyle = ( variant: string ): ThemeUIStyleObject => {
53
+ const backgroundColor = variant === 'disabled' ? 'icon.inverse-disabled' : 'icon.inverse';
54
+
55
+ return {
56
+ width: 14,
57
+ height: 14,
58
+ backgroundColor,
59
+ maskImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='1 1 14 14' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M13.9259 4.9995L6.15142 12.4008L2.92603 9.33023L4.2591 7.92994L6.15142 9.73143L12.5928 3.59921L13.9259 4.9995Z' fill='currentcolor'/%3E%3C/svg%3E")`,
60
+
61
+ '&[data-state=indeterminate]': {
62
+ maskImage: 'none',
63
+ backgroundColor,
64
+ position: 'absolute',
65
+ top: '50%',
66
+ width: 8,
67
+ height: 2,
68
+ marginTop: '-1px',
69
+ },
70
+ };
71
+ };
@@ -62,39 +62,35 @@ export const Default = () => {
62
62
 
63
63
  return (
64
64
  <>
65
- { ( [ 'primary', 'success', 'error', 'warning', 'info' ] as RadioProps[ 'variant' ][] ).map(
66
- variant => (
67
- <Box key={ variant }>
68
- <Heading as="h2" sx={ { textTransform: 'capitalize' } }>
69
- { variant }
70
- </Heading>
71
-
72
- <Radio
73
- variant={ variant }
74
- onChange={ ( _, option ) =>
75
- toggleChecked( `the_option_${ variant }`, option?.value )
76
- }
77
- name={ `the_option_${ variant }` }
78
- defaultValue={ checked?.[ `the_option_${ variant }` ] || `${ variant }-option-a` }
79
- options={ [
80
- {
81
- id: `${ variant }-option-a`,
82
- value: `${ variant }-option-a`,
83
- label: `I am the ${ variant } option A`,
84
- },
85
- {
86
- id: `${ variant }-option-b`,
87
- value: `${ variant }-option-b`,
88
- label: `I am the ${ variant } option B`,
89
- },
90
- ] }
91
- />
92
- </Box>
93
- )
94
- ) }
65
+ { ( [ 'primary', 'brand' ] as RadioProps[ 'variant' ][] ).map( variant => (
66
+ <Box key={ variant }>
67
+ <Heading as="h2" sx={ { textTransform: 'capitalize' } }>
68
+ { variant }
69
+ </Heading>
70
+
71
+ <Radio
72
+ variant={ variant }
73
+ onChange={ ( _, option ) => toggleChecked( `the_option_${ variant }`, option?.value ) }
74
+ name={ `the_option_${ variant }` }
75
+ defaultValue={ checked?.[ `the_option_${ variant }` ] || `${ variant }-option-a` }
76
+ options={ [
77
+ {
78
+ id: `${ variant }-option-a`,
79
+ value: `${ variant }-option-a`,
80
+ label: `I am the ${ variant } option A`,
81
+ },
82
+ {
83
+ id: `${ variant }-option-b`,
84
+ value: `${ variant }-option-b`,
85
+ label: `I am the ${ variant } option B`,
86
+ },
87
+ ] }
88
+ />
89
+ </Box>
90
+ ) ) }
95
91
  <Box>
96
92
  <Heading as="h2" sx={ { textTransform: 'capitalize' } }>
97
- Disabled
93
+ disabled
98
94
  </Heading>
99
95
 
100
96
  <Radio
@@ -197,7 +193,7 @@ export const AcessibleExamples = () => {
197
193
 
198
194
  <Form.Fieldset>
199
195
  <Form.Legend sx={ { mb: 0, fontSize: 2, fontWeight: 'bold' } }>
200
- All Disabled options
196
+ All disabled options
201
197
  </Form.Legend>
202
198
 
203
199
  <Flex sx={ { alignItems: 'center' } }>
@@ -8,7 +8,7 @@ import { RadioOption, RadioOptionOptionProps } from './RadioOption';
8
8
  export const VIP_RADIO = 'vip-radio-component';
9
9
 
10
10
  export type RadioProps = {
11
- variant?: 'primary' | 'success' | 'error' | 'warning' | 'info' | 'disabled';
11
+ variant?: 'primary' | 'success' | 'brand' | 'disabled';
12
12
  disabled?: boolean | undefined;
13
13
  defaultValue?: string | number;
14
14
  onChange?: ( e: React.ChangeEvent< HTMLInputElement >, option?: RadioOptionOptionProps ) => void;
@@ -1,13 +1,16 @@
1
1
  import { ThemeUIStyleObject } from 'theme-ui';
2
2
 
3
- import { screenReaderTextClass } from '../../ScreenReaderText/ScreenReaderText';
4
3
  import { baseControlBorderStyle, inputBaseText } from '../Input.styles';
5
4
 
6
5
  // The output willl be 18px because of the 1px border.
7
6
  const RADIO_SIZE = 16;
8
7
 
9
8
  export const inputStyle = ( variant: string ): ThemeUIStyleObject => ( {
10
- ...screenReaderTextClass,
9
+ position: 'absolute',
10
+ top: 0,
11
+ left: 0,
12
+ clip: 'rect(1px, 1px, 1px, 1px)',
13
+ clipPath: 'inset(50%)',
11
14
  width: RADIO_SIZE,
12
15
  height: RADIO_SIZE,
13
16
  '&:focus ~ label:before': {
@@ -15,7 +18,7 @@ export const inputStyle = ( variant: string ): ThemeUIStyleObject => ( {
15
18
  content: '""',
16
19
  border: '1px solid',
17
20
  borderColor: baseControlBorderStyle.borderColor,
18
- left: -5,
21
+ left: 0,
19
22
  },
20
23
  '&:checked ~ label::after': {
21
24
  borderColor: variant,
@@ -28,18 +31,16 @@ export const inputStyle = ( variant: string ): ThemeUIStyleObject => ( {
28
31
  } );
29
32
 
30
33
  export const labelStyle = ( variant: string ): ThemeUIStyleObject => ( {
34
+ display: 'flex',
31
35
  cursor: 'pointer',
32
36
  position: 'relative',
33
- marginLeft: 5,
34
37
  marginBottom: 0,
35
38
  userSelect: 'none',
36
39
  color: inputBaseText,
37
- lineHeight: 'body',
40
+ fontWeight: 'regular',
41
+ lineHeight: 'normal',
38
42
  '&:before, &:after': {
39
43
  borderRadius: '100%',
40
- position: 'absolute',
41
- top: 1,
42
- left: -5,
43
44
  transition: 'all .3s ease-out',
44
45
  width: RADIO_SIZE,
45
46
  height: RADIO_SIZE,
@@ -48,8 +49,12 @@ export const labelStyle = ( variant: string ): ThemeUIStyleObject => ( {
48
49
  content: '""',
49
50
  border: '1px solid',
50
51
  borderColor: baseControlBorderStyle.borderColor,
52
+ marginRight: 2,
51
53
  },
52
54
  '&::after': {
55
+ position: 'absolute',
56
+ top: 0,
57
+ left: 0,
53
58
  content: '""',
54
59
  backgroundColor: variant,
55
60
  backgroundSize: '100%',
@@ -65,4 +70,5 @@ export const itemStyle: ThemeUIStyleObject = {
65
70
  display: 'flex',
66
71
  alignItems: 'center',
67
72
  my: 2,
73
+ position: 'relative',
68
74
  };
@@ -38,6 +38,7 @@ const RadioOption = ( {
38
38
  backgroundColor: 'input.radio-box.background.default',
39
39
  cursor: 'pointer',
40
40
  borderRadius: 2,
41
+ minWidth: 220,
41
42
  textAlign: 'left',
42
43
  border: '1px solid',
43
44
  borderColor: 'input.radio-box.border.default',
@@ -94,7 +94,7 @@ export const VIPDashboardLike: Story = {
94
94
  <Toolbar.Separator />
95
95
 
96
96
  <a href="/">
97
- <Avatar isVIP name="John Doe" src="https://i.pravatar.cc/80" />
97
+ <Avatar name="John Doe" src="https://i.pravatar.cc/80" />
98
98
  <ScreenReaderText>John Doe</ScreenReaderText>
99
99
  </a>
100
100
  </Toolbar.UtilNav>
@@ -6,6 +6,5 @@
6
6
 
7
7
  export default theme => ( {
8
8
  ...theme.color,
9
- brand: theme.color.gold,
10
9
  grey: theme.color.gray,
11
10
  } );
@@ -1506,9 +1506,9 @@
1506
1506
  }
1507
1507
  },
1508
1508
  "node_modules/follow-redirects": {
1509
- "version": "1.15.4",
1510
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
1511
- "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==",
1509
+ "version": "1.15.6",
1510
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
1511
+ "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
1512
1512
  "funding": [
1513
1513
  {
1514
1514
  "type": "individual",
@@ -4658,9 +4658,9 @@
4658
4658
  }
4659
4659
  },
4660
4660
  "follow-redirects": {
4661
- "version": "1.15.4",
4662
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
4663
- "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==",
4661
+ "version": "1.15.6",
4662
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
4663
+ "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
4664
4664
  "peer": true
4665
4665
  },
4666
4666
  "font-atlas": {