@automattic/vip-design-system 2.3.0 → 2.4.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.
- package/build/system/Button/Button.js +2 -2
- package/build/system/Nav/Nav.stories.js +1 -0
- package/build/system/Nav/NavItemGroup.d.ts +1 -0
- package/build/system/Nav/NavItemGroup.js +2 -0
- package/build/system/Nav/NavItemGroup.test.d.ts +2 -0
- package/build/system/Nav/NavItemGroup.test.js +73 -0
- package/build/system/Nav/styles/variants/menu.d.ts +2 -2
- package/build/system/Nav/styles/variants/menu.js +4 -4
- package/build/system/NewDialog/DialogClose.js +6 -3
- package/build/system/theme/index.d.ts +7 -2
- package/build/system/theme/index.js +10 -3
- package/package.json +1 -1
- package/src/system/Button/Button.tsx +2 -2
- package/src/system/Nav/Nav.stories.tsx +6 -1
- package/src/system/Nav/NavItemGroup.test.tsx +50 -0
- package/src/system/Nav/NavItemGroup.tsx +3 -0
- package/src/system/Nav/styles/variants/menu.ts +4 -4
- package/src/system/NewDialog/DialogClose.tsx +4 -3
- package/src/system/theme/index.js +10 -3
|
@@ -52,8 +52,8 @@ var Button = exports.Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
52
52
|
cursor: 'not-allowed',
|
|
53
53
|
pointerEvents: 'none'
|
|
54
54
|
},
|
|
55
|
-
flexGrow: Boolean(grow) === true ? '1' :
|
|
56
|
-
width: Boolean(full) === true ? '100%' :
|
|
55
|
+
flexGrow: Boolean(grow) === true ? '1' : undefined,
|
|
56
|
+
width: Boolean(full) === true ? '100%' : undefined
|
|
57
57
|
}, sx)
|
|
58
58
|
}, rest, {
|
|
59
59
|
"aria-disabled": disabled,
|
|
@@ -131,6 +131,7 @@ var Menu = exports.Menu = {
|
|
|
131
131
|
children: "Domains & TLS"
|
|
132
132
|
}), (0, _jsxRuntime.jsxs)(_NavItem.NavItem.MenuGroup, {
|
|
133
133
|
active: true,
|
|
134
|
+
activeChildren: true,
|
|
134
135
|
label: "Logs",
|
|
135
136
|
renderIcon: function renderIcon(size) {
|
|
136
137
|
return (0, _jsxRuntime.jsx)(_bi.BiHistory, {
|
|
@@ -3,6 +3,7 @@ import { NavItemRenderIconProp } from './Nav';
|
|
|
3
3
|
import { NavItemBaseProps } from './NavItem';
|
|
4
4
|
export interface NavItemGroupProps extends NavItemBaseProps {
|
|
5
5
|
renderIcon?: NavItemRenderIconProp;
|
|
6
|
+
activeChildren?: boolean;
|
|
6
7
|
label: string;
|
|
7
8
|
}
|
|
8
9
|
export declare const IconContainer: ({ children }: {
|
|
@@ -23,6 +23,7 @@ var NavItemGroupBase = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
|
|
|
23
23
|
orientation = _ref.orientation,
|
|
24
24
|
className = _ref.className,
|
|
25
25
|
active = _ref.active,
|
|
26
|
+
activeChildren = _ref.activeChildren,
|
|
26
27
|
renderIcon = _ref.renderIcon,
|
|
27
28
|
children = _ref.children,
|
|
28
29
|
sx = _ref.sx;
|
|
@@ -47,6 +48,7 @@ var NavItemGroupBase = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
|
|
|
47
48
|
"aria-haspopup": true,
|
|
48
49
|
"data-active": active || undefined,
|
|
49
50
|
"data-open": isExpanded || undefined,
|
|
51
|
+
"data-active-children": activeChildren || undefined,
|
|
50
52
|
sx: _extends({}, (0, _styles.navItemLinkVariantStyles)(variant), _menugroup.navItemGroupTriggerStyles),
|
|
51
53
|
children: [renderIcon ? (0, _jsxRuntime.jsx)(IconContainer, {
|
|
52
54
|
children: renderIcon(_NavItem.NAV_ITEM_ICON_SIZE)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
var _jestAxe = require("jest-axe");
|
|
5
|
+
var _themeUi = require("theme-ui");
|
|
6
|
+
var _Nav = require("./Nav");
|
|
7
|
+
var _NavItem = require("./NavItem");
|
|
8
|
+
var _ = require("../");
|
|
9
|
+
var _CustomLink = require("../utils/stories/CustomLink");
|
|
10
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
11
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
12
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
13
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /** @jsxImportSource theme-ui */ /* eslint-disable @typescript-eslint/ban-ts-comment */ // @ts-nocheck
|
|
14
|
+
var renderWithTheme = function renderWithTheme(children) {
|
|
15
|
+
return (0, _react.render)((0, _jsxRuntime.jsx)(_themeUi.ThemeUIProvider, {
|
|
16
|
+
theme: _.theme,
|
|
17
|
+
children: children
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
var renderComponent = function renderComponent() {
|
|
21
|
+
return renderWithTheme((0, _jsxRuntime.jsx)(_Nav.Nav.Menu, {
|
|
22
|
+
label: "Nav Menu",
|
|
23
|
+
children: (0, _jsxRuntime.jsxs)(_NavItem.NavItem.MenuGroup, {
|
|
24
|
+
active: true,
|
|
25
|
+
activeChildren: true,
|
|
26
|
+
label: "Logs",
|
|
27
|
+
children: [(0, _jsxRuntime.jsx)(_NavItem.NavItem.Menu, {
|
|
28
|
+
active: true,
|
|
29
|
+
as: _CustomLink.CustomLink,
|
|
30
|
+
href: "https://google.com/",
|
|
31
|
+
children: "Audit"
|
|
32
|
+
}), (0, _jsxRuntime.jsx)(_NavItem.NavItem.Menu, {
|
|
33
|
+
as: _CustomLink.CustomLink,
|
|
34
|
+
href: "https://wpvip.com/",
|
|
35
|
+
children: "Runtime"
|
|
36
|
+
}), (0, _jsxRuntime.jsx)(_NavItem.NavItem.Menu, {
|
|
37
|
+
as: _CustomLink.CustomLink,
|
|
38
|
+
href: "https://dashboard.wpvip.com/",
|
|
39
|
+
children: "Slow Query"
|
|
40
|
+
})]
|
|
41
|
+
})
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
describe('<NavItemGroup />', function () {
|
|
45
|
+
it('renders the NavItemGroup component a data-active-children', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
46
|
+
var _renderComponent, container, button;
|
|
47
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
48
|
+
while (1) switch (_context.prev = _context.next) {
|
|
49
|
+
case 0:
|
|
50
|
+
_renderComponent = renderComponent(), container = _renderComponent.container; // Should find the button label
|
|
51
|
+
button = _react.screen.getByRole('button', {
|
|
52
|
+
label: /Logs/
|
|
53
|
+
});
|
|
54
|
+
expect(button).toBeInTheDocument();
|
|
55
|
+
|
|
56
|
+
// Expect to have another attribute
|
|
57
|
+
expect(button).toHaveAttribute('data-active', 'true');
|
|
58
|
+
expect(button).toHaveAttribute('data-active-children', 'true');
|
|
59
|
+
|
|
60
|
+
// Check for accessibility issues
|
|
61
|
+
_context.t0 = expect;
|
|
62
|
+
_context.next = 8;
|
|
63
|
+
return (0, _jestAxe.axe)(container);
|
|
64
|
+
case 8:
|
|
65
|
+
_context.t1 = _context.sent;
|
|
66
|
+
(0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
67
|
+
case 10:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee);
|
|
72
|
+
})));
|
|
73
|
+
});
|
|
@@ -10,7 +10,7 @@ export declare const menuInverseItemLinkStyles: {
|
|
|
10
10
|
backgroundColor: string;
|
|
11
11
|
color: string;
|
|
12
12
|
"&:visited": {};
|
|
13
|
-
"&[data-active]": {};
|
|
14
|
-
"&:focus:not(&[data-active]), &:hover:not(&[data-active])": {};
|
|
13
|
+
"&[data-active]:not(&[data-active-children=\"true\"][data-state=\"open\"])": {};
|
|
14
|
+
"&:focus:not(&[data-active]:not(&[data-active-children=\"true\"][data-state=\"open\"])), &:hover:not(&[data-active]:not(&[data-active-children=\"true\"][data-state=\"open\"]))": {};
|
|
15
15
|
};
|
|
16
16
|
export {};
|
|
@@ -29,9 +29,9 @@ var menuInverseItemStyles = exports.menuInverseItemStyles = function menuInverse
|
|
|
29
29
|
// Menu Item Link <a>
|
|
30
30
|
|
|
31
31
|
var visitedLink = '&:visited';
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var focusNotActiveHoverNotActive =
|
|
32
|
+
var active = '&[data-active]:not(&[data-active-children="true"][data-state="open"])';
|
|
33
|
+
var activeBefore = active + "::before";
|
|
34
|
+
var focusNotActiveHoverNotActive = "&:focus:not(" + active + "), &:hover:not(" + active + ")";
|
|
35
35
|
var notHover = ':not(&:hover)';
|
|
36
36
|
var svgIcon = 'svg';
|
|
37
37
|
var menuItemLinkStyles = exports.menuItemLinkStyles = (_menuItemLinkStyles = {
|
|
@@ -59,7 +59,7 @@ var menuItemLinkStyles = exports.menuItemLinkStyles = (_menuItemLinkStyles = {
|
|
|
59
59
|
width: '100%'
|
|
60
60
|
}, _menuItemLinkStyles[visitedLink] = {
|
|
61
61
|
color: 'text'
|
|
62
|
-
}, _menuItemLinkStyles[
|
|
62
|
+
}, _menuItemLinkStyles[activeBefore] = {
|
|
63
63
|
position: 'absolute',
|
|
64
64
|
content: "''",
|
|
65
65
|
overflow: 'hidden',
|
|
@@ -27,8 +27,9 @@ var defaultCloseStyles = exports.defaultCloseStyles = function defaultCloseStyle
|
|
|
27
27
|
position: 'absolute',
|
|
28
28
|
top: 3,
|
|
29
29
|
right: 3,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
width: 38,
|
|
31
|
+
height: 38,
|
|
32
|
+
p: 0,
|
|
32
33
|
color: variant === 'primary' ? 'icon.primary' : 'icon.inverse',
|
|
33
34
|
svg: {
|
|
34
35
|
'&:hover': {
|
|
@@ -47,7 +48,9 @@ var DialogCloseDefault = exports.DialogCloseDefault = /*#__PURE__*/(0, _react.fo
|
|
|
47
48
|
variant: "tertiary",
|
|
48
49
|
sx: defaultCloseStyles(variant),
|
|
49
50
|
children: (0, _jsxRuntime.jsx)(_io.IoClose, {
|
|
50
|
-
"aria-hidden": "true"
|
|
51
|
+
"aria-hidden": "true",
|
|
52
|
+
width: 20,
|
|
53
|
+
height: 20
|
|
51
54
|
})
|
|
52
55
|
})
|
|
53
56
|
});
|
|
@@ -67,7 +67,7 @@ declare namespace _default {
|
|
|
67
67
|
py: number;
|
|
68
68
|
px: number;
|
|
69
69
|
minHeight: string;
|
|
70
|
-
|
|
70
|
+
display: string;
|
|
71
71
|
cursor: string;
|
|
72
72
|
fontWeight: string;
|
|
73
73
|
boxShadow: string;
|
|
@@ -77,10 +77,15 @@ declare namespace _default {
|
|
|
77
77
|
color: string;
|
|
78
78
|
};
|
|
79
79
|
verticalAlign: string;
|
|
80
|
-
display: string;
|
|
81
80
|
alignItems: string;
|
|
82
81
|
justifyContent: string;
|
|
83
82
|
textDecoration: string;
|
|
83
|
+
svg: {
|
|
84
|
+
fill: string;
|
|
85
|
+
'&:hover': {
|
|
86
|
+
fill: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
84
89
|
'&:hover': {
|
|
85
90
|
textDecoration: string;
|
|
86
91
|
};
|
|
@@ -278,7 +278,7 @@ export default {
|
|
|
278
278
|
py: 0,
|
|
279
279
|
px: 5,
|
|
280
280
|
minHeight: '38px',
|
|
281
|
-
|
|
281
|
+
display: 'inline-flex',
|
|
282
282
|
cursor: 'pointer',
|
|
283
283
|
fontWeight: 'medium',
|
|
284
284
|
boxShadow: 'none',
|
|
@@ -288,10 +288,15 @@ export default {
|
|
|
288
288
|
color: 'button.primary.label.hover',
|
|
289
289
|
},
|
|
290
290
|
verticalAlign: 'middle',
|
|
291
|
-
display: 'inline-flex',
|
|
292
291
|
alignItems: 'center',
|
|
293
292
|
justifyContent: 'center',
|
|
294
293
|
textDecoration: 'none',
|
|
294
|
+
svg: {
|
|
295
|
+
fill: 'currentColor',
|
|
296
|
+
'&:hover': {
|
|
297
|
+
fill: 'inherit',
|
|
298
|
+
},
|
|
299
|
+
},
|
|
295
300
|
'&:hover': {
|
|
296
301
|
textDecoration: 'none',
|
|
297
302
|
},
|
|
@@ -409,8 +414,10 @@ export default {
|
|
|
409
414
|
'&:active': {
|
|
410
415
|
color: 'links.active',
|
|
411
416
|
},
|
|
417
|
+
|
|
412
418
|
textDecorationThickness: '0.125rem',
|
|
413
|
-
textUnderlineOffset: '0.
|
|
419
|
+
textUnderlineOffset: '0.250rem',
|
|
420
|
+
|
|
414
421
|
'&:hover, &:focus': {
|
|
415
422
|
color: 'links.hover',
|
|
416
423
|
textDecorationLine: 'underline',
|
package/package.json
CHANGED
|
@@ -54,8 +54,8 @@ const Button = forwardRef< HTMLButtonElement, ButtonProps >(
|
|
|
54
54
|
cursor: 'not-allowed',
|
|
55
55
|
pointerEvents: 'none',
|
|
56
56
|
},
|
|
57
|
-
flexGrow: Boolean( grow ) === true ? '1' :
|
|
58
|
-
width: Boolean( full ) === true ? '100%' :
|
|
57
|
+
flexGrow: Boolean( grow ) === true ? '1' : undefined,
|
|
58
|
+
width: Boolean( full ) === true ? '100%' : undefined,
|
|
59
59
|
...sx,
|
|
60
60
|
} }
|
|
61
61
|
{ ...rest }
|
|
@@ -163,7 +163,12 @@ export const Menu: Story = {
|
|
|
163
163
|
Domains & TLS
|
|
164
164
|
</NavItem.Menu>
|
|
165
165
|
|
|
166
|
-
<NavItem.MenuGroup
|
|
166
|
+
<NavItem.MenuGroup
|
|
167
|
+
active
|
|
168
|
+
activeChildren
|
|
169
|
+
label="Logs"
|
|
170
|
+
renderIcon={ size => <BiHistory size={ size } /> }
|
|
171
|
+
>
|
|
167
172
|
<NavItem.Menu active as={ CustomLink } href="https://google.com/">
|
|
168
173
|
Audit
|
|
169
174
|
</NavItem.Menu>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
|
|
5
|
+
import { render, screen } from '@testing-library/react';
|
|
6
|
+
import { axe } from 'jest-axe';
|
|
7
|
+
import { ThemeUIProvider } from 'theme-ui';
|
|
8
|
+
|
|
9
|
+
import { Nav } from './Nav';
|
|
10
|
+
import { NavItem } from './NavItem';
|
|
11
|
+
import { theme } from '../';
|
|
12
|
+
import { CustomLink } from '../utils/stories/CustomLink';
|
|
13
|
+
|
|
14
|
+
const renderWithTheme = children =>
|
|
15
|
+
render( <ThemeUIProvider theme={ theme }>{ children }</ThemeUIProvider> );
|
|
16
|
+
|
|
17
|
+
const renderComponent = () =>
|
|
18
|
+
renderWithTheme(
|
|
19
|
+
<Nav.Menu label="Nav Menu">
|
|
20
|
+
<NavItem.MenuGroup active activeChildren label="Logs">
|
|
21
|
+
<NavItem.Menu active as={ CustomLink } href="https://google.com/">
|
|
22
|
+
Audit
|
|
23
|
+
</NavItem.Menu>
|
|
24
|
+
<NavItem.Menu as={ CustomLink } href="https://wpvip.com/">
|
|
25
|
+
Runtime
|
|
26
|
+
</NavItem.Menu>
|
|
27
|
+
<NavItem.Menu as={ CustomLink } href="https://dashboard.wpvip.com/">
|
|
28
|
+
Slow Query
|
|
29
|
+
</NavItem.Menu>
|
|
30
|
+
</NavItem.MenuGroup>
|
|
31
|
+
</Nav.Menu>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
describe( '<NavItemGroup />', () => {
|
|
35
|
+
it( 'renders the NavItemGroup component a data-active-children', async () => {
|
|
36
|
+
const { container } = renderComponent();
|
|
37
|
+
|
|
38
|
+
// Should find the button label
|
|
39
|
+
const button = screen.getByRole( 'button', { label: /Logs/ } );
|
|
40
|
+
|
|
41
|
+
expect( button ).toBeInTheDocument();
|
|
42
|
+
|
|
43
|
+
// Expect to have another attribute
|
|
44
|
+
expect( button ).toHaveAttribute( 'data-active', 'true' );
|
|
45
|
+
expect( button ).toHaveAttribute( 'data-active-children', 'true' );
|
|
46
|
+
|
|
47
|
+
// Check for accessibility issues
|
|
48
|
+
expect( await axe( container ) ).toHaveNoViolations();
|
|
49
|
+
} );
|
|
50
|
+
} );
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
|
|
18
18
|
export interface NavItemGroupProps extends NavItemBaseProps {
|
|
19
19
|
renderIcon?: NavItemRenderIconProp;
|
|
20
|
+
activeChildren?: boolean;
|
|
20
21
|
label: string;
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -28,6 +29,7 @@ const NavItemGroupBase = forwardRef< HTMLLIElement, NavItemGroupProps >(
|
|
|
28
29
|
orientation,
|
|
29
30
|
className,
|
|
30
31
|
active,
|
|
32
|
+
activeChildren,
|
|
31
33
|
renderIcon,
|
|
32
34
|
children,
|
|
33
35
|
sx,
|
|
@@ -54,6 +56,7 @@ const NavItemGroupBase = forwardRef< HTMLLIElement, NavItemGroupProps >(
|
|
|
54
56
|
aria-haspopup={ true }
|
|
55
57
|
data-active={ active || undefined }
|
|
56
58
|
data-open={ isExpanded || undefined }
|
|
59
|
+
data-active-children={ activeChildren || undefined }
|
|
57
60
|
sx={ {
|
|
58
61
|
...navItemLinkVariantStyles( variant ),
|
|
59
62
|
...navItemGroupTriggerStyles,
|
|
@@ -31,9 +31,9 @@ export const menuInverseItemStyles = (
|
|
|
31
31
|
// Menu Item Link <a>
|
|
32
32
|
|
|
33
33
|
const visitedLink = '&:visited';
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const focusNotActiveHoverNotActive =
|
|
34
|
+
const active = '&[data-active]:not(&[data-active-children="true"][data-state="open"])';
|
|
35
|
+
const activeBefore = `${ active }::before`;
|
|
36
|
+
const focusNotActiveHoverNotActive = `&:focus:not(${ active }), &:hover:not(${ active })`;
|
|
37
37
|
const notHover = ':not(&:hover)';
|
|
38
38
|
const svgIcon = 'svg';
|
|
39
39
|
|
|
@@ -63,7 +63,7 @@ export const menuItemLinkStyles: MixedStyleProp = {
|
|
|
63
63
|
[ visitedLink ]: {
|
|
64
64
|
color: 'text',
|
|
65
65
|
},
|
|
66
|
-
[
|
|
66
|
+
[ activeBefore ]: {
|
|
67
67
|
position: 'absolute',
|
|
68
68
|
content: "''",
|
|
69
69
|
overflow: 'hidden',
|
|
@@ -29,8 +29,9 @@ export const defaultCloseStyles = ( variant = 'primary' ): ThemeUIStyleObject =>
|
|
|
29
29
|
position: 'absolute',
|
|
30
30
|
top: 3,
|
|
31
31
|
right: 3,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
width: 38,
|
|
33
|
+
height: 38,
|
|
34
|
+
p: 0,
|
|
34
35
|
color: variant === 'primary' ? 'icon.primary' : 'icon.inverse',
|
|
35
36
|
svg: {
|
|
36
37
|
'&:hover': {
|
|
@@ -49,7 +50,7 @@ export const DialogCloseDefault = forwardRef< HTMLButtonElement, DialogCloseDefa
|
|
|
49
50
|
variant="tertiary"
|
|
50
51
|
sx={ defaultCloseStyles( variant ) }
|
|
51
52
|
>
|
|
52
|
-
<IoClose aria-hidden="true" />
|
|
53
|
+
<IoClose aria-hidden="true" width={ 20 } height={ 20 } />
|
|
53
54
|
</Button>
|
|
54
55
|
</DialogClose>
|
|
55
56
|
);
|
|
@@ -278,7 +278,7 @@ export default {
|
|
|
278
278
|
py: 0,
|
|
279
279
|
px: 5,
|
|
280
280
|
minHeight: '38px',
|
|
281
|
-
|
|
281
|
+
display: 'inline-flex',
|
|
282
282
|
cursor: 'pointer',
|
|
283
283
|
fontWeight: 'medium',
|
|
284
284
|
boxShadow: 'none',
|
|
@@ -288,10 +288,15 @@ export default {
|
|
|
288
288
|
color: 'button.primary.label.hover',
|
|
289
289
|
},
|
|
290
290
|
verticalAlign: 'middle',
|
|
291
|
-
display: 'inline-flex',
|
|
292
291
|
alignItems: 'center',
|
|
293
292
|
justifyContent: 'center',
|
|
294
293
|
textDecoration: 'none',
|
|
294
|
+
svg: {
|
|
295
|
+
fill: 'currentColor',
|
|
296
|
+
'&:hover': {
|
|
297
|
+
fill: 'inherit',
|
|
298
|
+
},
|
|
299
|
+
},
|
|
295
300
|
'&:hover': {
|
|
296
301
|
textDecoration: 'none',
|
|
297
302
|
},
|
|
@@ -409,8 +414,10 @@ export default {
|
|
|
409
414
|
'&:active': {
|
|
410
415
|
color: 'links.active',
|
|
411
416
|
},
|
|
417
|
+
|
|
412
418
|
textDecorationThickness: '0.125rem',
|
|
413
|
-
textUnderlineOffset: '0.
|
|
419
|
+
textUnderlineOffset: '0.250rem',
|
|
420
|
+
|
|
414
421
|
'&:hover, &:focus': {
|
|
415
422
|
color: 'links.hover',
|
|
416
423
|
textDecorationLine: 'underline',
|