@automattic/vip-design-system 2.12.7 → 2.13.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.
@@ -868,6 +868,14 @@
868
868
  "success": {
869
869
  "type": "color",
870
870
  "value": "#d7efdf"
871
+ },
872
+ "neutral": {
873
+ "type": "color",
874
+ "value": "#ebe9e8"
875
+ },
876
+ "feature": {
877
+ "type": "color",
878
+ "value": "#e8ccffff"
871
879
  }
872
880
  },
873
881
  "text": {
@@ -886,6 +894,14 @@
886
894
  "success": {
887
895
  "type": "color",
888
896
  "value": "#003700"
897
+ },
898
+ "neutral": {
899
+ "type": "color",
900
+ "value": "#13191e"
901
+ },
902
+ "feature": {
903
+ "type": "color",
904
+ "value": "#270047ff"
889
905
  }
890
906
  },
891
907
  "icon": {
@@ -904,6 +920,14 @@
904
920
  "success": {
905
921
  "type": "color",
906
922
  "value": "#007934"
923
+ },
924
+ "neutral": {
925
+ "type": "color",
926
+ "value": "#9b9796"
927
+ },
928
+ "feature": {
929
+ "type": "color",
930
+ "value": "#a73dffff"
907
931
  }
908
932
  },
909
933
  "accent": {
@@ -922,6 +946,14 @@
922
946
  "success": {
923
947
  "type": "color",
924
948
  "value": "#40ba6f"
949
+ },
950
+ "neutral": {
951
+ "type": "color",
952
+ "value": "#827f7e"
953
+ },
954
+ "feature": {
955
+ "type": "color",
956
+ "value": "#8000ebff"
925
957
  }
926
958
  },
927
959
  "link": {
@@ -1000,6 +1032,25 @@
1000
1032
  "type": "color",
1001
1033
  "value": "#00611e"
1002
1034
  }
1035
+ },
1036
+ "neutral": {
1037
+ "default": {
1038
+ "type": "color",
1039
+ "description": "Use for text links",
1040
+ "value": "#13191e"
1041
+ },
1042
+ "hover": {
1043
+ "type": "color",
1044
+ "value": "#514e4d"
1045
+ },
1046
+ "active": {
1047
+ "type": "color",
1048
+ "value": "#514e4d"
1049
+ },
1050
+ "visited": {
1051
+ "type": "color",
1052
+ "value": "#383635"
1053
+ }
1003
1054
  }
1004
1055
  },
1005
1056
  "helper-text": {
@@ -3644,6 +3695,116 @@
3644
3695
  "value": "#000800",
3645
3696
  "type": "color"
3646
3697
  }
