@fragment-build/ui 1.0.0 → 1.0.4
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/components/color-input/ColorInput.js +16 -0
- package/dist/components/color-input/ColorInput.js.map +1 -0
- package/dist/components/color-input/{ColorInput.stories.jsx → ColorInput.stories.js} +1 -0
- package/dist/components/color-input/ColorInput.stories.js.map +1 -0
- package/dist/components/color-selector/ColorSelector.js +10 -0
- package/dist/components/color-selector/ColorSelector.js.map +1 -0
- package/dist/components/color-selector/{ColorSelector.stories.jsx → ColorSelector.stories.js} +3 -1
- package/dist/components/color-selector/ColorSelector.stories.js.map +1 -0
- package/dist/fragments/shell/Shell.js +7 -0
- package/dist/fragments/shell/Shell.js.map +1 -0
- package/dist/fragments/shell/Shell.stories.js +129 -0
- package/dist/fragments/shell/Shell.stories.js.map +1 -0
- package/dist/fragments/sidebar/Sidebar.js +75 -0
- package/dist/fragments/sidebar/Sidebar.js.map +1 -0
- package/dist/fragments/sidebar/{Sidebar.stories.jsx → Sidebar.stories.js} +19 -15
- package/dist/fragments/sidebar/Sidebar.stories.js.map +1 -0
- package/dist/hooks/breakpoints.js +1 -0
- package/dist/hooks/breakpoints.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +1 -1
- package/dist/components/color-input/ColorInput.jsx +0 -26
- package/dist/components/color-selector/ColorSelector.jsx +0 -22
- package/dist/fragments/shell/Shell.jsx +0 -10
- package/dist/fragments/shell/Shell.stories.jsx +0 -170
- package/dist/fragments/sidebar/Sidebar.jsx +0 -129
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Avatar, Input } from '@nextui-org/react';
|
|
4
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
5
|
+
export const ColorInput = ({ defaultValue, label = 'Color', errorMessage = "Please enter a valid color in hex format e.g. #f3f or #ff33ff", onValueChange, isInvalid, ...rest }) => {
|
|
6
|
+
const [value, setValue] = useState(defaultValue || '#7d7d7d');
|
|
7
|
+
useEffect(() => onValueChange && onValueChange(value), [value, onValueChange]);
|
|
8
|
+
const validateHexColor = (value) => value.match(/^#(?:[0-9a-fA-F]{3}){1,2}$/i);
|
|
9
|
+
const invalid = useMemo(() => {
|
|
10
|
+
if (value === "")
|
|
11
|
+
return false;
|
|
12
|
+
return validateHexColor(value) && !isInvalid ? false : true;
|
|
13
|
+
}, [value, isInvalid]);
|
|
14
|
+
return (_jsx(Input, { ...rest, label: label, type: "text", value: value, onValueChange: setValue, isInvalid: invalid, errorMessage: invalid && errorMessage, endContent: (_jsx(Avatar, { as: "button", size: "sm", showFallback: true, fallback: _jsx("input", { type: 'color', className: "w-full h-full opacity-0 cursor-pointer", onChange: (e) => setValue(e.currentTarget.value) }), style: { backgroundColor: value }, classNames: { base: 'shrink-0', fallback: 'w-full h-full' } })) }));
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=ColorInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorInput.js","sourceRoot":"","sources":["../../../src/components/color-input/ColorInput.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQrD,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,EACpD,YAAY,EACZ,KAAK,GAAG,OAAO,EACf,YAAY,GAAG,+DAA+D,EAC9E,aAAa,EACb,SAAS,EACT,GAAG,IAAI,EACR,EAAE,EAAE;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,YAAY,IAAI,SAAS,CAAC,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE,CAAC,a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E,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qGAAqG;AACrG,MAAM,IAAI,GAA4B;IACpC,KAAK,EAAE,uBAAuB;IAC9B,SAAS,EAAE,UAAU;IACrB,IAAI,EAAE,CAAC,UAAU,CAAC;CACnB,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,8FAA8F;AAC9F,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,IAAI,EAAE;QACJ,aAAa,EAAE,OAAO,CAAC,GAAG;KAC3B;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Avatar } from '@nextui-org/react';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
export const ColorSelector = ({ values, defaultValue, onValueChange, icon, ...rest }) => {
|
|
6
|
+
const [value, setValue] = useState(defaultValue && values.includes(defaultValue) ? defaultValue : values[0]);
|
|
7
|
+
useEffect(() => onValueChange(value), [value, onValueChange]);
|
|
8
|
+
return (_jsx("div", { className: 'flex gap-4', children: values.map((color) => (_jsx(Avatar, { as: "button", showFallback: true, fallback: value === color && icon ? icon : _jsx(_Fragment, {}), style: { backgroundColor: color }, classNames: { base: 'shrink-0' }, isBordered: value === color, onClick: () => setValue(color), ...rest }))) }));
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=ColorSelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSelector.js","sourceRoot":"","sources":["../../../src/components/color-selector/ColorSelector.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,EAAe,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAe5C,MAAM,CAAC,MAAM,aAAa,GAAiC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE;IACpH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,YAAY,IAAI,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7G,SAAS,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;IAE9D,OAAO,CACL,cAAK,SAAS,EAAC,YAAY,YACxB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,KAAC,MAAM,IACL,EAAE,EAAC,QAAQ,EACX,YAAY,QACZ,QAAQ,EAAE,KAAK,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAK,EAChD,KAAK,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,EACjC,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAChC,UAAU,EAAE,KAAK,KAAK,KAAK,EAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,KAC1B,IAAI,GACR,CACH,CAAC,GACE,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/components/color-selector/{ColorSelector.stories.jsx → ColorSelector.stories.js}
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { ColorSelector } from "./ColorSelector";
|
|
2
3
|
import { IconCheck } from "@tabler/icons-react";
|
|
3
4
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
|
|
@@ -20,6 +21,7 @@ export const WithIcon = {
|
|
|
20
21
|
values: ['red', 'green', 'blue'],
|
|
21
22
|
onValueChange: console.log,
|
|
22
23
|
color: 'primary',
|
|
23
|
-
icon:
|
|
24
|
+
icon: _jsx(IconCheck, { size: 24, stroke: 1.5 })
|
|
24
25
|
},
|
|
25
26
|
};
|
|
27
|
+
//# sourceMappingURL=ColorSelector.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSelector.stories.js","sourceRoot":"","sources":["../../../src/components/color-selector/ColorSelector.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,qGAAqG;AACrG,MAAM,IAAI,GAA+B;IACvC,KAAK,EAAE,0BAA0B;IACjC,SAAS,EAAE,aAAa;IACxB,IAAI,EAAE,CAAC,UAAU,CAAC;CACnB,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,8FAA8F;AAC9F,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC;QAChC,aAAa,EAAE,OAAO,CAAC,GAAG;QAC1B,KAAK,EAAE,SAAS;KACjB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAU;IAC7B,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC;QAChC,aAAa,EAAE,OAAO,CAAC,GAAG;QAC1B,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,KAAC,SAAS,IAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,GAAI;KAC3C;CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Sidebar } from '../sidebar/Sidebar';
|
|
4
|
+
export const Shell = ({ sidebar, children }) => {
|
|
5
|
+
return (_jsxs("div", { className: `flex min-h-screen`, children: [_jsx(Sidebar, { ...sidebar }), _jsx("main", { className: "flex-1 px-6 lg:px-12 xl:px-20 py-14 max-w-screen-2xl", children: children })] }));
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=Shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Shell.js","sourceRoot":"","sources":["../../../src/fragments/shell/Shell.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,OAAO,EAAgB,MAAM,oBAAoB,CAAC;AAW3D,MAAM,CAAC,MAAM,KAAK,GAAyB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IACnE,OAAO,CACL,eAAK,SAAS,EAAE,mBAAmB,aACjC,KAAC,OAAO,OAAK,OAAO,GAAI,EACxB,eAAM,SAAS,EAAC,sDAAsD,YACnE,QAAQ,GACJ,IACH,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Card, CardBody, Divider, Input, Tab, Table, TableBody, TableCell, TableColumn, TableHeader, TableRow, Tabs, } from "@nextui-org/react";
|
|
3
|
+
import { IconBox, IconBoxMultiple, IconHome, IconMessageCircle, } from "@tabler/icons-react";
|
|
4
|
+
import { Shell } from "./Shell";
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "components/Shell",
|
|
8
|
+
component: Shell,
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: "fullscreen",
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
16
|
+
export const Primary = {
|
|
17
|
+
args: {
|
|
18
|
+
sidebar: {
|
|
19
|
+
items: [
|
|
20
|
+
{
|
|
21
|
+
type: "user",
|
|
22
|
+
key: "user",
|
|
23
|
+
name: "Tony Reichert",
|
|
24
|
+
description: "ACME Inc.",
|
|
25
|
+
avatar: {
|
|
26
|
+
src: "https://i.pravatar.cc/150?u=a042581f4e29026024d",
|
|
27
|
+
},
|
|
28
|
+
dropdownItems: [
|
|
29
|
+
{
|
|
30
|
+
label: "My Profile",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "Settings",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: "Organization Settings",
|
|
37
|
+
showDivider: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: "Logout",
|
|
41
|
+
color: "danger",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "custom",
|
|
47
|
+
key: "search",
|
|
48
|
+
render: _jsx(Input, { label: "Search..." }),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "navigation",
|
|
52
|
+
key: "navigation-overview",
|
|
53
|
+
label: "Overview",
|
|
54
|
+
navigation: [
|
|
55
|
+
{
|
|
56
|
+
label: "Home",
|
|
57
|
+
link: "/",
|
|
58
|
+
icon: _jsx(IconHome, { stroke: 1.5 }),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: "My Projects",
|
|
62
|
+
link: "/projects",
|
|
63
|
+
icon: _jsx(IconBoxMultiple, { stroke: 1.5 }),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
label: "Chat",
|
|
67
|
+
link: "/chat",
|
|
68
|
+
icon: _jsx(IconMessageCircle, { stroke: 1.5 }),
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: "navigation",
|
|
74
|
+
key: "navigation-projects",
|
|
75
|
+
label: "Projects",
|
|
76
|
+
navigation: [
|
|
77
|
+
{
|
|
78
|
+
label: "Project 1",
|
|
79
|
+
link: "/projects/1",
|
|
80
|
+
icon: _jsx(IconBox, { stroke: 1.5 }),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: "Project 2",
|
|
84
|
+
link: "/projects/2",
|
|
85
|
+
icon: _jsx(IconBox, { stroke: 1.5 }),
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: "Project 3",
|
|
89
|
+
link: "/projects/3",
|
|
90
|
+
icon: _jsx(IconBox, { stroke: 1.5 }),
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: "custom",
|
|
96
|
+
key: "bottom-banner",
|
|
97
|
+
render: (_jsx(Card, { radius: "lg", className: "border-none", children: _jsx("img", { alt: "Woman listing to music", className: "object-cover w-full", height: 200, src: "https://nextui.org/images/hero-card.jpeg", width: 200 }) })),
|
|
98
|
+
align: "bottom",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
children: "CONTENT",
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
export const Collapsed = {
|
|
106
|
+
args: {
|
|
107
|
+
...Primary.args,
|
|
108
|
+
sidebar: Primary.args?.sidebar ? {
|
|
109
|
+
...Primary.args.sidebar,
|
|
110
|
+
layout: "collapsed",
|
|
111
|
+
} : undefined,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
export const Auto = {
|
|
115
|
+
args: {
|
|
116
|
+
...Primary.args,
|
|
117
|
+
sidebar: Primary.args?.sidebar ? {
|
|
118
|
+
...Primary.args.sidebar,
|
|
119
|
+
autoLayout: true,
|
|
120
|
+
} : undefined,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
export const WithTable = {
|
|
124
|
+
args: {
|
|
125
|
+
...Primary.args,
|
|
126
|
+
children: (_jsxs(_Fragment, { children: [_jsx("h1", { children: "Customers" }), _jsx("p", { className: "mt-2 text-foreground-500", children: "Blablabla" }), _jsx(Divider, { className: "my-4" }), _jsxs(Tabs, { "aria-label": "Options", children: [_jsx(Tab, { title: "Table", children: _jsxs(Table, { "aria-label": "Example static collection table", selectionMode: "multiple", removeWrapper: true, children: [_jsxs(TableHeader, { children: [_jsx(TableColumn, { children: "NAME" }), _jsx(TableColumn, { children: "ROLE" }), _jsx(TableColumn, { children: "STATUS" })] }), _jsxs(TableBody, { children: [_jsxs(TableRow, { children: [_jsx(TableCell, { children: "Tony Reichert" }), _jsx(TableCell, { children: "CEO" }), _jsx(TableCell, { children: "Active" })] }, "1"), _jsxs(TableRow, { children: [_jsx(TableCell, { children: "Zoey Lang" }), _jsx(TableCell, { children: "Technical Lead" }), _jsx(TableCell, { children: "Paused" })] }, "2"), _jsxs(TableRow, { children: [_jsx(TableCell, { children: "Jane Fisher" }), _jsx(TableCell, { children: "Senior Developer" }), _jsx(TableCell, { children: "Active" })] }, "3"), _jsxs(TableRow, { children: [_jsx(TableCell, { children: "William Howard" }), _jsx(TableCell, { children: "Community Manager" }), _jsx(TableCell, { children: "Vacation" })] }, "4")] })] }) }, "table"), _jsx(Tab, { title: "Music", children: _jsx(Card, { children: _jsx(CardBody, { children: "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." }) }) }, "music"), _jsx(Tab, { title: "Videos", children: _jsx(Card, { children: _jsx(CardBody, { children: "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." }) }) }, "videos")] })] })),
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=Shell.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Shell.stories.js","sourceRoot":"","sources":["../../../src/fragments/shell/Shell.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,KAAK,EACL,GAAG,EACH,KAAK,EACL,SAAS,EACT,SAAS,EACT,WAA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C,SAAS,yBAAmB,KAHjB,GAAG,CAIN,EACX,MAAC,QAAQ,eACP,KAAC,SAAS,iCAA2B,EACrC,KAAC,SAAS,oCAA8B,EACxC,KAAC,SAAS,2BAAqB,KAHnB,GAAG,CAIN,IACD,IACN,IAjCD,OAAO,CAkCV,EACN,KAAC,GAAG,IAAa,KAAK,EAAC,OAAO,YAC5B,KAAC,IAAI,cACH,KAAC,QAAQ,qOAKE,GACN,IARA,OAAO,CASV,EACN,KAAC,GAAG,IAAc,KAAK,EAAC,QAAQ,YAC9B,KAAC,IAAI,cACH,KAAC,QAAQ,iIAGE,GACN,IANA,QAAQ,CAOX,IACD,IACN,CACJ;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Avatar, Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, Listbox, ListboxItem, ListboxSection, ScrollShadow, Tooltip, User, } from '@nextui-org/react';
|
|
4
|
+
import { useSmaller } from '../../hooks/breakpoints';
|
|
5
|
+
import { IconChevronLeft } from '@tabler/icons-react';
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
7
|
+
const getAlignmentClasses = (align) => {
|
|
8
|
+
switch (align) {
|
|
9
|
+
case 'center':
|
|
10
|
+
return 'my-auto';
|
|
11
|
+
case 'bottom':
|
|
12
|
+
return 'mt-auto sticky bottom-0 bg-content1';
|
|
13
|
+
default:
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const renderItems = (item, options) => {
|
|
18
|
+
switch (item.type) {
|
|
19
|
+
case 'navigation':
|
|
20
|
+
return options.layout === 'expanded' ? (_jsx(Listbox, { variant: "flat", "aria-label": "Listbox menu with sections", itemClasses: {
|
|
21
|
+
base: 'h-12 gap-6',
|
|
22
|
+
}, ...item.listboxProps, children: _jsx(ListboxSection, { title: item.label, classNames: { group: 'flex flex-col gap-1' }, children: item.navigation.map((navItem) => (_jsx(ListboxItem, { startContent: navItem.icon, endContent: navItem.endContent, href: navItem.link, className: options.activeNav?.link === navItem.link ? "bg-default/40 text-default-foreground" : '', children: navItem.label }, navItem.label))) }) })) : (_jsx("nav", { className: "flex flex-col gap-1", children: item.navigation.map((navItem) => (_jsx(Tooltip, { placement: "right", content: navItem.label, children: _jsx(Button, { variant: options.activeNav?.link === navItem.link ? 'flat' : 'light', size: "lg", as: "a", startContent: navItem.icon, href: navItem.link, isIconOnly: true }) }, navItem.label))) }));
|
|
23
|
+
case 'user':
|
|
24
|
+
return (_jsxs(Dropdown, { placement: "bottom-start", classNames: { trigger: options.layout === 'expanded' ? 'justify-start px-2' : 'justify-start' }, ...item.dropdown, children: [_jsx(DropdownTrigger, { children: options.layout === 'expanded' ? (_jsx(User, { as: "button", avatarProps: item.avatar, className: "transition-transform", description: item.description, name: item.name })) : (_jsx(Avatar, { as: "button", className: "transition-transform", ...item.avatar })) }), _jsx(DropdownMenu, { "aria-label": "User Actions", color: "primary", variant: "flat", items: item.dropdownItems || [], children: (dropdownItem) => (_jsx(DropdownItem, { ...dropdownItem, children: dropdownItem.label }, dropdownItem.label)) })] }));
|
|
25
|
+
case 'custom':
|
|
26
|
+
return options.layout === 'expanded' || item.showCollapsed ? _jsx("div", { className: "px-2", children: item.render }) : null;
|
|
27
|
+
default:
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const getActiveNav = (currentPath, items) => {
|
|
32
|
+
if (!currentPath)
|
|
33
|
+
return;
|
|
34
|
+
const navigations = [];
|
|
35
|
+
items.forEach((item) => {
|
|
36
|
+
if (item.type !== 'navigation')
|
|
37
|
+
return;
|
|
38
|
+
navigations.push(item.navigation);
|
|
39
|
+
});
|
|
40
|
+
const possibleMatches = navigations.flat().filter((navItem) => navItem.link.startsWith(currentPath)).sort((a, b) => b.link.length - a.link.length);
|
|
41
|
+
return possibleMatches.find((pMatch) => pMatch.link === currentPath) || possibleMatches[0];
|
|
42
|
+
};
|
|
43
|
+
export const Sidebar = ({ items, layout = 'expanded', autoLayout, currentPath }) => {
|
|
44
|
+
const isMobile = useSmaller('xl');
|
|
45
|
+
const [activeNav, setActiveNav] = useState(getActiveNav(currentPath, items));
|
|
46
|
+
useEffect(() => setActiveNav(getActiveNav(currentPath, items)), [currentPath, items]);
|
|
47
|
+
let renderedLayout = autoLayout ? undefined : layout;
|
|
48
|
+
if (autoLayout) {
|
|
49
|
+
if (isMobile) {
|
|
50
|
+
renderedLayout = 'collapsed';
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
renderedLayout = 'expanded';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const [collapsed, setCollapsed] = useState(renderedLayout === 'collapsed');
|
|
57
|
+
useEffect(() => { if (autoLayout)
|
|
58
|
+
setCollapsed(isMobile); }, [isMobile, setCollapsed, autoLayout]);
|
|
59
|
+
const layoutStyles = collapsed ? 'w-20 opacity-0 pointer-events-none' : 'w-72';
|
|
60
|
+
const collapseButtonStyles = collapsed ? 'left-20 translate-x-1/2 rotate-180' : 'left-72 -translate-x-1/2';
|
|
61
|
+
return (_jsxs("div", { className: 'flex border-r-[1px] border-default-100', children: [_jsxs("div", { className: `fixed top-0 left-0 flex flex-col h-screen bg-content1 gap-8 transition-all ${collapsed ? '' : 'opacity-0'}`, children: [_jsx(ScrollShadow, { className: `w-20 items-center flex flex-col gap-8 px-3 pt-8 overflow-y-auto flex-1`, children: items.map((item) => {
|
|
62
|
+
const children = item.align !== 'bottom' ? renderItems(item, { layout: 'collapsed', activeNav }) : null;
|
|
63
|
+
return children ? (_jsx("div", { className: getAlignmentClasses(item.align), children: children }, item.key)) : null;
|
|
64
|
+
}) }), _jsx("div", { className: `w-20 items-center flex flex-col gap-8 px-3 pb-8`, children: items.map((item) => {
|
|
65
|
+
const children = item.align === 'bottom' ? renderItems(item, { layout: 'collapsed', activeNav }) : null;
|
|
66
|
+
return children ? (_jsx("div", { className: getAlignmentClasses(item.align), children: children }, item.key)) : null;
|
|
67
|
+
}) })] }), _jsxs("div", { className: `${layoutStyles} fixed top-0 left-0 flex flex-col h-screen bg-content1 gap-8 overflow-hidden transition-all`, children: [_jsx(ScrollShadow, { className: `w-72 flex flex-col gap-8 px-3 pt-8 overflow-y-auto flex-1`, children: items.map((item) => {
|
|
68
|
+
const children = item.align !== 'bottom' ? renderItems(item, { layout: 'expanded', activeNav }) : null;
|
|
69
|
+
return children ? (_jsx("div", { className: getAlignmentClasses(item.align), children: children }, item.key)) : null;
|
|
70
|
+
}) }), _jsx("div", { className: `w-72 flex flex-col gap-8 px-3 pb-8`, children: items.map((item) => {
|
|
71
|
+
const children = item.align === 'bottom' ? renderItems(item, { layout: 'expanded', activeNav }) : null;
|
|
72
|
+
return children ? (_jsx("div", { className: getAlignmentClasses(item.align), children: children }, item.key)) : null;
|
|
73
|
+
}) })] }), _jsx("div", { className: `${layoutStyles} transition-all h-screen` }), _jsx("div", { className: `fixed top-6 transition-all ${collapseButtonStyles}`, children: _jsx(Button, { size: "sm", isIconOnly: true, radius: "full", className: "h-unit-6 w-unit-6 min-w-unit-6 bg-default-100", onClick: () => setCollapsed(!collapsed), children: _jsx(IconChevronLeft, { size: 14 }) }) })] }));
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=Sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sidebar.js","sourceRoot":"","sources":["../../../src/fragments/sidebar/Sidebar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,MAAM,EAEN,MAAM,EACN,QAAQ,EACR,YAAY,EAEZ,YAAY,EAEZ,eAAe,EACf,OAAO,EACP,WAAW,EAEX,cAAc,EACd,YAAY,EACZ,OAAO,EACP,IAAI,GACL,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,M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AAC,IAAI,CAAC,KAAK,CAAC,YAC3D,QAAQ,IADD,IAAI,CAAC,GAAG,CAEZ,CACP,CAAC,CAAC,CAAC,IAAI,CAAC;wBACX,CAAC,CAAC,GACW,EACf,cAAK,SAAS,EAAE,oCAAoC,YACjD,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;4BAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;4BACvG,OAAO,QAAQ,CAAC,CAAC,CAAC,CAChB,cAAoB,SAAS,EAAE,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,YAC3D,QAAQ,IADD,IAAI,CAAC,GAAG,CAEZ,CACP,CAAC,CAAC,CAAC,IAAI,CAAC;wBACX,CAAC,CAAC,GACE,IACF,EACN,cAAK,SAAS,EAAE,GAAG,YAAY,0BAA0B,GAAI,EAC7D,cAAK,SAAS,EAAE,8BAA8B,oBAAoB,EAAE,YAClE,KAAC,MAAM,IAAC,IAAI,EAAC,IAAI,EAAC,UAAU,QAAC,MAAM,EAAC,MAAM,EAAC,SAAS,EAAC,+CAA+C,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,YAC1I,KAAC,eAAe,IAAC,IAAI,EAAE,EAAE,GAAI,GACtB,GACL,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { Button, Card, Input } from "@nextui-org/react";
|
|
2
3
|
import { IconBox, IconBoxMultiple, IconCirclePlus, IconHome, IconMessageCircle, } from "@tabler/icons-react";
|
|
3
4
|
import { Sidebar } from "./Sidebar";
|
|
@@ -44,7 +45,7 @@ export const Primary = {
|
|
|
44
45
|
{
|
|
45
46
|
type: "custom",
|
|
46
47
|
key: "search",
|
|
47
|
-
render:
|
|
48
|
+
render: _jsx(Input, { label: "Search..." }),
|
|
48
49
|
},
|
|
49
50
|
{
|
|
50
51
|
type: "navigation",
|
|
@@ -54,15 +55,13 @@ export const Primary = {
|
|
|
54
55
|
{
|
|
55
56
|
label: "Home",
|
|
56
57
|
link: "/",
|
|
57
|
-
icon:
|
|
58
|
+
icon: _jsx(IconHome, { stroke: 1.5 }),
|
|
58
59
|
},
|
|
59
60
|
{
|
|
60
61
|
label: "My Projects",
|
|
61
62
|
link: "/projects",
|
|
62
|
-
icon:
|
|
63
|
-
endContent: (
|
|
64
|
-
<IconCirclePlus size={18}/>
|
|
65
|
-
</Button>),
|
|
63
|
+
icon: _jsx(IconBoxMultiple, { stroke: 1.5 }),
|
|
64
|
+
endContent: (_jsx(Button, { size: "sm", variant: "light", isIconOnly: true, children: _jsx(IconCirclePlus, { size: 18 }) })),
|
|
66
65
|
items: [
|
|
67
66
|
{
|
|
68
67
|
type: "navigation",
|
|
@@ -87,7 +86,7 @@ export const Primary = {
|
|
|
87
86
|
{
|
|
88
87
|
label: "Chat",
|
|
89
88
|
link: "/chat",
|
|
90
|
-
icon:
|
|
89
|
+
icon: _jsx(IconMessageCircle, { stroke: 1.5 }),
|
|
91
90
|
},
|
|
92
91
|
],
|
|
93
92
|
},
|
|
@@ -99,34 +98,39 @@ export const Primary = {
|
|
|
99
98
|
{
|
|
100
99
|
label: "Project 1",
|
|
101
100
|
link: "/projects/1",
|
|
102
|
-
icon:
|
|
101
|
+
icon: _jsx(IconBox, { stroke: 1.5 }),
|
|
103
102
|
},
|
|
104
103
|
{
|
|
105
104
|
label: "Project 2",
|
|
106
105
|
link: "/projects/2",
|
|
107
|
-
icon:
|
|
106
|
+
icon: _jsx(IconBox, { stroke: 1.5 }),
|
|
108
107
|
},
|
|
109
108
|
{
|
|
110
109
|
label: "Project 3",
|
|
111
110
|
link: "/projects/3",
|
|
112
|
-
icon:
|
|
111
|
+
icon: _jsx(IconBox, { stroke: 1.5 }),
|
|
113
112
|
},
|
|
114
113
|
],
|
|
115
114
|
},
|
|
116
115
|
{
|
|
117
116
|
type: "custom",
|
|
118
117
|
key: "bottom-banner",
|
|
119
|
-
render: (
|
|
120
|
-
<img alt="Woman listing to music" className="object-cover w-full" height={200} src="https://nextui.org/images/hero-card.jpeg" width={200}/>
|
|
121
|
-
</Card>),
|
|
118
|
+
render: (_jsx(Card, { radius: "lg", className: "border-none", children: _jsx("img", { alt: "Woman listing to music", className: "object-cover w-full", height: 200, src: "https://nextui.org/images/hero-card.jpeg", width: 200 }) })),
|
|
122
119
|
align: "bottom",
|
|
123
120
|
},
|
|
124
121
|
],
|
|
125
122
|
},
|
|
126
123
|
};
|
|
127
124
|
export const Collapsed = {
|
|
128
|
-
args:
|
|
125
|
+
args: {
|
|
126
|
+
...Primary.args,
|
|
127
|
+
layout: "collapsed",
|
|
128
|
+
},
|
|
129
129
|
};
|
|
130
130
|
export const Auto = {
|
|
131
|
-
args:
|
|
131
|
+
args: {
|
|
132
|
+
...Primary.args,
|
|
133
|
+
autoLayout: true,
|
|
134
|
+
},
|
|
132
135
|
};
|
|
136
|
+
//# sourceMappingURL=Sidebar.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sidebar.stories.js","sourceRoot":"","sources":["../../../src/fragments/sidebar/Sidebar.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EACL,OAAO,EACP,eAAe,EACf,cAAc,EACd,QAAQ,EACR,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,qGAAqG;AACrG,MAAM,IAAI,GAAyB;IACjC,KAAK,EAAE,oBAAoB;IAC3B,SAAS,EAAE,OAAO;IAClB,sBAAsB;IACtB,UA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AAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAU;IAC9B,IAAI,EAAE;QACJ,GAAG,OAAO,CAAC,IAAI;QACf,MAAM,EAAE,WAAW;KACpB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAU;IACzB,IAAI,EAAE;QACJ,GAAG,OAAO,CAAC,IAAI;QACf,UAAU,EAAE,IAAI;KACjB;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breakpoints.js","sourceRoot":"","sources":["../../src/hooks/breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEjF,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from '@nextui-org/react';
|
|
2
2
|
export * from './components/color-input/ColorInput';
|
|
3
|
+
export * from './components/color-selector/ColorSelector';
|
|
3
4
|
export * from './fragments/shell/Shell';
|
|
4
5
|
export * from './fragments/sidebar/Sidebar';
|
|
6
|
+
export * from './hooks/breakpoints';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from '@nextui-org/react';
|
|
2
2
|
export * from './components/color-input/ColorInput';
|
|
3
|
+
export * from './components/color-selector/ColorSelector';
|
|
3
4
|
export * from './fragments/shell/Shell';
|
|
4
5
|
export * from './fragments/sidebar/Sidebar';
|
|
6
|
+
export * from './hooks/breakpoints';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAElC,cAAc,qCAAqC,CAAC;AACpD,cAAc,2CAA2C,CAAC;AAE1D,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
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
|
-
import { Avatar, Input } from '@nextui-org/react';
|
|
14
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
15
|
-
export const ColorInput = (_a) => {
|
|
16
|
-
var { defaultValue, label = 'Color', errorMessage = "Please enter a valid color in hex format e.g. #f3f or #ff33ff", onValueChange, isInvalid } = _a, rest = __rest(_a, ["defaultValue", "label", "errorMessage", "onValueChange", "isInvalid"]);
|
|
17
|
-
const [value, setValue] = useState(defaultValue || '#7d7d7d');
|
|
18
|
-
useEffect(() => onValueChange && onValueChange(value), [value, onValueChange]);
|
|
19
|
-
const validateHexColor = (value) => value.match(/^#(?:[0-9a-fA-F]{3}){1,2}$/i);
|
|
20
|
-
const invalid = useMemo(() => {
|
|
21
|
-
if (value === "")
|
|
22
|
-
return false;
|
|
23
|
-
return validateHexColor(value) && !isInvalid ? false : true;
|
|
24
|
-
}, [value, isInvalid]);
|
|
25
|
-
return (<Input {...rest} label={label} type="text" value={value} onValueChange={setValue} isInvalid={invalid} errorMessage={invalid && errorMessage} endContent={(<Avatar as="button" size="sm" showFallback fallback={<input type='color' className="w-full h-full opacity-0 cursor-pointer" onChange={(e) => setValue(e.currentTarget.value)}/>} style={{ backgroundColor: value }} classNames={{ base: 'shrink-0', fallback: 'w-full h-full' }}/>)}/>);
|
|
26
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
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
|
-
import { Avatar } from '@nextui-org/react';
|
|
14
|
-
import { useEffect, useState } from 'react';
|
|
15
|
-
export const ColorSelector = (_a) => {
|
|
16
|
-
var { values, defaultValue, onValueChange, icon } = _a, rest = __rest(_a, ["values", "defaultValue", "onValueChange", "icon"]);
|
|
17
|
-
const [value, setValue] = useState(defaultValue && values.includes(defaultValue) ? defaultValue : values[0]);
|
|
18
|
-
useEffect(() => onValueChange(value), [value, onValueChange]);
|
|
19
|
-
return (<div className='flex gap-4'>
|
|
20
|
-
{values.map((color) => (<Avatar as="button" showFallback fallback={value === color && icon ? icon : <></>} style={{ backgroundColor: color }} classNames={{ base: 'shrink-0' }} isBordered={value === color} onClick={() => setValue(color)} {...rest}/>))}
|
|
21
|
-
</div>);
|
|
22
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { Sidebar } from '../sidebar/Sidebar';
|
|
3
|
-
export const Shell = ({ sidebar, children }) => {
|
|
4
|
-
return (<div className={`flex min-h-screen`}>
|
|
5
|
-
<Sidebar {...sidebar}/>
|
|
6
|
-
<main className="flex-1 px-6 lg:px-12 xl:px-20 py-14 max-w-screen-2xl">
|
|
7
|
-
{children}
|
|
8
|
-
</main>
|
|
9
|
-
</div>);
|
|
10
|
-
};
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
var _a, _b;
|
|
2
|
-
import { Card, CardBody, Divider, Input, Tab, Table, TableBody, TableCell, TableColumn, TableHeader, TableRow, Tabs, } from "@nextui-org/react";
|
|
3
|
-
import { IconBox, IconBoxMultiple, IconHome, IconMessageCircle, } from "@tabler/icons-react";
|
|
4
|
-
import { Shell } from "./Shell";
|
|
5
|
-
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
|
|
6
|
-
const meta = {
|
|
7
|
-
title: "components/Shell",
|
|
8
|
-
component: Shell,
|
|
9
|
-
tags: ["autodocs"],
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: "fullscreen",
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
export default meta;
|
|
15
|
-
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
16
|
-
export const Primary = {
|
|
17
|
-
args: {
|
|
18
|
-
sidebar: {
|
|
19
|
-
items: [
|
|
20
|
-
{
|
|
21
|
-
type: "user",
|
|
22
|
-
key: "user",
|
|
23
|
-
name: "Tony Reichert",
|
|
24
|
-
description: "ACME Inc.",
|
|
25
|
-
avatar: {
|
|
26
|
-
src: "https://i.pravatar.cc/150?u=a042581f4e29026024d",
|
|
27
|
-
},
|
|
28
|
-
dropdownItems: [
|
|
29
|
-
{
|
|
30
|
-
label: "My Profile",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
label: "Settings",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
label: "Organization Settings",
|
|
37
|
-
showDivider: true,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
label: "Logout",
|
|
41
|
-
color: "danger",
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
type: "custom",
|
|
47
|
-
key: "search",
|
|
48
|
-
render: <Input label="Search..."/>,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
type: "navigation",
|
|
52
|
-
key: "navigation-overview",
|
|
53
|
-
label: "Overview",
|
|
54
|
-
navigation: [
|
|
55
|
-
{
|
|
56
|
-
label: "Home",
|
|
57
|
-
link: "/",
|
|
58
|
-
icon: <IconHome stroke={1.5}/>,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
label: "My Projects",
|
|
62
|
-
link: "/projects",
|
|
63
|
-
icon: <IconBoxMultiple stroke={1.5}/>,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
label: "Chat",
|
|
67
|
-
link: "/chat",
|
|
68
|
-
icon: <IconMessageCircle stroke={1.5}/>,
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
type: "navigation",
|
|
74
|
-
key: "navigation-projects",
|
|
75
|
-
label: "Projects",
|
|
76
|
-
navigation: [
|
|
77
|
-
{
|
|
78
|
-
label: "Project 1",
|
|
79
|
-
link: "/projects/1",
|
|
80
|
-
icon: <IconBox stroke={1.5}/>,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
label: "Project 2",
|
|
84
|
-
link: "/projects/2",
|
|
85
|
-
icon: <IconBox stroke={1.5}/>,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
label: "Project 3",
|
|
89
|
-
link: "/projects/3",
|
|
90
|
-
icon: <IconBox stroke={1.5}/>,
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
type: "custom",
|
|
96
|
-
key: "bottom-banner",
|
|
97
|
-
render: (<Card radius="lg" className="border-none">
|
|
98
|
-
<img alt="Woman listing to music" className="object-cover w-full" height={200} src="https://nextui.org/images/hero-card.jpeg" width={200}/>
|
|
99
|
-
</Card>),
|
|
100
|
-
align: "bottom",
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
},
|
|
104
|
-
children: "CONTENT",
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
export const Collapsed = {
|
|
108
|
-
args: Object.assign(Object.assign({}, Primary.args), { sidebar: ((_a = Primary.args) === null || _a === void 0 ? void 0 : _a.sidebar) ? Object.assign(Object.assign({}, Primary.args.sidebar), { layout: "collapsed" }) : undefined }),
|
|
109
|
-
};
|
|
110
|
-
export const Auto = {
|
|
111
|
-
args: Object.assign(Object.assign({}, Primary.args), { sidebar: ((_b = Primary.args) === null || _b === void 0 ? void 0 : _b.sidebar) ? Object.assign(Object.assign({}, Primary.args.sidebar), { autoLayout: true }) : undefined }),
|
|
112
|
-
};
|
|
113
|
-
export const WithTable = {
|
|
114
|
-
args: Object.assign(Object.assign({}, Primary.args), { children: (<>
|
|
115
|
-
<h1>Customers</h1>
|
|
116
|
-
<p className="mt-2 text-foreground-500">Blablabla</p>
|
|
117
|
-
<Divider className="my-4"/>
|
|
118
|
-
<Tabs aria-label="Options">
|
|
119
|
-
<Tab key="table" title="Table">
|
|
120
|
-
<Table aria-label="Example static collection table" selectionMode="multiple" removeWrapper>
|
|
121
|
-
<TableHeader>
|
|
122
|
-
<TableColumn>NAME</TableColumn>
|
|
123
|
-
<TableColumn>ROLE</TableColumn>
|
|
124
|
-
<TableColumn>STATUS</TableColumn>
|
|
125
|
-
</TableHeader>
|
|
126
|
-
<TableBody>
|
|
127
|
-
<TableRow key="1">
|
|
128
|
-
<TableCell>Tony Reichert</TableCell>
|
|
129
|
-
<TableCell>CEO</TableCell>
|
|
130
|
-
<TableCell>Active</TableCell>
|
|
131
|
-
</TableRow>
|
|
132
|
-
<TableRow key="2">
|
|
133
|
-
<TableCell>Zoey Lang</TableCell>
|
|
134
|
-
<TableCell>Technical Lead</TableCell>
|
|
135
|
-
<TableCell>Paused</TableCell>
|
|
136
|
-
</TableRow>
|
|
137
|
-
<TableRow key="3">
|
|
138
|
-
<TableCell>Jane Fisher</TableCell>
|
|
139
|
-
<TableCell>Senior Developer</TableCell>
|
|
140
|
-
<TableCell>Active</TableCell>
|
|
141
|
-
</TableRow>
|
|
142
|
-
<TableRow key="4">
|
|
143
|
-
<TableCell>William Howard</TableCell>
|
|
144
|
-
<TableCell>Community Manager</TableCell>
|
|
145
|
-
<TableCell>Vacation</TableCell>
|
|
146
|
-
</TableRow>
|
|
147
|
-
</TableBody>
|
|
148
|
-
</Table>
|
|
149
|
-
</Tab>
|
|
150
|
-
<Tab key="music" title="Music">
|
|
151
|
-
<Card>
|
|
152
|
-
<CardBody>
|
|
153
|
-
Ut enim ad minim veniam, quis nostrud exercitation ullamco
|
|
154
|
-
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
|
|
155
|
-
dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
156
|
-
fugiat nulla pariatur.
|
|
157
|
-
</CardBody>
|
|
158
|
-
</Card>
|
|
159
|
-
</Tab>
|
|
160
|
-
<Tab key="videos" title="Videos">
|
|
161
|
-
<Card>
|
|
162
|
-
<CardBody>
|
|
163
|
-
Excepteur sint occaecat cupidatat non proident, sunt in culpa
|
|
164
|
-
qui officia deserunt mollit anim id est laborum.
|
|
165
|
-
</CardBody>
|
|
166
|
-
</Card>
|
|
167
|
-
</Tab>
|
|
168
|
-
</Tabs>
|
|
169
|
-
</>) }),
|
|
170
|
-
};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { Avatar, Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, Listbox, ListboxItem, ListboxSection, ScrollShadow, Tooltip, User, } from '@nextui-org/react';
|
|
3
|
-
import { useSmaller } from '../../hooks/breakpoints';
|
|
4
|
-
import { IconChevronLeft } from '@tabler/icons-react';
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
6
|
-
const getAlignmentClasses = (align) => {
|
|
7
|
-
switch (align) {
|
|
8
|
-
case 'center':
|
|
9
|
-
return 'my-auto';
|
|
10
|
-
case 'bottom':
|
|
11
|
-
return 'mt-auto sticky bottom-0 bg-content1';
|
|
12
|
-
default:
|
|
13
|
-
return '';
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const renderItems = (item, options) => {
|
|
17
|
-
switch (item.type) {
|
|
18
|
-
case 'navigation':
|
|
19
|
-
return options.layout === 'expanded' ? (<Listbox variant="flat" aria-label="Listbox menu with sections" itemClasses={{
|
|
20
|
-
base: 'h-12 gap-6',
|
|
21
|
-
}} {...item.listboxProps}>
|
|
22
|
-
<ListboxSection title={item.label} classNames={{ group: 'flex flex-col gap-1' }}>
|
|
23
|
-
{item.navigation.map((navItem) => {
|
|
24
|
-
var _a;
|
|
25
|
-
return (<ListboxItem key={navItem.label} startContent={navItem.icon} endContent={navItem.endContent} href={navItem.link} className={((_a = options.activeNav) === null || _a === void 0 ? void 0 : _a.link) === navItem.link ? "bg-default/40 text-default-foreground" : ''}>
|
|
26
|
-
{navItem.label}
|
|
27
|
-
</ListboxItem>);
|
|
28
|
-
})}
|
|
29
|
-
</ListboxSection>
|
|
30
|
-
</Listbox>) : (<nav className="flex flex-col gap-1">
|
|
31
|
-
{item.navigation.map((navItem) => {
|
|
32
|
-
var _a;
|
|
33
|
-
return (<Tooltip key={navItem.label} placement="right" content={navItem.label}>
|
|
34
|
-
<Button variant={((_a = options.activeNav) === null || _a === void 0 ? void 0 : _a.link) === navItem.link ? 'flat' : 'light'} size="lg" as="a" startContent={navItem.icon} href={navItem.link} isIconOnly/>
|
|
35
|
-
</Tooltip>);
|
|
36
|
-
})}
|
|
37
|
-
</nav>);
|
|
38
|
-
case 'user':
|
|
39
|
-
return (<Dropdown placement="bottom-start" classNames={{ trigger: options.layout === 'expanded' ? 'justify-start px-2' : 'justify-start' }} {...item.dropdown}>
|
|
40
|
-
<DropdownTrigger>
|
|
41
|
-
{options.layout === 'expanded' ? (<User as="button" avatarProps={item.avatar} className="transition-transform" description={item.description} name={item.name}/>) : (<Avatar as="button" className="transition-transform" {...item.avatar}/>)}
|
|
42
|
-
</DropdownTrigger>
|
|
43
|
-
<DropdownMenu aria-label="User Actions" color="primary" variant="flat" items={item.dropdownItems || []}>
|
|
44
|
-
{(dropdownItem) => (<DropdownItem key={dropdownItem.label} {...dropdownItem}>
|
|
45
|
-
{dropdownItem.label}
|
|
46
|
-
</DropdownItem>)}
|
|
47
|
-
</DropdownMenu>
|
|
48
|
-
</Dropdown>);
|
|
49
|
-
case 'custom':
|
|
50
|
-
return options.layout === 'expanded' || item.showCollapsed ? <div className="px-2">{item.render}</div> : null;
|
|
51
|
-
default:
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const getActiveNav = (currentPath, items) => {
|
|
56
|
-
if (!currentPath)
|
|
57
|
-
return;
|
|
58
|
-
const navigations = [];
|
|
59
|
-
items.forEach((item) => {
|
|
60
|
-
if (item.type !== 'navigation')
|
|
61
|
-
return;
|
|
62
|
-
navigations.push(item.navigation);
|
|
63
|
-
});
|
|
64
|
-
const possibleMatches = navigations.flat().filter((navItem) => navItem.link.startsWith(currentPath)).sort((a, b) => b.link.length - a.link.length);
|
|
65
|
-
return possibleMatches.find((pMatch) => pMatch.link === currentPath) || possibleMatches[0];
|
|
66
|
-
};
|
|
67
|
-
export const Sidebar = ({ items, layout = 'expanded', autoLayout, currentPath }) => {
|
|
68
|
-
const isMobile = useSmaller('xl');
|
|
69
|
-
const [activeNav, setActiveNav] = useState(getActiveNav(currentPath, items));
|
|
70
|
-
useEffect(() => setActiveNav(getActiveNav(currentPath, items)), [currentPath, items]);
|
|
71
|
-
let renderedLayout = autoLayout ? undefined : layout;
|
|
72
|
-
if (autoLayout) {
|
|
73
|
-
if (isMobile) {
|
|
74
|
-
renderedLayout = 'collapsed';
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
renderedLayout = 'expanded';
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const [collapsed, setCollapsed] = useState(renderedLayout === 'collapsed');
|
|
81
|
-
useEffect(() => { if (autoLayout)
|
|
82
|
-
setCollapsed(isMobile); }, [isMobile, setCollapsed, autoLayout]);
|
|
83
|
-
const layoutStyles = collapsed ? 'w-20 opacity-0 pointer-events-none' : 'w-72';
|
|
84
|
-
const collapseButtonStyles = collapsed ? 'left-20 translate-x-1/2 rotate-180' : 'left-72 -translate-x-1/2';
|
|
85
|
-
return (<div className='flex border-r-[1px] border-default-100'>
|
|
86
|
-
<div className={`fixed top-0 left-0 flex flex-col h-screen bg-content1 gap-8 transition-all ${collapsed ? '' : 'opacity-0'}`}>
|
|
87
|
-
<ScrollShadow className={`w-20 items-center flex flex-col gap-8 px-3 pt-8 overflow-y-auto flex-1`}>
|
|
88
|
-
{items.map((item) => {
|
|
89
|
-
const children = item.align !== 'bottom' ? renderItems(item, { layout: 'collapsed', activeNav }) : null;
|
|
90
|
-
return children ? (<div key={item.key} className={getAlignmentClasses(item.align)}>
|
|
91
|
-
{children}
|
|
92
|
-
</div>) : null;
|
|
93
|
-
})}
|
|
94
|
-
</ScrollShadow>
|
|
95
|
-
<div className={`w-20 items-center flex flex-col gap-8 px-3 pb-8`}>
|
|
96
|
-
{items.map((item) => {
|
|
97
|
-
const children = item.align === 'bottom' ? renderItems(item, { layout: 'collapsed', activeNav }) : null;
|
|
98
|
-
return children ? (<div key={item.key} className={getAlignmentClasses(item.align)}>
|
|
99
|
-
{children}
|
|
100
|
-
</div>) : null;
|
|
101
|
-
})}
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
<div className={`${layoutStyles} fixed top-0 left-0 flex flex-col h-screen bg-content1 gap-8 overflow-hidden transition-all`}>
|
|
105
|
-
<ScrollShadow className={`w-72 flex flex-col gap-8 px-3 pt-8 overflow-y-auto flex-1`}>
|
|
106
|
-
{items.map((item) => {
|
|
107
|
-
const children = item.align !== 'bottom' ? renderItems(item, { layout: 'expanded', activeNav }) : null;
|
|
108
|
-
return children ? (<div key={item.key} className={getAlignmentClasses(item.align)}>
|
|
109
|
-
{children}
|
|
110
|
-
</div>) : null;
|
|
111
|
-
})}
|
|
112
|
-
</ScrollShadow>
|
|
113
|
-
<div className={`w-72 flex flex-col gap-8 px-3 pb-8`}>
|
|
114
|
-
{items.map((item) => {
|
|
115
|
-
const children = item.align === 'bottom' ? renderItems(item, { layout: 'expanded', activeNav }) : null;
|
|
116
|
-
return children ? (<div key={item.key} className={getAlignmentClasses(item.align)}>
|
|
117
|
-
{children}
|
|
118
|
-
</div>) : null;
|
|
119
|
-
})}
|
|
120
|
-
</div>
|
|
121
|
-
</div>
|
|
122
|
-
<div className={`${layoutStyles} transition-all h-screen`}/>
|
|
123
|
-
<div className={`fixed top-6 transition-all ${collapseButtonStyles}`}>
|
|
124
|
-
<Button size="sm" isIconOnly radius="full" className="h-unit-6 w-unit-6 min-w-unit-6 bg-default-100" onClick={() => setCollapsed(!collapsed)}>
|
|
125
|
-
<IconChevronLeft size={14}/>
|
|
126
|
-
</Button>
|
|
127
|
-
</div>
|
|
128
|
-
</div>);
|
|
129
|
-
};
|