@automattic/vip-design-system 2.4.0 → 2.4.1

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.
@@ -24,7 +24,7 @@ var NavBase = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
24
24
  "aria-label": label,
25
25
  ref: ref,
26
26
  className: (0, _classnames["default"])(VIP_NAV, className),
27
- sx: (0, _styles.navStyles)(variant),
27
+ sx: (0, _styles.navStyles)(variant, orientation),
28
28
  orientation: orientation,
29
29
  children: (0, _jsxRuntime.jsx)(NavigationMenu.List, {
30
30
  className: (0, _classnames["default"])(VIP_NAV + "-list"),
@@ -68,22 +68,34 @@ var Tab = exports.Tab = {
68
68
  },
69
69
  label: "Nav Tab",
70
70
  children: [(0, _jsxRuntime.jsx)(_NavItem.NavItem.Tab, {
71
- active: true,
72
71
  as: _CustomLink.CustomLink,
73
- href: "https://random-website.com/",
72
+ href: "#!",
74
73
  children: "PHP"
75
74
  }), (0, _jsxRuntime.jsx)(_NavItem.NavItem.Tab, {
76
75
  as: _CustomLink.CustomLink,
77
- href: "https://wordpress.com",
76
+ href: "#2!",
78
77
  children: "WordPress"
79
78
  }), (0, _jsxRuntime.jsx)(_NavItem.NavItem.Tab, {
79
+ active: true,
80
80
  as: _CustomLink.CustomLink,
81
- href: "https://newrelic.com/",
81
+ href: "#3!",
82
82
  children: "New Relic"
83
+ }), (0, _jsxRuntime.jsx)(_NavItem.NavItem.Tab, {
84
+ as: _CustomLink.CustomLink,
85
+ href: "#4!",
86
+ children: "Datadog"
87
+ }), (0, _jsxRuntime.jsx)(_NavItem.NavItem.Tab, {
88
+ as: _CustomLink.CustomLink,
89
+ href: "#4!",
90
+ children: "OnePlus"
91
+ }), (0, _jsxRuntime.jsx)(_NavItem.NavItem.Tab, {
92
+ as: _CustomLink.CustomLink,
93
+ href: "#5!",
94
+ children: "Rollbar"
83
95
  }), (0, _jsxRuntime.jsx)(_NavItem.NavItem.Tab, {
84
96
  disabled: true,
85
97
  as: _CustomLink.CustomLink,
86
- href: "https://google.com/",
98
+ href: "#6!",
87
99
  children: "Not accessible"
88
100
  })]
89
101
  })]
@@ -4,6 +4,7 @@ type MixedStyleProp = {
4
4
  [key: string]: string | number | MixedStyleProp | ThemeUIStyleObject;
5
5
  };
6
6
  export declare const menuItemStyles: (orientation: NavProps['orientation']) => ThemeUIStyleObject;
7
+ export declare const tabItemStyles: (orientation: NavProps['orientation']) => ThemeUIStyleObject;
7
8
  export declare const menuInverseItemStyles: (orientation: NavProps['orientation']) => ThemeUIStyleObject;
8
9
  export declare const menuItemLinkStyles: MixedStyleProp;
9
10
  export declare const menuInverseItemLinkStyles: {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.menuItemStyles = exports.menuItemLinkStyles = exports.menuInverseItemStyles = exports.menuInverseItemLinkStyles = void 0;
4
+ exports.tabItemStyles = exports.menuItemStyles = exports.menuItemLinkStyles = exports.menuInverseItemStyles = exports.menuInverseItemLinkStyles = void 0;
5
5
  var _primary = require("./primary");
6
6
  var _menuItemLinkStyles, _extends2;
7
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); }
@@ -16,6 +16,13 @@ var menuItemStyles = exports.menuItemStyles = function menuItemStyles(orientatio
16
16
  });
17
17
  };
18
18
 
19
+ // Tab Item Style <li>
20
+ var tabItemStyles = exports.tabItemStyles = function tabItemStyles(orientation) {
21
+ return _extends({}, (0, _primary.defaultNavItemStyles)(orientation), {
22
+ mr: 0
23
+ });
24
+ };
25
+
19
26
  // Menu Inverse Item Style <li>
