@nice-digital/nds-horizontal-nav 3.0.3 → 4.0.0-alpha.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/es/HorizontalNav.d.ts +19 -0
- package/es/HorizontalNav.js +36 -56
- package/es/HorizontalNav.test.d.ts +1 -0
- package/es/HorizontalNav.test.js +69 -0
- package/package.json +12 -11
- package/es/HorizontalNav.js.map +0 -1
- package/horizontal-nav.d.ts +0 -22
- package/lib/HorizontalNav.js +0 -102
- package/lib/HorizontalNav.js.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "../scss/horizontal-nav.scss";
|
|
3
|
+
export interface HorizontalNavProps {
|
|
4
|
+
[prop: string]: unknown;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface HorizontalNavLinkProps {
|
|
9
|
+
[prop: string]: unknown;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
destination: string;
|
|
13
|
+
elementType?: React.ElementType;
|
|
14
|
+
isCurrent?: boolean;
|
|
15
|
+
method?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const HorizontalNav: React.FC<HorizontalNavProps>;
|
|
19
|
+
export declare const HorizontalNavLink: React.FC<HorizontalNavLinkProps>;
|
package/es/HorizontalNav.js
CHANGED
|
@@ -1,56 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
className: classnames("horizontal-nav__link", className)
|
|
38
|
-
}, _props[method || ElementType === "a" && "href" || "to"] = destination, _props);
|
|
39
|
-
return /*#__PURE__*/React.createElement("li", {
|
|
40
|
-
className: "horizontal-nav__item"
|
|
41
|
-
}, /*#__PURE__*/React.createElement(ElementType, _extends({}, props, rest), title || children || destination || "No Link"));
|
|
42
|
-
};
|
|
43
|
-
HorizontalNav.propTypes = {
|
|
44
|
-
children: PropTypes.node,
|
|
45
|
-
className: PropTypes.string
|
|
46
|
-
};
|
|
47
|
-
HorizontalNavLink.propTypes = {
|
|
48
|
-
children: PropTypes.node,
|
|
49
|
-
title: PropTypes.string,
|
|
50
|
-
isCurrent: PropTypes.bool,
|
|
51
|
-
destination: PropTypes.string.isRequired,
|
|
52
|
-
elementType: PropTypes.elementType,
|
|
53
|
-
className: PropTypes.string,
|
|
54
|
-
method: PropTypes.string
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=HorizontalNav.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.HorizontalNavLink = exports.HorizontalNav = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
20
|
+
require("../scss/horizontal-nav.scss");
|
|
21
|
+
const HorizontalNav = (_a) => {
|
|
22
|
+
var { className, children } = _a, rest = __rest(_a, ["className", "children"]);
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)("nav", Object.assign({ className: (0, classnames_1.default)("horizontal-nav", className) }, rest, { children: (0, jsx_runtime_1.jsx)("ul", Object.assign({ className: "horizontal-nav__list" }, { children: children })) })));
|
|
24
|
+
};
|
|
25
|
+
exports.HorizontalNav = HorizontalNav;
|
|
26
|
+
const HorizontalNavLink = (_a) => {
|
|
27
|
+
var { title, isCurrent = false, destination, elementType: ElementType = "a", children, className, method } = _a, rest = __rest(_a, ["title", "isCurrent", "destination", "elementType", "children", "className", "method"]);
|
|
28
|
+
// Would like to make method a required prop in the future but not possible without a breaking change
|
|
29
|
+
const props = {
|
|
30
|
+
"aria-current": isCurrent,
|
|
31
|
+
className: (0, classnames_1.default)("horizontal-nav__link", className),
|
|
32
|
+
[method || (ElementType === "a" && "href") || "to"]: destination
|
|
33
|
+
};
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)("li", Object.assign({ className: "horizontal-nav__item" }, { children: (0, jsx_runtime_1.jsx)(ElementType, Object.assign({}, props, rest, { children: title || children || destination || "No Link" })) })));
|
|
35
|
+
};
|
|
36
|
+
exports.HorizontalNavLink = HorizontalNavLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("@testing-library/react");
|
|
5
|
+
const HorizontalNav_1 = require("./HorizontalNav");
|
|
6
|
+
const Link = () => (0, jsx_runtime_1.jsx)("div", { "data-type": "link" });
|
|
7
|
+
const links = [
|
|
8
|
+
{
|
|
9
|
+
title: "Link One",
|
|
10
|
+
destination: "/formgroup",
|
|
11
|
+
className: "one"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
title: "Link Two",
|
|
15
|
+
destination: "/pageheader",
|
|
16
|
+
isCurrent: true,
|
|
17
|
+
elementType: Link,
|
|
18
|
+
className: "two"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
title: "Link Three",
|
|
22
|
+
destination: "/stackednav",
|
|
23
|
+
method: "pigeon",
|
|
24
|
+
className: "three"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
title: "Link Four",
|
|
28
|
+
destination: "/alert",
|
|
29
|
+
elementType: Link,
|
|
30
|
+
method: "to",
|
|
31
|
+
className: "four"
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
describe("Horizontal Nav Component", () => {
|
|
35
|
+
it("should match the default snapshot", () => {
|
|
36
|
+
const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNav, { children: links.map((link) => ((0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNavLink, Object.assign({}, link, { className: "monkey", "data-track": "monkey" }), link.title))) }));
|
|
37
|
+
expect(wrapper).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
it("should render the name of the destination as the link text if no title or child is supplied ", () => {
|
|
40
|
+
const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNav, { children: (0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNavLink, { destination: "/testing" }) }));
|
|
41
|
+
expect(wrapper.getByRole("link", { name: "/testing" })).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
describe("HorizontalNav", () => {
|
|
44
|
+
it("should pass additional props to the container", () => {
|
|
45
|
+
const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNav, Object.assign({ autoglassrepair: "autoglass replace" }, { children: (0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNavLink, Object.assign({ destination: "#" }, { children: "Link text" })) })));
|
|
46
|
+
expect(wrapper.getByRole("navigation").getAttribute("autoglassrepair")).toBe("autoglass replace");
|
|
47
|
+
});
|
|
48
|
+
it("should merge additional classes onto the container", () => {
|
|
49
|
+
const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNav, Object.assign({ className: "classy" }, { children: (0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNavLink, Object.assign({ destination: "#" }, { children: "Link text" })) })));
|
|
50
|
+
expect(wrapper.getByRole("navigation")).toHaveClass("classy");
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
describe("HorizontalNavLink", () => {
|
|
54
|
+
it("NavLink should pass additional props directly to the link", () => {
|
|
55
|
+
const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNav, { children: (0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNavLink, Object.assign({ destination: "#", dancing: "is what we do" }, { children: "Link text" })) }));
|
|
56
|
+
expect(wrapper.getByRole("link").getAttribute("dancing")).toBe("is what we do");
|
|
57
|
+
});
|
|
58
|
+
it("should merge additional classes onto the anchor", () => {
|
|
59
|
+
const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNav, { children: (0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNavLink, Object.assign({ destination: "#", className: "very-classy" }, { children: "Link text" })) }));
|
|
60
|
+
expect(wrapper.getByRole("link")).toHaveClass("very-classy");
|
|
61
|
+
});
|
|
62
|
+
it("should use a custom navigation attribute if supplied, otherwise fall back to href if anchor or to if not", () => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNav, { children: links.map((link) => ((0, jsx_runtime_1.jsx)(HorizontalNav_1.HorizontalNavLink, Object.assign({}, link), link.title))) }));
|
|
65
|
+
expect((_a = container.querySelector("a.three")) === null || _a === void 0 ? void 0 : _a.getAttribute("pigeon")).toBeTruthy();
|
|
66
|
+
expect((_b = container.querySelector("a.one")) === null || _b === void 0 ? void 0 : _b.getAttribute("href")).toBeTruthy();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice-digital/nds-horizontal-nav",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "Horizontal navigation component for the NICE Design System",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"navigation"
|
|
@@ -8,16 +8,13 @@
|
|
|
8
8
|
"author": "Warren Keith <w@rren.dev>",
|
|
9
9
|
"homepage": "https://design-system.nice.org.uk/",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"main": "
|
|
12
|
-
"module": "es/HorizontalNav.js",
|
|
11
|
+
"main": "es/HorizontalNav.js",
|
|
13
12
|
"style": "scss/horizontal-nav.scss",
|
|
14
|
-
"types": "horizontal-nav.d.ts",
|
|
15
13
|
"directories": {
|
|
16
|
-
"lib": "
|
|
14
|
+
"lib": "es",
|
|
17
15
|
"test": "__tests__"
|
|
18
16
|
},
|
|
19
17
|
"files": [
|
|
20
|
-
"lib",
|
|
21
18
|
"es",
|
|
22
19
|
"scss",
|
|
23
20
|
"*.d.ts"
|
|
@@ -34,16 +31,20 @@
|
|
|
34
31
|
"url": "https://github.com/nice-digital/nice-design-system/issues"
|
|
35
32
|
},
|
|
36
33
|
"dependencies": {
|
|
37
|
-
"@nice-digital/nds-core": "^
|
|
38
|
-
"classnames": "^2.2.6"
|
|
39
|
-
"prop-types": "^15.7.2"
|
|
34
|
+
"@nice-digital/nds-core": "^4.0.0-alpha.0",
|
|
35
|
+
"classnames": "^2.2.6"
|
|
40
36
|
},
|
|
41
37
|
"peerDependencies": {
|
|
42
38
|
"react": "^16 || ^17 || ^18",
|
|
43
39
|
"react-dom": "^16 || ^17 || ^18"
|
|
44
40
|
},
|
|
45
41
|
"devDependencies": {
|
|
46
|
-
"@
|
|
42
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
43
|
+
"@testing-library/react": "^13.4.0",
|
|
44
|
+
"@testing-library/user-event": "^14.4.3",
|
|
45
|
+
"@types/jest": "^29.2.2",
|
|
46
|
+
"@types/node": "^18.11.9",
|
|
47
|
+
"typescript": "^4.8.4"
|
|
47
48
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "e225e0b15723013fb3df7309d197590a09cc2ea7"
|
|
49
50
|
}
|
package/es/HorizontalNav.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalNav.js","names":["React","PropTypes","classnames","HorizontalNav","className","children","rest","HorizontalNavLink","title","isCurrent","destination","elementType","ElementType","method","props","propTypes","node","string","bool","isRequired"],"sources":["../src/HorizontalNav.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport classnames from \"classnames\";\n\nimport \"./../scss/horizontal-nav.scss\";\n\nexport const HorizontalNav = ({ className, children, ...rest }) => {\n\treturn (\n\t\t<nav className={classnames(\"horizontal-nav\", className)} {...rest}>\n\t\t\t<ul className=\"horizontal-nav__list\">{children}</ul>\n\t\t</nav>\n\t);\n};\n\nexport const HorizontalNavLink = ({\n\ttitle,\n\tisCurrent = false,\n\tdestination,\n\telementType: ElementType = \"a\",\n\tchildren,\n\tclassName,\n\tmethod,\n\t...rest\n}) => {\n\t// Would like to make method a required prop in the future but not possible without a breaking change\n\tconst props = {\n\t\t\"aria-current\": isCurrent,\n\t\tclassName: classnames(\"horizontal-nav__link\", className),\n\t\t[method || (ElementType === \"a\" && \"href\") || \"to\"]: destination\n\t};\n\treturn (\n\t\t<li className=\"horizontal-nav__item\">\n\t\t\t<ElementType {...props} {...rest}>\n\t\t\t\t{title || children || destination || \"No Link\"}\n\t\t\t</ElementType>\n\t\t</li>\n\t);\n};\n\nHorizontalNav.propTypes = {\n\tchildren: PropTypes.node,\n\tclassName: PropTypes.string\n};\n\nHorizontalNavLink.propTypes = {\n\tchildren: PropTypes.node,\n\ttitle: PropTypes.string,\n\tisCurrent: PropTypes.bool,\n\tdestination: PropTypes.string.isRequired,\n\telementType: PropTypes.elementType,\n\tclassName: PropTypes.string,\n\tmethod: PropTypes.string\n};\n"],"mappings":";;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,OAAO,+BAAP;AAEA,OAAO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,OAAsC;EAAA,IAAnCC,SAAmC,QAAnCA,SAAmC;EAAA,IAAxBC,QAAwB,QAAxBA,QAAwB;EAAA,IAAXC,IAAW;;EAClE,oBACC;IAAK,SAAS,EAAEJ,UAAU,CAAC,gBAAD,EAAmBE,SAAnB;EAA1B,GAA6DE,IAA7D,gBACC;IAAI,SAAS,EAAC;EAAd,GAAsCD,QAAtC,CADD,CADD;AAKA,CANM;AAQP,OAAO,IAAME,iBAAiB,GAAG,SAApBA,iBAAoB,QAS3B;EAAA;;EAAA,IARLC,KAQK,SARLA,KAQK;EAAA,4BAPLC,SAOK;EAAA,IAPLA,SAOK,gCAPO,KAOP;EAAA,IANLC,WAMK,SANLA,WAMK;EAAA,8BALLC,WAKK;EAAA,IALQC,WAKR,kCALsB,GAKtB;EAAA,IAJLP,QAIK,SAJLA,QAIK;EAAA,IAHLD,SAGK,SAHLA,SAGK;EAAA,IAFLS,MAEK,SAFLA,MAEK;EAAA,IADFP,IACE;;EACL;EACA,IAAMQ,KAAK;IACV,gBAAgBL,SADN;IAEVL,SAAS,EAAEF,UAAU,CAAC,sBAAD,EAAyBE,SAAzB;EAFX,UAGTS,MAAM,IAAKD,WAAW,KAAK,GAAhB,IAAuB,MAAlC,IAA6C,IAHpC,IAG2CF,WAH3C,SAAX;EAKA,oBACC;IAAI,SAAS,EAAC;EAAd,gBACC,oBAAC,WAAD,eAAiBI,KAAjB,EAA4BR,IAA5B,GACEE,KAAK,IAAIH,QAAT,IAAqBK,WAArB,IAAoC,SADtC,CADD,CADD;AAOA,CAvBM;AAyBPP,aAAa,CAACY,SAAd,GAA0B;EACzBV,QAAQ,EAAEJ,SAAS,CAACe,IADK;EAEzBZ,SAAS,EAAEH,SAAS,CAACgB;AAFI,CAA1B;AAKAV,iBAAiB,CAACQ,SAAlB,GAA8B;EAC7BV,QAAQ,EAAEJ,SAAS,CAACe,IADS;EAE7BR,KAAK,EAAEP,SAAS,CAACgB,MAFY;EAG7BR,SAAS,EAAER,SAAS,CAACiB,IAHQ;EAI7BR,WAAW,EAAET,SAAS,CAACgB,MAAV,CAAiBE,UAJD;EAK7BR,WAAW,EAAEV,SAAS,CAACU,WALM;EAM7BP,SAAS,EAAEH,SAAS,CAACgB,MANQ;EAO7BJ,MAAM,EAAEZ,SAAS,CAACgB;AAPW,CAA9B"}
|
package/horizontal-nav.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
declare module "@nice-digital/nds-horizontal-nav" {
|
|
2
|
-
import React = require("react");
|
|
3
|
-
|
|
4
|
-
export interface HorizontalNavProps {
|
|
5
|
-
[prop: string]: unknown;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface HorizontalNavLinkProps {
|
|
10
|
-
[prop: string]: unknown;
|
|
11
|
-
children?: React.ReactNode;
|
|
12
|
-
className?: string;
|
|
13
|
-
destination: string;
|
|
14
|
-
elementType?: React.ElementType;
|
|
15
|
-
isCurrent?: boolean;
|
|
16
|
-
method?: string;
|
|
17
|
-
title?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const HorizontalNav: React.FC<HorizontalNavProps>;
|
|
21
|
-
export const HorizontalNavLink: React.FC<HorizontalNavLinkProps>;
|
|
22
|
-
}
|
package/lib/HorizontalNav.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
exports.__esModule = true;
|
|
6
|
-
exports.HorizontalNavLink = exports.HorizontalNav = void 0;
|
|
7
|
-
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
-
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
-
|
|
18
|
-
require("./../scss/horizontal-nav.scss");
|
|
19
|
-
|
|
20
|
-
var _excluded = ["className", "children"],
|
|
21
|
-
_excluded2 = ["title", "isCurrent", "destination", "elementType", "children", "className", "method"];
|
|
22
|
-
|
|
23
|
-
var _jsxFileName = "C:\\_dev\\nice-design-system\\components\\nds-horizontal-nav\\src\\HorizontalNav.js",
|
|
24
|
-
_this = void 0;
|
|
25
|
-
|
|
26
|
-
var HorizontalNav = function HorizontalNav(_ref) {
|
|
27
|
-
var className = _ref.className,
|
|
28
|
-
children = _ref.children,
|
|
29
|
-
rest = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
30
|
-
return /*#__PURE__*/_react["default"].createElement("nav", (0, _extends2["default"])({
|
|
31
|
-
className: (0, _classnames["default"])("horizontal-nav", className)
|
|
32
|
-
}, rest, {
|
|
33
|
-
__self: _this,
|
|
34
|
-
__source: {
|
|
35
|
-
fileName: _jsxFileName,
|
|
36
|
-
lineNumber: 9,
|
|
37
|
-
columnNumber: 3
|
|
38
|
-
}
|
|
39
|
-
}), /*#__PURE__*/_react["default"].createElement("ul", {
|
|
40
|
-
className: "horizontal-nav__list",
|
|
41
|
-
__self: _this,
|
|
42
|
-
__source: {
|
|
43
|
-
fileName: _jsxFileName,
|
|
44
|
-
lineNumber: 10,
|
|
45
|
-
columnNumber: 4
|
|
46
|
-
}
|
|
47
|
-
}, children));
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
exports.HorizontalNav = HorizontalNav;
|
|
51
|
-
|
|
52
|
-
var HorizontalNavLink = function HorizontalNavLink(_ref2) {
|
|
53
|
-
var _props;
|
|
54
|
-
|
|
55
|
-
var title = _ref2.title,
|
|
56
|
-
_ref2$isCurrent = _ref2.isCurrent,
|
|
57
|
-
isCurrent = _ref2$isCurrent === void 0 ? false : _ref2$isCurrent,
|
|
58
|
-
destination = _ref2.destination,
|
|
59
|
-
_ref2$elementType = _ref2.elementType,
|
|
60
|
-
ElementType = _ref2$elementType === void 0 ? "a" : _ref2$elementType,
|
|
61
|
-
children = _ref2.children,
|
|
62
|
-
className = _ref2.className,
|
|
63
|
-
method = _ref2.method,
|
|
64
|
-
rest = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, _excluded2);
|
|
65
|
-
// Would like to make method a required prop in the future but not possible without a breaking change
|
|
66
|
-
var props = (_props = {
|
|
67
|
-
"aria-current": isCurrent,
|
|
68
|
-
className: (0, _classnames["default"])("horizontal-nav__link", className)
|
|
69
|
-
}, _props[method || ElementType === "a" && "href" || "to"] = destination, _props);
|
|
70
|
-
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
71
|
-
className: "horizontal-nav__item",
|
|
72
|
-
__self: _this,
|
|
73
|
-
__source: {
|
|
74
|
-
fileName: _jsxFileName,
|
|
75
|
-
lineNumber: 32,
|
|
76
|
-
columnNumber: 3
|
|
77
|
-
}
|
|
78
|
-
}, /*#__PURE__*/_react["default"].createElement(ElementType, (0, _extends2["default"])({}, props, rest, {
|
|
79
|
-
__self: _this,
|
|
80
|
-
__source: {
|
|
81
|
-
fileName: _jsxFileName,
|
|
82
|
-
lineNumber: 33,
|
|
83
|
-
columnNumber: 4
|
|
84
|
-
}
|
|
85
|
-
}), title || children || destination || "No Link"));
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
exports.HorizontalNavLink = HorizontalNavLink;
|
|
89
|
-
HorizontalNav.propTypes = {
|
|
90
|
-
children: _propTypes["default"].node,
|
|
91
|
-
className: _propTypes["default"].string
|
|
92
|
-
};
|
|
93
|
-
HorizontalNavLink.propTypes = {
|
|
94
|
-
children: _propTypes["default"].node,
|
|
95
|
-
title: _propTypes["default"].string,
|
|
96
|
-
isCurrent: _propTypes["default"].bool,
|
|
97
|
-
destination: _propTypes["default"].string.isRequired,
|
|
98
|
-
elementType: _propTypes["default"].elementType,
|
|
99
|
-
className: _propTypes["default"].string,
|
|
100
|
-
method: _propTypes["default"].string
|
|
101
|
-
};
|
|
102
|
-
//# sourceMappingURL=HorizontalNav.js.map
|
package/lib/HorizontalNav.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalNav.js","names":["HorizontalNav","className","children","rest","classnames","HorizontalNavLink","title","isCurrent","destination","elementType","ElementType","method","props","propTypes","PropTypes","node","string","bool","isRequired"],"sources":["../src/HorizontalNav.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport classnames from \"classnames\";\n\nimport \"./../scss/horizontal-nav.scss\";\n\nexport const HorizontalNav = ({ className, children, ...rest }) => {\n\treturn (\n\t\t<nav className={classnames(\"horizontal-nav\", className)} {...rest}>\n\t\t\t<ul className=\"horizontal-nav__list\">{children}</ul>\n\t\t</nav>\n\t);\n};\n\nexport const HorizontalNavLink = ({\n\ttitle,\n\tisCurrent = false,\n\tdestination,\n\telementType: ElementType = \"a\",\n\tchildren,\n\tclassName,\n\tmethod,\n\t...rest\n}) => {\n\t// Would like to make method a required prop in the future but not possible without a breaking change\n\tconst props = {\n\t\t\"aria-current\": isCurrent,\n\t\tclassName: classnames(\"horizontal-nav__link\", className),\n\t\t[method || (ElementType === \"a\" && \"href\") || \"to\"]: destination\n\t};\n\treturn (\n\t\t<li className=\"horizontal-nav__item\">\n\t\t\t<ElementType {...props} {...rest}>\n\t\t\t\t{title || children || destination || \"No Link\"}\n\t\t\t</ElementType>\n\t\t</li>\n\t);\n};\n\nHorizontalNav.propTypes = {\n\tchildren: PropTypes.node,\n\tclassName: PropTypes.string\n};\n\nHorizontalNavLink.propTypes = {\n\tchildren: PropTypes.node,\n\ttitle: PropTypes.string,\n\tisCurrent: PropTypes.bool,\n\tdestination: PropTypes.string.isRequired,\n\telementType: PropTypes.elementType,\n\tclassName: PropTypes.string,\n\tmethod: PropTypes.string\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;;;AAEO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,OAAsC;EAAA,IAAnCC,SAAmC,QAAnCA,SAAmC;EAAA,IAAxBC,QAAwB,QAAxBA,QAAwB;EAAA,IAAXC,IAAW;EAClE,oBACC;IAAK,SAAS,EAAE,IAAAC,sBAAA,EAAW,gBAAX,EAA6BH,SAA7B;EAAhB,GAA6DE,IAA7D;IAAA;IAAA;MAAA;MAAA;MAAA;IAAA;EAAA,iBACC;IAAI,SAAS,EAAC,sBAAd;IAAA;IAAA;MAAA;MAAA;MAAA;IAAA;EAAA,GAAsCD,QAAtC,CADD,CADD;AAKA,CANM;;;;AAQA,IAAMG,iBAAiB,GAAG,SAApBA,iBAAoB,QAS3B;EAAA;;EAAA,IARLC,KAQK,SARLA,KAQK;EAAA,4BAPLC,SAOK;EAAA,IAPLA,SAOK,gCAPO,KAOP;EAAA,IANLC,WAMK,SANLA,WAMK;EAAA,8BALLC,WAKK;EAAA,IALQC,WAKR,kCALsB,GAKtB;EAAA,IAJLR,QAIK,SAJLA,QAIK;EAAA,IAHLD,SAGK,SAHLA,SAGK;EAAA,IAFLU,MAEK,SAFLA,MAEK;EAAA,IADFR,IACE;EACL;EACA,IAAMS,KAAK;IACV,gBAAgBL,SADN;IAEVN,SAAS,EAAE,IAAAG,sBAAA,EAAW,sBAAX,EAAmCH,SAAnC;EAFD,UAGTU,MAAM,IAAKD,WAAW,KAAK,GAAhB,IAAuB,MAAlC,IAA6C,IAHpC,IAG2CF,WAH3C,SAAX;EAKA,oBACC;IAAI,SAAS,EAAC,sBAAd;IAAA;IAAA;MAAA;MAAA;MAAA;IAAA;EAAA,gBACC,gCAAC,WAAD,gCAAiBI,KAAjB,EAA4BT,IAA5B;IAAA;IAAA;MAAA;MAAA;MAAA;IAAA;EAAA,IACEG,KAAK,IAAIJ,QAAT,IAAqBM,WAArB,IAAoC,SADtC,CADD,CADD;AAOA,CAvBM;;;AAyBPR,aAAa,CAACa,SAAd,GAA0B;EACzBX,QAAQ,EAAEY,qBAAA,CAAUC,IADK;EAEzBd,SAAS,EAAEa,qBAAA,CAAUE;AAFI,CAA1B;AAKAX,iBAAiB,CAACQ,SAAlB,GAA8B;EAC7BX,QAAQ,EAAEY,qBAAA,CAAUC,IADS;EAE7BT,KAAK,EAAEQ,qBAAA,CAAUE,MAFY;EAG7BT,SAAS,EAAEO,qBAAA,CAAUG,IAHQ;EAI7BT,WAAW,EAAEM,qBAAA,CAAUE,MAAV,CAAiBE,UAJD;EAK7BT,WAAW,EAAEK,qBAAA,CAAUL,WALM;EAM7BR,SAAS,EAAEa,qBAAA,CAAUE,MANQ;EAO7BL,MAAM,EAAEG,qBAAA,CAAUE;AAPW,CAA9B"}
|