3698
+ },
3699
+ "purple": {
3700
+ "0": {
3701
+ "value": "#faf5ffff",
3702
+ "type": "color"
3703
+ },
3704
+ "3": {
3705
+ "value": "#f1e0ffff",
3706
+ "type": "color"
3707
+ },
3708
+ "7": {
3709
+ "value": "#e8ccffff",
3710
+ "type": "color"
3711
+ },
3712
+ "10": {
3713
+ "value": "#dfb8ffff",
3714
+ "type": "color"
3715
+ },
3716
+ "15": {
3717
+ "value": "#d5a3ffff",
3718
+ "type": "color"
3719
+ },
3720
+ "20": {
3721
+ "value": "#cc8fffff",
3722
+ "type": "color"
3723
+ },
3724
+ "25": {
3725
+ "value": "#c37affff",
3726
+ "type": "color"
3727
+ },
3728
+ "30": {
3729
+ "value": "#ba66ffff",
3730
+ "type": "color"
3731
+ },
3732
+ "35": {
3733
+ "value": "#b052ffff",
3734
+ "type": "color"
3735
+ },
3736
+ "40": {
3737
+ "value": "#a73dffff",
3738
+ "type": "color"
3739
+ },
3740
+ "45": {
3741
+ "value": "#9e29ffff",
3742
+ "type": "color"
3743
+ },
3744
+ "50": {
3745
+ "value": "#9514ffff",
3746
+ "type": "color"
3747
+ },
3748
+ "55": {
3749
+ "value": "#8c00ffff",
3750
+ "type": "color"
3751
+ },
3752
+ "60": {
3753
+ "value": "#8000ebff",
3754
+ "type": "color"
3755
+ },
3756
+ "65": {
3757
+ "value": "#7500d6ff",
3758
+ "type": "color"
3759
+ },
3760
+ "70": {
3761
+ "value": "#6a00c2ff",
3762
+ "type": "color"
3763
+ },
3764
+ "73": {
3765
+ "value": "#5f00adff",
3766
+ "type": "color"
3767
+ },
3768
+ "75": {
3769
+ "value": "#540099ff",
3770
+ "type": "color"
3771
+ },
3772
+ "78": {
3773
+ "value": "#490085ff",
3774
+ "type": "color"
3775
+ },
3776
+ "80": {
3777
+ "value": "#3d0070ff",
3778
+ "type": "color"
3779
+ },
3780
+ "83": {
3781
+ "value": "#32005cff",
3782
+ "type": "color"
3783
+ },
3784
+ "85": {
3785
+ "value": "#270047ff",
3786
+ "type": "color"
3787
+ },
3788
+ "88": {
3789
+ "value": "#1c0033ff",
3790
+ "type": "color"
3791
+ },
3792
+ "90": {
3793
+ "value": "#11001fff",
3794
+ "type": "color"
3795
+ },
3796
+ "93": {
3797
+ "value": "#06000aff",
3798
+ "type": "color"
3799
+ },
3800
+ "95": {
3801
+ "value": "#050008ff",
3802
+ "type": "color"
3803
+ },
3804
+ "100": {
3805
+ "value": "#050008ff",
3806
+ "type": "color"
3807
+ }
3647
3808
  }
3648
3809
  },
3649
3810
  "breakpoint": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "2.12.7",
3
+ "version": "2.13.0",
4
4
  "main": "build/system/index.js",
5
5
  "scripts": {
6
6
  "build-storybook": "storybook build",
@@ -25,6 +25,7 @@ export interface CardProps {
25
25
  renderHeader?: ( title?: string ) => React.ReactNode;
26
26
  bodyStyles?: ThemeUIStyleObject;
27
27
  headerStyles?: ThemeUIStyleObject;
28
+ hideBody?: boolean;
28
29
  }
29
30
 
30
31
  type CardBoxProps = CardProps & BoxProps;
@@ -38,6 +39,7 @@ export const Card = forwardRef< HTMLElement, CardBoxProps >(
38
39
  bodyStyles,
39
40
  headerStyles,
40
41
  children,
42
+ hideBody = false,
41
43
  ...rest
42
44
  }: CardProps,
43
45
  ref: Ref< HTMLElement >
@@ -64,15 +66,17 @@ export const Card = forwardRef< HTMLElement, CardBoxProps >(
64
66
  </Box>
65
67
  ) }
66
68
 
67
- <Box
68
- className="vip-card-body-component"
69
- sx={ {
70
- variant: `cards.${ variant }.children`,
71
- ...bodyStyles,
72
- } }
73
- >
74
- { children }
75
- </Box>
69
+ { ! hideBody && (
70
+ <Box
71
+ className="vip-card-body-component"
72
+ sx={ {
73
+ variant: `cards.${ variant }.children`,
74
+ ...bodyStyles,
75
+ } }
76
+ >
77
+ { children }
78
+ </Box>
79
+ ) }
76
80
  </Box>
77
81
  );
78
82
  }
