@bonprix-ds/react-side-navigation 1.0.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/dist/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
import { default as default_2 } from 'react';
|
|
3
|
+
import { ElementType } from 'react';
|
|
4
|
+
import { IconType } from '@bonprix-ds/react-icon';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
import { TitleLevel } from '@bonprix-ds/utils';
|
|
7
|
+
|
|
8
|
+
declare interface NavigationTitle {
|
|
9
|
+
title: string;
|
|
10
|
+
hideTitle?: boolean;
|
|
11
|
+
titleLevel?: TitleLevel;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare const SideNavigation: {
|
|
15
|
+
(props: SideNavigationProps): default_2.JSX.Element;
|
|
16
|
+
displayName: string;
|
|
17
|
+
Section: {
|
|
18
|
+
({ children, title, hideTitle, titleLevel }: SideNavigationSectionProps): default_2.JSX.Element;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
Item: {
|
|
22
|
+
<C extends ElementType>({ children, icon, active, component, ...props }: SideNavigationItemProps<C>): default_2.JSX.Element;
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export default SideNavigation;
|
|
27
|
+
|
|
28
|
+
declare interface SideNavigationItemBaseProps {
|
|
29
|
+
/** The text content of the list item. */
|
|
30
|
+
children: string;
|
|
31
|
+
/** The icon to display in front of the list item. */
|
|
32
|
+
icon?: IconType;
|
|
33
|
+
/** Should be set to `true`, if the current page is equal to the link in this item. */
|
|
34
|
+
active?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare type SideNavigationItemProps<C extends ElementType> = SideNavigationItemBaseProps & {
|
|
38
|
+
/** The semantic component to render the Link. Preferrably `"a"`, `"button"` or something like `Link` from NextJS. Native props will be passed to this component. */
|
|
39
|
+
component?: C;
|
|
40
|
+
} & Omit<ComponentProps<C>, keyof SideNavigationItemBaseProps | "component">;
|
|
41
|
+
|
|
42
|
+
export declare interface SideNavigationProps extends NavigationTitle {
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare interface SideNavigationSectionProps extends NavigationTitle {
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import e from "./SideNavigationRoot.js";
|
|
2
|
+
import t from "@bonprix-ds/react-icon";
|
|
3
|
+
import n from "@bonprix-ds/react-typography";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
//#region src/SideNavigation.tsx
|
|
7
|
+
var a = ({ children: e, title: t, hideTitle: a = !1, titleLevel: o = "h4" }) => /* @__PURE__ */ i("li", {
|
|
8
|
+
"aria-label": a ? t : void 0,
|
|
9
|
+
className: "pb-3 border-b border-clr-bg-main-light last:border-none flex flex-col gap-3",
|
|
10
|
+
children: [!a && /* @__PURE__ */ r(n, {
|
|
11
|
+
variant: "h6",
|
|
12
|
+
component: o,
|
|
13
|
+
color: "on-bg-mid",
|
|
14
|
+
children: t
|
|
15
|
+
}), /* @__PURE__ */ r("ul", {
|
|
16
|
+
className: "flex flex-col gap-3 ps-1",
|
|
17
|
+
children: e
|
|
18
|
+
})]
|
|
19
|
+
});
|
|
20
|
+
a.displayName = "SideNavigation.Section";
|
|
21
|
+
var o = ({ children: e, icon: n, active: a, component: o = "a", ...s }) => {
|
|
22
|
+
let c = o, l = [
|
|
23
|
+
"typography-input-text text-clr-on-bg-high flex items-center gap-3 px-1 py-2",
|
|
24
|
+
"no-underline hover:underline underline-offset-[30%]",
|
|
25
|
+
"focus-visible:outline outline-clr-on-bg-high outline-offset-2 outline-2 radius-2 rounded-sm",
|
|
26
|
+
"aria-current-page:underline aria-current-page:decoration-[15%]"
|
|
27
|
+
].join(" ");
|
|
28
|
+
return /* @__PURE__ */ r("li", { children: /* @__PURE__ */ i(c, {
|
|
29
|
+
...s,
|
|
30
|
+
className: l,
|
|
31
|
+
"aria-current": a ? "page" : void 0,
|
|
32
|
+
children: [n && /* @__PURE__ */ r(t, {
|
|
33
|
+
variant: n,
|
|
34
|
+
className: "h-5 w-5 fill-clr-on-bg-high"
|
|
35
|
+
}), /* @__PURE__ */ r("span", { children: e })]
|
|
36
|
+
}) });
|
|
37
|
+
};
|
|
38
|
+
o.displayName = "SideNavigation.Item";
|
|
39
|
+
var s = (t) => /* @__PURE__ */ r(e, { ...t });
|
|
40
|
+
s.displayName = "SideNavigation", s.Section = a, s.Item = o;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { s as default };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=SideNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SideNavigation.js","names":[],"sources":["../../src/SideNavigation.tsx"],"sourcesContent":["import Icon, { type IconType } from \"@bonprix-ds/react-icon\";\nimport Typography from \"@bonprix-ds/react-typography\";\nimport React, { ComponentProps, ElementType, ReactNode } from \"react\";\n\nimport SideNavigationRoot, { type NavigationTitle, type SideNavigationProps } from \"./SideNavigationRoot\";\n\nexport type { SideNavigationProps } from \"./SideNavigationRoot\";\n\ninterface SideNavigationSectionProps extends NavigationTitle {\n children: ReactNode;\n}\n\nconst SideNavigationSection = ({ children, title, hideTitle = false, titleLevel = \"h4\" }: SideNavigationSectionProps) => {\n return (\n <li aria-label={hideTitle ? title : undefined} className=\"pb-3 border-b border-clr-bg-main-light last:border-none flex flex-col gap-3\">\n {!hideTitle && (\n <Typography variant=\"h6\" component={titleLevel} color=\"on-bg-mid\">\n {title}\n </Typography>\n )}\n <ul className=\"flex flex-col gap-3 ps-1\">{children}</ul>\n </li>\n );\n};\n\nSideNavigationSection.displayName = \"SideNavigation.Section\";\n\ninterface SideNavigationItemBaseProps {\n /** The text content of the list item. */\n children: string;\n /** The icon to display in front of the list item. */\n icon?: IconType;\n /** Should be set to `true`, if the current page is equal to the link in this item. */\n active?: boolean;\n}\n\ntype SideNavigationItemProps<C extends ElementType> = SideNavigationItemBaseProps & {\n /** The semantic component to render the Link. Preferrably `\"a\"`, `\"button\"` or something like `Link` from NextJS. Native props will be passed to this component. */\n component?: C;\n} & Omit<ComponentProps<C>, keyof SideNavigationItemBaseProps | \"component\">;\n\nconst SideNavigationItem = <C extends ElementType>({\n children,\n icon,\n active,\n component = \"a\" as C,\n ...props\n}: SideNavigationItemProps<C>) => {\n const Component: ElementType = component;\n const classNames = [\n \"typography-input-text text-clr-on-bg-high flex items-center gap-3 px-1 py-2\",\n \"no-underline hover:underline underline-offset-[30%]\",\n \"focus-visible:outline outline-clr-on-bg-high outline-offset-2 outline-2 radius-2 rounded-sm\",\n \"aria-current-page:underline aria-current-page:decoration-[15%]\",\n ].join(\" \");\n return (\n <li>\n <Component {...props} className={classNames} aria-current={active ? \"page\" : undefined}>\n {icon && <Icon variant={icon} className=\"h-5 w-5 fill-clr-on-bg-high\" />}\n <span>{children}</span>\n </Component>\n </li>\n );\n};\n\nSideNavigationItem.displayName = \"SideNavigation.Item\";\n\nconst SideNavigation = (props: SideNavigationProps) => <SideNavigationRoot {...props} />;\n\nSideNavigation.displayName = \"SideNavigation\";\n\nSideNavigation.Section = SideNavigationSection;\nSideNavigation.Item = SideNavigationItem;\n\nexport default SideNavigation;\n"],"mappings":";;;;;;AAYA,IAAM,KAAyB,EAAE,aAAU,UAAO,eAAY,IAAO,gBAAa,WAE9E,kBAAC,MAAD;CAAI,cAAY,IAAY,IAAQ,KAAA;CAAW,WAAU;CAAzD,UAAA,CACG,CAAC,KACA,kBAAC,GAAD;EAAY,SAAQ;EAAK,WAAW;EAAY,OAAM;EACnD,UAAA;CACS,CAAA,GAEd,kBAAC,MAAD;EAAI,WAAU;EAA4B;CAAa,CAAA,CACrD;;AAIR,EAAsB,cAAc;AAgBpC,IAAM,KAA6C,EACjD,aACA,SACA,WACA,eAAY,KACZ,GAAG,QAC6B;CAChC,IAAM,IAAyB,GACzB,IAAa;EACjB;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,GAAG;CACV,OACE,kBAAC,MAAD,EAAA,UACE,kBAAC,GAAD;EAAW,GAAI;EAAO,WAAW;EAAY,gBAAc,IAAS,SAAS,KAAA;EAA7E,UAAA,CACG,KAAQ,kBAAC,GAAD;GAAM,SAAS;GAAM,WAAU;EAA+B,CAAA,GACvE,kBAAC,QAAD,EAAO,YAAe,CAAA,CACb;CACT,CAAA,EAAA,CAAA;AAER;AAEA,EAAmB,cAAc;AAEjC,IAAM,KAAkB,MAA+B,kBAAC,GAAD,EAAoB,GAAI,EAAQ,CAAA;AAEvF,EAAe,cAAc,kBAE7B,EAAe,UAAU,GACzB,EAAe,OAAO"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import e from "@bonprix-ds/react-typography";
|
|
3
|
+
import "react";
|
|
4
|
+
import { useBreakpointDown as t } from "@bonprix-ds/utils";
|
|
5
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
6
|
+
//#region src/SideNavigationRoot.tsx
|
|
7
|
+
var i = ({ children: i, title: a, hideTitle: o = !1, titleLevel: s = "h3" }) => t("m") ? null : /* @__PURE__ */ r("nav", {
|
|
8
|
+
...o ? { "aria-label": a } : { "aria-labelledby": "side-navigation-header" },
|
|
9
|
+
className: "preflight pt-6 ps-6 pe-2 bg-clr-bg-main h-screen overflow-auto min-w-[18.75rem] max-w-[31.25rem] w-fit",
|
|
10
|
+
"data-bpds": "side-navigation",
|
|
11
|
+
children: [!o && /* @__PURE__ */ n("div", {
|
|
12
|
+
className: "pt-3 pb-6",
|
|
13
|
+
children: /* @__PURE__ */ n(e, {
|
|
14
|
+
variant: "bonprix-h4",
|
|
15
|
+
component: s,
|
|
16
|
+
id: "side-navigation-header",
|
|
17
|
+
children: a
|
|
18
|
+
})
|
|
19
|
+
}), /* @__PURE__ */ n("ul", {
|
|
20
|
+
className: "flex flex-col gap-3",
|
|
21
|
+
children: i
|
|
22
|
+
})]
|
|
23
|
+
});
|
|
24
|
+
i.displayName = "SideNavigation";
|
|
25
|
+
//#endregion
|
|
26
|
+
export { i as default };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=SideNavigationRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SideNavigationRoot.js","names":[],"sources":["../../src/SideNavigationRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport Typography from \"@bonprix-ds/react-typography\";\nimport type { TitleLevel } from \"@bonprix-ds/utils\";\nimport { useBreakpointDown } from \"@bonprix-ds/utils\";\nimport React, { ReactNode } from \"react\";\n\nexport interface NavigationTitle {\n title: string;\n hideTitle?: boolean;\n titleLevel?: TitleLevel;\n}\n\nexport interface SideNavigationProps extends NavigationTitle {\n children: ReactNode;\n}\n\nconst SideNavigationRoot = ({ children, title, hideTitle = false, titleLevel = \"h3\" }: SideNavigationProps) => {\n if (useBreakpointDown(\"m\")) return null;\n const labelAttribute = hideTitle ? { \"aria-label\": title } : { \"aria-labelledby\": \"side-navigation-header\" };\n return (\n <nav\n {...labelAttribute}\n className=\"preflight pt-6 ps-6 pe-2 bg-clr-bg-main h-screen overflow-auto min-w-[18.75rem] max-w-[31.25rem] w-fit\"\n data-bpds=\"side-navigation\"\n >\n {!hideTitle && (\n <div className=\"pt-3 pb-6\">\n <Typography variant=\"bonprix-h4\" component={titleLevel} id=\"side-navigation-header\">\n {title}\n </Typography>\n </div>\n )}\n <ul className=\"flex flex-col gap-3\">{children}</ul>\n </nav>\n );\n};\n\nSideNavigationRoot.displayName = \"SideNavigation\";\n\nexport default SideNavigationRoot;\n"],"mappings":";;;;;;AAiBA,IAAM,KAAsB,EAAE,aAAU,UAAO,eAAY,IAAO,gBAAa,WACzE,EAAkB,GAAG,IAAU,OAGjC,kBAAC,OAAD;CACE,GAHmB,IAAY,EAAE,cAAc,EAAM,IAAI,EAAE,mBAAmB,yBAAyB;CAIvG,WAAU;CACV,aAAU;CAHZ,UAAA,CAKG,CAAC,KACA,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,GAAD;GAAY,SAAQ;GAAa,WAAW;GAAY,IAAG;GACxD,UAAA;EACS,CAAA;CACT,CAAA,GAEP,kBAAC,MAAD;EAAI,WAAU;EAAuB;CAAa,CAAA,CAC/C;;AAIT,EAAmB,cAAc"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bonprix-ds/react-side-navigation",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SideNavigation component, implemented in React, for the Bonprix Design System.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public",
|
|
8
|
+
"provenance": true
|
|
9
|
+
},
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [],
|
|
24
|
+
"author": "",
|
|
25
|
+
"license": "UNLICENSED",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/bonprix/design-system.git",
|
|
29
|
+
"directory": "packages/react/side-navigation"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@bonprix-ds/react-icon": "1.1.3",
|
|
33
|
+
"@bonprix-ds/utils": "0.2.1",
|
|
34
|
+
"@bonprix-ds/react-typography": "1.0.4"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": "^19.0.0",
|
|
38
|
+
"react-dom": "^19.0.0",
|
|
39
|
+
"tailwind-variants": "0.3.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"vite": "8.2.2",
|
|
43
|
+
"@types/react": "19.2.18",
|
|
44
|
+
"@vitejs/plugin-react": "6.1.1",
|
|
45
|
+
"rollup-preserve-directives": "1.1.3",
|
|
46
|
+
"unplugin-dts": "1.0.3",
|
|
47
|
+
"@microsoft/api-extractor": "7.59.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "vite build"
|
|
51
|
+
}
|
|
52
|
+
}
|