20
27
  var menuInverseItemStyles = exports.menuInverseItemStyles = function menuInverseItemStyles(orientation) {
21
28
  return _extends({}, menuItemStyles(orientation), {
@@ -1,3 +1,4 @@
1
1
  import { ThemeUIStyleObject } from 'theme-ui';
2
- export declare const tabRootStyles: ThemeUIStyleObject;
2
+ import { NavProps } from '../../Nav';
3
+ export declare const tabRootStyles: (orientation: NavProps['orientation']) => ThemeUIStyleObject;
3
4
  export declare const tabItemLinkStyles: ThemeUIStyleObject;
@@ -5,27 +5,61 @@ exports.tabRootStyles = exports.tabItemLinkStyles = void 0;
5
5
  var _primary = require("./primary");
6
6
  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); }
7
7
  // Tab Root Styles <nav>
8
-
9
- var tabRootStyles = exports.tabRootStyles = {
10
- width: '100%',
11
- borderColor: 'borders.2'
8
+ var getTabPropsByOrientation = function getTabPropsByOrientation(orientation) {
9
+ if (orientation === 'vertical') {
10
+ return {
11
+ '> div:first-of-type': {
12
+ height: '100%',
13
+ overflowY: 'auto'
14
+ },
15
+ ul: {
16
+ minHeight: 'max-content'
17
+ }
18
+ };
19
+ }
20
+ return {
21
+ '> div:first-of-type': {
22
+ width: '100%',
23
+ overflowX: 'auto'
24
+ },
25
+ ul: {
26
+ minWidth: 'max-content'
27
+ }
28
+ };
29
+ };
30
+ var tabRootStyles = exports.tabRootStyles = function tabRootStyles(orientation) {
31
+ return _extends({
32
+ width: '100%',
33
+ borderColor: 'borders.2',
34
+ gap: 2
35
+ }, getTabPropsByOrientation(orientation));
12
36
  };
13
37
 
14
38
  // Tab Link <a>
15
39
  var tabItemLinkStyles = exports.tabItemLinkStyles = _extends({}, _primary.defaultItemLinkStyles, {
16
- px: 0,
17
- mr: 2,
40
+ px: 2,
41
+ height: '100%',
42
+ backgroundColor: 'red',
18
43
  color: 'heading',
19
44
  '&[data-active]': {
20
45
  color: 'link',
21
46
  fontWeight: 'normal',
22
- boxShadow: 'inset 0 -1px 0 0, 0 1px 0 0'
47
+ position: 'relative',
48
+ '&::after': {
49
+ position: 'absolute',
50
+ bottom: 0,
51
+ display: 'block',
52
+ width: '100%',
53
+ content: '""',
54
+ height: '0.125rem',
55
+ backgroundColor: 'link'
56
+ }
23
57
  },
24
58
  '&[aria-disabled="true"]': {
25
59
  color: 'muted'
26
60
  },
27
61
  ':hover': {
28
62
  fontWeight: 'regular',
29
- color: 'heading'
63
+ color: 'link'
30
64
  }
31
65
  });
@@ -3,6 +3,5 @@ import { NavProps, NavVariant } from './Nav';
3
3
  export declare const navItemLinkVariantStyles: (variant: NavVariant) => ThemeUIStyleObject;
4
4
  export declare const navItemLinkStyles: (variant: NavVariant) => ThemeUIStyleObject;
5
5
  export declare const navItemStyles: (orientation: NavProps['orientation'], variant?: NavVariant) => ThemeUIStyleObject;
6
- export declare const navRootStyles: (variant: NavVariant) => ThemeUIStyleObject;
7
- export declare const navStyles: (variant: NavVariant) => ThemeUIStyleObject;
6
+ export declare const navStyles: (variant: NavVariant, orientation: NavProps['orientation']) => ThemeUIStyleObject;
8
7
  export declare const navMenuListStyles: (orientation: NavProps['orientation']) => ThemeUIStyleObject;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.navStyles = exports.navRootStyles = exports.navMenuListStyles = exports.navItemStyles = exports.navItemLinkVariantStyles = exports.navItemLinkStyles = void 0;
4
+ exports.navStyles = exports.navMenuListStyles = exports.navItemStyles = exports.navItemLinkVariantStyles = exports.navItemLinkStyles = void 0;
5
5
  var _breadcrumbs = require("./styles/variants/breadcrumbs");
6
6
  var _menu = require("./styles/variants/menu");
7
7
  var _primary = require("./styles/variants/primary");
@@ -57,6 +57,10 @@ var navItemStyles = exports.navItemStyles = function navItemStyles(orientation,
57
57
  {
58
58
  return (0, _menu.menuItemStyles)(orientation);
59
59
  }
60
+ case 'tabs':
61
+ {
62
+ return (0, _menu.tabItemStyles)(orientation);
63
+ }
60
64
  case 'menu-inverse':
61
65
  {
62
66
  return (0, _menu.menuInverseItemStyles)(orientation);
@@ -71,28 +75,12 @@ var navItemStyles = exports.navItemStyles = function navItemStyles(orientation,
71
75
  }
72
76
  }
73
77
  };
74
- var navRootStyles = exports.navRootStyles = function navRootStyles(variant) {
75
- switch (variant) {
76
- case 'tabs':
77
- {
78
- return _tabs.tabRootStyles;
79
- }
80
- case 'toolbar':
81
- {
82
- return _toolbar.toolbarRootStyles;
83
- }
84
- default:
85
- {
86
- return _primary.defaultNavRootStyles;
87
- }
88
- }
89
- };
90
- var navStyles = exports.navStyles = function navStyles(variant) {
78
+ var navStyles = exports.navStyles = function navStyles(variant, orientation) {
91
79
  var navStyle = {};
92
80
  switch (variant) {
93
81
  case 'tabs':
94
82
  {
95
- navStyle = _tabs.tabRootStyles;
83
+ navStyle = (0, _tabs.tabRootStyles)(orientation);
96
84
  }
97
85
  break;
98
86
  case 'toolbar':
@@ -38,6 +38,7 @@ export const Default = () => (
38
38
  </TabsContent>
39
39
  </Tabs>
40
40
  );
41
+
41
42
  export const SetActiveTab = () => {
42
43
  const [ activeTab, setActiveTab ] = React.useState( 'all' );
43
44
 
@@ -24,7 +24,16 @@ const styles = {
24
24
  '&[data-state="active"]': {
25
25
  color: 'link',
26
26
  fontWeight: 'regular',
27
- boxShadow: 'inset 0 -1px 0 0, 0 1px 0 0',
27
+ position: 'relative',
28
+ '&::after': {
29
+ position: 'absolute',
30
+ bottom: 0,
31
+ display: 'block',
32
+ width: '100%',
33
+ content: '""',
34
+ height: '0.125rem',
35
+ backgroundColor: 'link',
36
+ },
28
37
  },
29
38
  '&:disabled': {
30
39
  color: 'muted',
@@ -326,6 +326,7 @@ declare namespace _default {
326
326
  '&:hover': {
327
327
  textDecorationLine: string;
328
328
  textDecorationThickness: string;
329
+ textUnderlineOffset: string;
329
330
  };
330
331
  };
331
332
  export namespace svg {
@@ -536,7 +536,8 @@ export default {
536
536
  a: {
537
537
  '&:hover': {
538
538
  textDecorationLine: 'underline',
539
- textDecorationThickness: '2px',
539
+ textDecorationThickness: '0.125rem',
540
+ textUnderlineOffset: '0.250rem',
540
541
  },
541
542
  },
542
543
  svg: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "main": "build/system/index.js",
5
5
  "scripts": {
6
6
  "build-storybook": "storybook build",
@@ -115,16 +115,25 @@ export const Tab: Story = {
115
115
  <strong>Variant: Tab</strong>
116
116
  </p>
117
117
  <Nav.Tab sx={ { mb: 4 } } label="Nav Tab">
118
- <NavItem.Tab active as={ CustomLink } href="https://random-website.com/">
118
+ <NavItem.Tab as={ CustomLink } href="#!">
119
119
  PHP
120
120
  </NavItem.Tab>
121
- <NavItem.Tab as={ CustomLink } href="https://wordpress.com">
121
+ <NavItem.Tab as={ CustomLink } href="#2!">
122
122
  WordPress
123
123
  </NavItem.Tab>
124
- <NavItem.Tab as={ CustomLink } href="https://newrelic.com/">
124
+ <NavItem.Tab active as={ CustomLink } href="#3!">
125
125
  New Relic
126
126
  </NavItem.Tab>
127
- <NavItem.Tab disabled as={ CustomLink } href="https://google.com/">
127
+ <NavItem.Tab as={ CustomLink } href="#4!">
128
+ Datadog
129
+ </NavItem.Tab>
130
+ <NavItem.Tab as={ CustomLink } href="#4!">
131
+ OnePlus
132
+ </NavItem.Tab>
133
+ <NavItem.Tab as={ CustomLink } href="#5!">
134
+ Rollbar
135
+ </NavItem.Tab>
136
+ <NavItem.Tab disabled as={ CustomLink } href="#6!">
128
137
  Not accessible
129
138
  </NavItem.Tab>
130
139
  </Nav.Tab>
@@ -24,7 +24,7 @@ const NavBase = forwardRef< HTMLElement, NavProps >(
24
24
  aria-label={ label }
25
25
  ref={ ref }
26
26
  className={ classNames( VIP_NAV, className ) }
27
- sx={ navStyles( variant ) }
27
+ sx={ navStyles( variant, orientation ) }
28
28
  orientation={ orientation }
29
29
  >
30
30
  <NavigationMenu.List
@@ -17,6 +17,12 @@ export const menuItemStyles = ( orientation: NavProps[ 'orientation' ] ): ThemeU
17
17
  justifyContent: 'space-between',
18
18
  } );
19
19
 
20
+ // Tab Item Style <li>
21
+ export const tabItemStyles = ( orientation: NavProps[ 'orientation' ] ): ThemeUIStyleObject => ( {
22
+ ...defaultNavItemStyles( orientation ),
23
+ mr: 0,
24
+ } );
25
+
20
26
  // Menu Inverse Item Style <li>
21
27
  export const menuInverseItemStyles = (
22
28
  orientation: NavProps[ 'orientation' ]
@@ -1,27 +1,64 @@
1
1
  import { ThemeUIStyleObject } from 'theme-ui';
2
2
 
3
3
  import { defaultItemLinkStyles } from './primary';
4
+ import { NavProps } from '../../Nav';
4
5
 
5
6
  // Tab Root Styles <nav>
7
+ const getTabPropsByOrientation = ( orientation: NavProps[ 'orientation' ] ): ThemeUIStyleObject => {
8
+ if ( orientation === 'vertical' ) {
9
+ return {
10
+ '> div:first-of-type': {
11
+ height: '100%',
12
+ overflowY: 'auto',
13
+ },
14
+ ul: {
15
+ minHeight: 'max-content',
16
+ },
17
+ };
18
+ }
19
+ return {
20
+ '> div:first-of-type': {
21
+ width: '100%',
22
+ overflowX: 'auto',
23
+ },
24
+ ul: {
25
+ minWidth: 'max-content',
26
+ },
27
+ };
28
+ };
6
29
 
7
- export const tabRootStyles: ThemeUIStyleObject = {
30
+ export const tabRootStyles = ( orientation: NavProps[ 'orientation' ] ): ThemeUIStyleObject => ( {
8
31
  width: '100%',
9
32
  borderColor: 'borders.2',
10
- };
33
+ gap: 2,
34
+
35
+ // Responsive in case the content is bigger than the viewport
36
+ ...getTabPropsByOrientation( orientation ),
37
+ } );
11
38
 
12
39
  // Tab Link <a>
13
40
  export const tabItemLinkStyles: ThemeUIStyleObject = {
14
41
  ...defaultItemLinkStyles,
15
- px: 0,
16
- mr: 2,
42
+ px: 2,
43
+ height: '100%',
44
+ backgroundColor: 'red',
17
45
  color: 'heading',
18
46
  '&[data-active]': {
19
47
  color: 'link',
20
48
  fontWeight: 'normal',
21
- boxShadow: 'inset 0 -1px 0 0, 0 1px 0 0',
49
+ position: 'relative',
50
+ '&::after': {
51
+ position: 'absolute',
52
+ bottom: 0,
53
+ display: 'block',
54
+ width: '100%',
55
+ content: '""',
56
+ height: '0.125rem',
57
+ backgroundColor: 'link',
58
+ },
22
59
  },
23
60
  '&[aria-disabled="true"]': {
24
61
  color: 'muted',
25
62
  },
26
- ':hover': { fontWeight: 'regular', color: 'heading' },
63
+ ':hover': { fontWeight: 'regular', color: 'link' },
27
64
  };
@@ -8,6 +8,7 @@ import {
8
8
  menuInverseItemStyles,
9
9
  menuItemLinkStyles,
10
10
  menuItemStyles,
11
+ tabItemStyles,
11
12
  } from './styles/variants/menu';
12
13
  import {
13
14
  defaultNavItemStyles,
@@ -68,6 +69,9 @@ export const navItemStyles = (
68
69
  case 'menu': {
69
70
  return menuItemStyles( orientation );
70
71
  }
72
+ case 'tabs': {
73
+ return tabItemStyles( orientation );
74
+ }
71
75
  case 'menu-inverse': {
72
76
  return menuInverseItemStyles( orientation );
73
77
  }
@@ -82,29 +86,16 @@ export const navItemStyles = (
82
86
  }
83
87
  };
84
88
 
85
- export const navRootStyles = ( variant: NavVariant ): ThemeUIStyleObject => {
86
- switch ( variant ) {
87
- case 'tabs': {
88
- return tabRootStyles;
89
- }
90
-
91
- case 'toolbar': {
92
- return toolbarRootStyles;
93
- }
94
-
95
- default: {
96
- return defaultNavRootStyles;
97
- }
98
- }
99
- };
100
-
101
- export const navStyles = ( variant: NavVariant ): ThemeUIStyleObject => {
89
+ export const navStyles = (
90
+ variant: NavVariant,
91
+ orientation: NavProps[ 'orientation' ]
92
+ ): ThemeUIStyleObject => {
102
93
  let navStyle: ThemeUIStyleObject = {};
103
94
 
104
95
  switch ( variant ) {
105
96
  case 'tabs':
106
97
  {
107
- navStyle = tabRootStyles;
98
+ navStyle = tabRootStyles( orientation );
108
99
  }
109
100
 
110
101
  break;
@@ -38,6 +38,7 @@ export const Default = () => (
38
38
  </TabsContent>
39
39
  </Tabs>
40
40
  );
41
+
41
42
  export const SetActiveTab = () => {
42
43
  const [ activeTab, setActiveTab ] = React.useState( 'all' );
43
44
 
@@ -24,7 +24,16 @@ const styles = {
24
24
  '&[data-state="active"]': {
25
25
  color: 'link',
26
26
  fontWeight: 'regular',
27
- boxShadow: 'inset 0 -1px 0 0, 0 1px 0 0',
27
+ position: 'relative',
28
+ '&::after': {
29
+ position: 'absolute',
30
+ bottom: 0,
31
+ display: 'block',
32
+ width: '100%',
33
+ content: '""',
34
+ height: '0.125rem',
35
+ backgroundColor: 'link',
36
+ },
28
37
  },
29
38
  '&:disabled': {
30
39
  color: 'muted',
@@ -536,7 +536,8 @@ export default {
536
536
  a: {
537
537
  '&:hover': {
538
538
  textDecorationLine: 'underline',
539
- textDecorationThickness: '2px',
539
+ textDecorationThickness: '0.125rem',
540
+ textUnderlineOffset: '0.250rem',
540
541
  },
541
542
  },
542
543
  svg: {