@@ -189,19 +189,6 @@ export const Menu: Story = {
189
189
  </NavItem.Menu>
190
190
  </NavItem.MenuGroup>
191
191
 
192
- <NavItem.MenuGroup
193
- label="Clickable Parent Navigation Item"
194
- renderIcon={ size => <BiHistory size={ size } /> }
195
- parentHref="https://random-website.com/"
196
- >
197
- <NavItem.Menu as={ CustomLink } href="https://google.com/">
198
- Test
199
- </NavItem.Menu>
200
- <NavItem.Menu as={ CustomLink } href="https://wpvip.com/">
201
- Item
202
- </NavItem.Menu>
203
- </NavItem.MenuGroup>
204
-
205
192
  <NavItem.MenuGroup
206
193
  label="Performance"
207
194
  renderIcon={ size => <BiTachometer size={ size } /> }
@@ -19,7 +19,6 @@ export interface NavItemGroupProps extends NavItemBaseProps {
19
19
  renderIcon?: NavItemRenderIconProp;
20
20
  activeChildren?: boolean;
21
21
  label: string;
22
- parentHref?: string;
23
22
  }
24
23
 
25
24
  const NavItemGroupBase = forwardRef< HTMLLIElement, NavItemGroupProps >(
@@ -34,7 +33,6 @@ const NavItemGroupBase = forwardRef< HTMLLIElement, NavItemGroupProps >(
34
33
  renderIcon,
35
34
  children,
36
35
  sx,
37
- parentHref,
38
36
  }: NavItemGroupProps,
39
37
  ref: Ref< HTMLLIElement >
40
38
  ) => {
@@ -53,10 +51,9 @@ const NavItemGroupBase = forwardRef< HTMLLIElement, NavItemGroupProps >(
53
51
  >
54
52
  <Collapsible.Root defaultOpen={ active } open={ isExpanded } onOpenChange={ handleExpand }>
55
53
  <Collapsible.Trigger asChild>
56
- <div
57
- role="button"
58
- tabIndex={ 0 }
59
- aria-haspopup="true"
54
+ <button
55
+ type="button"
56
+ aria-haspopup={ true }
60
57
  data-active={ active || undefined }
61
58
  data-open={ isExpanded || undefined }
62
59
  data-active-children={ activeChildren || undefined }
@@ -68,22 +65,7 @@ const NavItemGroupBase = forwardRef< HTMLLIElement, NavItemGroupProps >(
68
65
  { renderIcon ? (
69
66
  <IconContainer>{ renderIcon( NAV_ITEM_ICON_SIZE ) }</IconContainer>
70
67
  ) : null }
71
-
72
- { parentHref ? (
73
- <a
74
- href={ parentHref }
75
- sx={ {
76
- textDecoration: 'none',
77
- color: 'inherit',
78
- '&:hover': { textDecoration: 'none' },
79
- } }
80
- onClick={ e => e.stopPropagation() }
81
- >
82
- { label }
83
- </a>
84
- ) : (
85
- label
86
- ) }
68
+ { label }
87
69
 
88
70
  <BiChevronDown
89
71
  data-arrow-indicator
@@ -91,9 +73,8 @@ const NavItemGroupBase = forwardRef< HTMLLIElement, NavItemGroupProps >(
91
73
  size={ NAV_ITEM_ICON_SIZE }
92
74
  sx={ { color: 'icon.secondary' } }
93
75
  />
94
- </div>
76
+ </button>
95
77
  </Collapsible.Trigger>
96
-
97
78
  <Collapsible.Content sx={ navItemGroupContentStyles }>
98
79
  <ul sx={ navItemGroupContentUlStyles }>{ children }</ul>
99
80
  </Collapsible.Content>
@@ -95,7 +95,18 @@ export const Default = () => (
95
95
  <Link href="/?path=/story/avatar--default">A link to Avatar</Link>
96
96
  </Notice>
97
97
 
98
- <Notice variant="info" sx={ { mb: 4 } }>
98
+ <Notice variant="success" sx={ { mb: 4 } } title="Collapsible Notice" collapsible>
99
+ Bucket names in Amazon S3 are globally unique.{ ' ' }
100
+ <Link href="/?path=/story/avatar--default">A link to Avatar</Link>
101
+ </Notice>
102
+
103
+ <Notice
104
+ variant="info"
105
+ sx={ { mb: 4 } }
106
+ title="Collapsible Notice Auto-Expanded"
107
+ collapsible
108
+ defaultOpen
109
+ >
99
110
  Bucket names in Amazon S3 are globally unique.
100
111
  </Notice>
101
112
  </React.Fragment>
@@ -3,20 +3,25 @@
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
+ import * as Collapsible from '@radix-ui/react-collapsible';
6
7
  import classNames from 'classnames';
7
- import React from 'react';
8
+ import React, { useState, useId } from 'react';
9
+ import { BiChevronDown, BiChevronUp } from 'react-icons/bi';
8
10
  import { MdError, MdWarning, MdCheckCircle, MdInfo } from 'react-icons/md';
9
11
  import { ThemeUIStyleObject } from 'theme-ui';
10
12
 
11
13
  /**
12
14
  * Internal dependencies
13
15
  */
14
- import { Box, Flex, Heading, Card } from '../';
16
+ import { Box, Flex, Heading, Card, Button } from '../';
15
17
 
16
- interface NoticeIconProps {
17
- color: string;
18
- variant: ColorVariants;
19
- }
18
+ type ColorVariants = 'warning' | 'error' | 'alert' | 'success' | 'info';
19
+
20
+ type CollapsibleProps = {
21
+ collapsible?: boolean;
22
+ defaultOpen?: boolean;
23
+ ariaContentId?: string;
24
+ };
20
25
 
21
26
  export type NoticeProps = React.HTMLAttributes< HTMLDivElement > & {
22
27
  children: React.ReactNode;
@@ -26,10 +31,9 @@ export type NoticeProps = React.HTMLAttributes< HTMLDivElement > & {
26
31
  variant?: ColorVariants;
27
32
  headingVariant?: React.ElementType;
28
33
  className?: string;
29
- };
30
- type ColorVariants = 'warning' | 'error' | 'alert' | 'success' | 'info';
34
+ } & CollapsibleProps;
31
35
 
32
- const NoticeIcon = ( { color, variant }: NoticeIconProps ) => {
36
+ const NoticeIcon = ( { color, variant }: { color: string; variant: ColorVariants } ) => {
33
37
  const sx = { color, flex: '0 0 auto' };
34
38
  const size = 24;
35
39
 
@@ -56,40 +60,147 @@ export const Notice = React.forwardRef< HTMLDivElement, NoticeProps >(
56
60
  sx = {},
57
61
  title,
58
62
  variant = 'warning',
63
+ collapsible = false,
64
+ defaultOpen = false,
59
65
  ...props
60
66
  },
61
67
  forwardRef
62
68
  ) => {
69
+ const [ isExpanded, setIsExpanded ] = useState( defaultOpen );
70
+ const handleExpand = ( openValue: boolean ) => setIsExpanded( openValue );
71
+ const ChevronIcon = isExpanded ? BiChevronUp : BiChevronDown;
72
+ const contentId = useId();
73
+
74
+ const iconColor = `notice.icon.${ variant }`;
75
+ const textColor = `notice.text.${ variant }`;
76
+
77
+ const baseCardSx: ThemeUIStyleObject = {
78
+ boxShadow: 'none',
79
+ borderRadius: 2,
80
+ bg: inline || collapsible ? 'transparent' : `notice.background.${ variant }`,
81
+ color: textColor,
82
+ fontSize: 2,
83
+ p: {
84
+ color: textColor,
85
+ fontSize: 2,
86
+ },
87
+ a: {
88
+ color: `notice.link.${ variant }.default`,
89
+ '&:visited': {
90
+ color: `notice.link.${ variant }.visited`,
91
+ },
92
+ '&:active': {
93
+ color: `notice.link.${ variant }.active`,
94
+ },
95
+ '&:hover, &:focus': {
96
+ color: `notice.link.${ variant }.hover`,
97
+ },
98
+ },
99
+ ul: {
100
+ pl: 5,
101
+ },
102
+ ...sx,
103
+ };
104
+
105
+ if ( collapsible ) {
106
+ const renderHeader = () => (
107
+ <Collapsible.Trigger asChild aria-expanded={ isExpanded } aria-controls={ contentId }>
108
+ <Button
109
+ variant="text"
110
+ sx={ {
111
+ border: 'none',
112
+ width: '100%',
113
+ display: 'flex',
114
+ alignItems: 'center',
115
+ justifyContent: 'space-between',
116
+ cursor: 'pointer',
117
+ bg: `notice.background.${ variant }`,
118
+ '&:hover, &:focus': {
119
+ bg: `notice.background.${ variant }`,
120
+ boxShadow: 'none',
121
+ transform: 'none',
122
+ border: 'none',
123
+ },
124
+ px: 3,
125
+ py: 2,
126
+ borderBottomLeftRadius: '0 !important',
127
+ borderBottomRightRadius: '0 !important',
128
+ } }
129
+ >
130
+ <Flex sx={ { alignItems: 'center', gap: 2 } }>
131
+ <NoticeIcon color={ iconColor } variant={ variant } />
132
+ <Heading
133
+ as={ headingVariant }
134
+ id={ `${ contentId }-heading` }
135
+ sx={ {
136
+ color: textColor,
137
+ fontSize: 2,
138
+ fontWeight: 'bold',
139
+ my: 2,
140
+ mx: 3,
141
+ } }
142
+ >
143
+ { title }
144
+ </Heading>
145
+ </Flex>
146
+ <ChevronIcon
147
+ size={ 32 }
148
+ sx={ {
149
+ color: 'icon.primary',
150
+ } }
151
+ data-arrow-indicator
152
+ aria-hidden="true"
153
+ />
154
+ </Button>
155
+ </Collapsible.Trigger>
156
+ );
157
+
158
+ return (
159
+ <Collapsible.Root
160
+ defaultOpen={ defaultOpen }
161
+ onOpenChange={ handleExpand }
162
+ data-active={ defaultOpen || undefined }
163
+ >
164
+ <Card
165
+ variant="notice"
166
+ hideBody={ ! isExpanded }
167
+ renderHeader={ renderHeader }
168
+ bodyStyles={ {
169
+ border: '2px solid',
170
+ borderColor: `notice.background.${ variant }`,
171
+ borderTop: 'none',
172
+ borderBottomLeftRadius: 2,
173
+ borderBottomRightRadius: 2,
174
+ px: 4,
175
+ py: 3,
176
+ } }
177
+ sx={ {
178
+ ...baseCardSx,
179
+ border: 'none',
180
+ overflow: 'hidden',
181
+ } }
182
+ className={ classNames( 'vip-notice-component', className ) }
183
+ { ...props }
184
+ ref={ forwardRef }
185
+ >
186
+ <Collapsible.Content
187
+ id={ contentId }
188
+ sx={ {
189
+ mx: 2,
190
+ my: 2,
191
+ } }
192
+ >
193
+ { children }
194
+ </Collapsible.Content>
195
+ </Card>
196
+ </Collapsible.Root>
197
+ );
198
+ }
199
+
63
200
  return (
64
201
  <Card
65
202
  variant="notice"
66
- sx={ {
67
- boxShadow: 'none',
68
- borderRadius: 2,
69
- bg: inline ? 'transparent' : `notice.background.${ variant }`,
70
- color: `notice.text.${ variant }`,
71
- fontSize: 2,
72
- p: {
73
- color: `notice.text.${ variant }`,
74
- fontSize: 2,
75
- },
76
- a: {
77
- color: `notice.link.${ variant }.default`,
78
- '&:visited': {
79
- color: `notice.link.${ variant }.visited`,
80
- },
81
- '&:active': {
82
- color: `notice.link.${ variant }.active`,
83
- },
84
- '&:hover, &:focus': {
85
- color: `notice.link.${ variant }.hover`,
86
- },
87
- },
88
- ul: {
89
- pl: 5,
90
- },
91
- ...sx,
92
- } }
203
+ sx={ baseCardSx }
93
204
  className={ classNames( 'vip-notice-component', className ) }
94
205
  ref={ forwardRef }
95
206
  { ...props }
@@ -108,8 +219,8 @@ export const Notice = React.forwardRef< HTMLDivElement, NoticeProps >(
108
219
  sx={ {
109
220
  flex: '1 100%', // we need this empty div to make the icon align to the bottom
110
221
  } }
111
- ></Box>
112
- <NoticeIcon color={ `notice.icon.${ variant }` } variant={ variant } />
222
+ />
223
+ <NoticeIcon color={ iconColor } variant={ variant } />
113
224
  </Flex>
114
225
  </Box>
115
226
  <Box>
@@ -117,7 +228,7 @@ export const Notice = React.forwardRef< HTMLDivElement, NoticeProps >(
117
228
  <Heading
118
229
  as={ headingVariant }
119
230
  sx={ {
120
- color: `notice.text.${ variant }`,
231
+ color: textColor,
121
232
  mb: 0,
122
233
  fontSize: 2,
123
234
  fontWeight: 'bold',