@fragment-build/ui 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/LICENSE.md +194 -0
- package/README.md +114 -0
- package/dist/components/color-input/ColorInput.d.ts +9 -0
- package/dist/components/color-input/ColorInput.jsx +26 -0
- package/dist/components/color-input/ColorInput.stories.d.ts +6 -0
- package/dist/components/color-input/ColorInput.stories.jsx +14 -0
- package/dist/components/color-selector/ColorSelector.d.ts +15 -0
- package/dist/components/color-selector/ColorSelector.jsx +22 -0
- package/dist/components/color-selector/ColorSelector.stories.d.ts +7 -0
- package/dist/components/color-selector/ColorSelector.stories.jsx +25 -0
- package/dist/fragments/shell/Shell.d.ts +11 -0
- package/dist/fragments/shell/Shell.jsx +10 -0
- package/dist/fragments/shell/Shell.stories.d.ts +9 -0
- package/dist/fragments/shell/Shell.stories.jsx +170 -0
- package/dist/fragments/sidebar/Sidebar.d.ts +47 -0
- package/dist/fragments/sidebar/Sidebar.jsx +129 -0
- package/dist/fragments/sidebar/Sidebar.stories.d.ts +8 -0
- package/dist/fragments/sidebar/Sidebar.stories.jsx +132 -0
- package/dist/hooks/breakpoints.d.ts +1 -0
- package/dist/hooks/breakpoints.js +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +54 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
==============
|
|
3
|
+
|
|
4
|
+
_Version 2.0, January 2004_
|
|
5
|
+
_<<http://www.apache.org/licenses/>>_
|
|
6
|
+
|
|
7
|
+
### Terms and Conditions for use, reproduction, and distribution
|
|
8
|
+
|
|
9
|
+
#### 1. Definitions
|
|
10
|
+
|
|
11
|
+
“License” shall mean the terms and conditions for use, reproduction, and
|
|
12
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
“Licensor” shall mean the copyright owner or entity authorized by the copyright
|
|
15
|
+
owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
“Legal Entity” shall mean the union of the acting entity and all other entities
|
|
18
|
+
that control, are controlled by, or are under common control with that entity.
|
|
19
|
+
For the purposes of this definition, “control” means **(i)** the power, direct or
|
|
20
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
21
|
+
contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or **(iii)** beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
“You” (or “Your”) shall mean an individual or Legal Entity exercising
|
|
25
|
+
permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
“Source” form shall mean the preferred form for making modifications, including
|
|
28
|
+
but not limited to software source code, documentation source, and configuration
|
|
29
|
+
files.
|
|
30
|
+
|
|
31
|
+
“Object” form shall mean any form resulting from mechanical transformation or
|
|
32
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
33
|
+
generated documentation, and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
“Work” shall mean the work of authorship, whether in Source or Object form, made
|
|
36
|
+
available under the License, as indicated by a copyright notice that is included
|
|
37
|
+
in or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
“Derivative Works” shall mean any work, whether in Source or Object form, that
|
|
40
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
41
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
42
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
43
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
44
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
45
|
+
|
|
46
|
+
“Contribution” shall mean any work of authorship, including the original version
|
|
47
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
48
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
49
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
50
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
|
51
|
+
“submitted” means any form of electronic, verbal, or written communication sent
|
|
52
|
+
to the Licensor or its representatives, including but not limited to
|
|
53
|
+
communication on electronic mailing lists, source code control systems, and
|
|
54
|
+
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
|
55
|
+
the purpose of discussing and improving the Work, but excluding communication
|
|
56
|
+
that is conspicuously marked or otherwise designated in writing by the copyright
|
|
57
|
+
owner as “Not a Contribution.”
|
|
58
|
+
|
|
59
|
+
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
|
|
60
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
61
|
+
incorporated within the Work.
|
|
62
|
+
|
|
63
|
+
#### 2. Grant of Copyright License
|
|
64
|
+
|
|
65
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
66
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
67
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
68
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
69
|
+
Derivative Works in Source or Object form.
|
|
70
|
+
|
|
71
|
+
#### 3. Grant of Patent License
|
|
72
|
+
|
|
73
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
74
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
75
|
+
irrevocable (except as stated in this section) patent license to make, have
|
|
76
|
+
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
|
77
|
+
such license applies only to those patent claims licensable by such Contributor
|
|
78
|
+
that are necessarily infringed by their Contribution(s) alone or by combination
|
|
79
|
+
of their Contribution(s) with the Work to which such Contribution(s) was
|
|
80
|
+
submitted. If You institute patent litigation against any entity (including a
|
|
81
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
|
82
|
+
Contribution incorporated within the Work constitutes direct or contributory
|
|
83
|
+
patent infringement, then any patent licenses granted to You under this License
|
|
84
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
85
|
+
|
|
86
|
+
#### 4. Redistribution
|
|
87
|
+
|
|
88
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
89
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
90
|
+
provided that You meet the following conditions:
|
|
91
|
+
|
|
92
|
+
* **(a)** You must give any other recipients of the Work or Derivative Works a copy of
|
|
93
|
+
this License; and
|
|
94
|
+
* **(b)** You must cause any modified files to carry prominent notices stating that You
|
|
95
|
+
changed the files; and
|
|
96
|
+
* **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
|
|
97
|
+
all copyright, patent, trademark, and attribution notices from the Source form
|
|
98
|
+
of the Work, excluding those notices that do not pertain to any part of the
|
|
99
|
+
Derivative Works; and
|
|
100
|
+
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
|
|
101
|
+
Derivative Works that You distribute must include a readable copy of the
|
|
102
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
103
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
104
|
+
following places: within a NOTICE text file distributed as part of the
|
|
105
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
106
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
107
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
108
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
109
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
110
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
111
|
+
provided that such additional attribution notices cannot be construed as
|
|
112
|
+
modifying the License.
|
|
113
|
+
|
|
114
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
115
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
116
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
117
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
118
|
+
with the conditions stated in this License.
|
|
119
|
+
|
|
120
|
+
#### 5. Submission of Contributions
|
|
121
|
+
|
|
122
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
123
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
124
|
+
conditions of this License, without any additional terms or conditions.
|
|
125
|
+
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
|
126
|
+
any separate license agreement you may have executed with Licensor regarding
|
|
127
|
+
such Contributions.
|
|
128
|
+
|
|
129
|
+
#### 6. Trademarks
|
|
130
|
+
|
|
131
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
132
|
+
service marks, or product names of the Licensor, except as required for
|
|
133
|
+
reasonable and customary use in describing the origin of the Work and
|
|
134
|
+
reproducing the content of the NOTICE file.
|
|
135
|
+
|
|
136
|
+
#### 7. Disclaimer of Warranty
|
|
137
|
+
|
|
138
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
139
|
+
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
|
|
140
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
141
|
+
including, without limitation, any warranties or conditions of TITLE,
|
|
142
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
|
143
|
+
solely responsible for determining the appropriateness of using or
|
|
144
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
|
145
|
+
permissions under this License.
|
|
146
|
+
|
|
147
|
+
#### 8. Limitation of Liability
|
|
148
|
+
|
|
149
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
150
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
151
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
152
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
153
|
+
or consequential damages of any character arising as a result of this License or
|
|
154
|
+
out of the use or inability to use the Work (including but not limited to
|
|
155
|
+
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
|
156
|
+
any and all other commercial damages or losses), even if such Contributor has
|
|
157
|
+
been advised of the possibility of such damages.
|
|
158
|
+
|
|
159
|
+
#### 9. Accepting Warranty or Additional Liability
|
|
160
|
+
|
|
161
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
162
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
163
|
+
other liability obligations and/or rights consistent with this License. However,
|
|
164
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
|
165
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
|
166
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
|
167
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
168
|
+
accepting any such warranty or additional liability.
|
|
169
|
+
|
|
170
|
+
_END OF TERMS AND CONDITIONS_
|
|
171
|
+
|
|
172
|
+
### APPENDIX: How to apply the Apache License to your work
|
|
173
|
+
|
|
174
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
175
|
+
notice, with the fields enclosed by brackets `[]` replaced with your own
|
|
176
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
177
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
178
|
+
recommend that a file or class name and description of purpose be included on
|
|
179
|
+
the same “printed page” as the copyright notice for easier identification within
|
|
180
|
+
third-party archives.
|
|
181
|
+
|
|
182
|
+
Copyright [yyyy] [name of copyright owner]
|
|
183
|
+
|
|
184
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
185
|
+
you may not use this file except in compliance with the License.
|
|
186
|
+
You may obtain a copy of the License at
|
|
187
|
+
|
|
188
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
189
|
+
|
|
190
|
+
Unless required by applicable law or agreed to in writing, software
|
|
191
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
192
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
193
|
+
See the License for the specific language governing permissions and
|
|
194
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img style="height: 100px; margin-bottom: 10px;" src="public/assets/logo.svg" alt="Logo - Fragment UI" />
|
|
3
|
+
</div>
|
|
4
|
+
<div align="center">
|
|
5
|
+
<h1>Fragment UI (Work in Progress)</h1>
|
|
6
|
+
<p>Create SaaS UIs with a simple and straightforward design system and component library</p>
|
|
7
|
+
<a href="https://www.npmjs.org/package/@fragment-build/ui">
|
|
8
|
+
<img alt="NPM package version" src="https://img.shields.io/github/package-json/v/@fragment-build/ui?label=npm&logo=npm">
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://fragment-build.github.io/fragment-ui/">
|
|
11
|
+
<img alt="Fragment UI Storybook" src="https://raw.githubusercontent.com/storybookjs/brand/main/badge/badge-storybook.svg">
|
|
12
|
+
</a>
|
|
13
|
+
</div>
|
|
14
|
+
<div align="center" style="margin: 20px">
|
|
15
|
+
<a href="https://discord.gg/A4GrRkgpym">
|
|
16
|
+
<img alt="Fragment UI Discord Server" src="https://img.shields.io/badge/join_discord_-7289da.svg?style=for-the-badge&logo=discord&logoColor=white">
|
|
17
|
+
</a>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
Fragment UI is a design system and React component library which provides already compositioned views for many SaaS apps which are completely customizable with our powerful theme system.
|
|
23
|
+
|
|
24
|
+
### Table of Contents
|
|
25
|
+
- [✨ Features](#-features)
|
|
26
|
+
- [✨ Components](#-components)
|
|
27
|
+
- [⏳ Installation](#-installation)
|
|
28
|
+
- [🔧 Configuration](#-configuration)
|
|
29
|
+
- [🤝 Contributing](#-contributing)
|
|
30
|
+
- [👨💻 Development](#-development)
|
|
31
|
+
- [🤝 Community support](#-community-support)
|
|
32
|
+
- [📝 License](#-license)
|
|
33
|
+
- [🔧 Built with](#-built-with)
|
|
34
|
+
|
|
35
|
+
## ✨ Features
|
|
36
|
+
|
|
37
|
+
- **Global theme file** with design tokens for colors, padding, margin, border-radius
|
|
38
|
+
- **Global event system:** Hook into every click event to trigger analytics/tracking events. All events are already pre-labeled but can be customized.
|
|
39
|
+
- **Accessibility:** All components are already prepared using aria labels and you can also easily use tab to navigate through them
|
|
40
|
+
- **Light / Dark mode compatible:** By design we're supporting ☀️ Light / 🌙 Dark modes
|
|
41
|
+
- **Interactive Theme Builder (soon):** A user interface to create your custom theme file with a real-time preview
|
|
42
|
+
- **Native i18n support (soon):** All components are localized by default but o course you can override this behavior
|
|
43
|
+
|
|
44
|
+
## ✨ Components
|
|
45
|
+
|
|
46
|
+
- Roles- & Permission Management
|
|
47
|
+
- User Management
|
|
48
|
+
- Team/Organization management with Invites
|
|
49
|
+
- Payment/Subscription Management
|
|
50
|
+
- Auth pages: Login, Signup, Password reset, Email confirmation
|
|
51
|
+
- Dashboard View with Sidebar and Topbar
|
|
52
|
+
- User Settings
|
|
53
|
+
|
|
54
|
+
## ⏳ Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Yarn
|
|
58
|
+
yarn add @fragment-build/ui
|
|
59
|
+
|
|
60
|
+
# npm
|
|
61
|
+
npm install -S @fragment-build/ui
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
As a next step you must configure the library the way you want to. See [**Configuration**](#🔧-configuration) section.
|
|
65
|
+
|
|
66
|
+
All done. Enjoy 🎉
|
|
67
|
+
|
|
68
|
+
## 🔧 Configuration
|
|
69
|
+
|
|
70
|
+
Coming soon.
|
|
71
|
+
|
|
72
|
+
## 🤝 Contributing
|
|
73
|
+
|
|
74
|
+
Feel free to fork and make a Pull Request to this project. All the input is warmly welcome!
|
|
75
|
+
|
|
76
|
+
To increase the amount of PRs being merged asap, we have some guidelines:
|
|
77
|
+
|
|
78
|
+
1. **Bugfixes**: If it's just a small fix you can just create a PR for it and explain your thoughts if necessary, otherwise use GitHub or Discord to start a discussion before you put a lot of effort into code changes.
|
|
79
|
+
2. **Features**: If you want to add new features, please use GitHub or Discord to start a discussion and we can figure out design and architectural decisions together.
|
|
80
|
+
3. **Breaking Changes**: Please use the `next-major` branch as your base and target branch for your contributions.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## 👨💻 Development
|
|
84
|
+
- Clone repository
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
git clone git@github.com:fragment-build/fragment-ui.git
|
|
88
|
+
cd fragment-ui
|
|
89
|
+
npm install
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- Run storybook
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm run storybook
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 🤝 Community support
|
|
99
|
+
|
|
100
|
+
For additional help, you can use one of these channels to ask a question:
|
|
101
|
+
|
|
102
|
+
- [Discord](https://discord.gg/A4GrRkgpym) We're present on official Fragment UI Discord. Feel free to use our channels or reach out to us directly.
|
|
103
|
+
- [GitHub](https://github.com/fragment-build/fragment-ui) (Bug reports, Contributions, Questions and Discussions)
|
|
104
|
+
|
|
105
|
+
## 📝 License
|
|
106
|
+
|
|
107
|
+
[Apollo 2.0 License](LICENSE.md) Copyright (c) solyd GmbH
|
|
108
|
+
|
|
109
|
+
## 🔧 Built with
|
|
110
|
+
|
|
111
|
+

|
|
112
|
+

|
|
113
|
+

|
|
114
|
+

|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InputProps } from '@nextui-org/react';
|
|
3
|
+
/**
|
|
4
|
+
* Primary UI component for selecting a color
|
|
5
|
+
*/
|
|
6
|
+
interface ColorInputProps extends InputProps {
|
|
7
|
+
}
|
|
8
|
+
export declare const ColorInput: React.FC<ColorInputProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ColorInput } from "./ColorInput";
|
|
2
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
|
|
3
|
+
const meta = {
|
|
4
|
+
title: "components/ColorInput",
|
|
5
|
+
component: ColorInput,
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
10
|
+
export const Primary = {
|
|
11
|
+
args: {
|
|
12
|
+
onValueChange: console.log,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AvatarProps } from '@nextui-org/react';
|
|
3
|
+
/**
|
|
4
|
+
* Primary UI component for selecting a color
|
|
5
|
+
*/
|
|
6
|
+
interface ColorSelectorProps {
|
|
7
|
+
values: string[];
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
onValueChange: (color: string) => void;
|
|
10
|
+
color?: AvatarProps['color'];
|
|
11
|
+
size?: AvatarProps['size'];
|
|
12
|
+
icon?: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const ColorSelector: React.FC<ColorSelectorProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { ColorSelector } from "./ColorSelector";
|
|
3
|
+
declare const meta: Meta<typeof ColorSelector>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const WithIcon: Story;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ColorSelector } from "./ColorSelector";
|
|
2
|
+
import { IconCheck } from "@tabler/icons-react";
|
|
3
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "components/ColorSelector",
|
|
6
|
+
component: ColorSelector,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
11
|
+
export const Primary = {
|
|
12
|
+
args: {
|
|
13
|
+
values: ['red', 'green', 'blue'],
|
|
14
|
+
onValueChange: console.log,
|
|
15
|
+
color: 'primary',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export const WithIcon = {
|
|
19
|
+
args: {
|
|
20
|
+
values: ['red', 'green', 'blue'],
|
|
21
|
+
onValueChange: console.log,
|
|
22
|
+
color: 'primary',
|
|
23
|
+
icon: <IconCheck size={24} stroke={1.5}/>
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SidebarProps } from '../sidebar/Sidebar';
|
|
3
|
+
/**
|
|
4
|
+
* Primary UI component for Dashboard App Shell
|
|
5
|
+
*/
|
|
6
|
+
interface ShellProps {
|
|
7
|
+
sidebar: SidebarProps;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare const Shell: React.FC<ShellProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Shell } from "./Shell";
|
|
3
|
+
declare const meta: Meta<typeof Shell>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const Collapsed: Story;
|
|
8
|
+
export declare const Auto: Story;
|
|
9
|
+
export declare const WithTable: Story;
|
|
@@ -0,0 +1,170 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AvatarProps, DropdownItemProps, DropdownProps, ListboxProps } from '@nextui-org/react';
|
|
3
|
+
/**
|
|
4
|
+
* Primary UI component for Dashboard Sidebars
|
|
5
|
+
*/
|
|
6
|
+
interface SidebarNavigationItem {
|
|
7
|
+
label: string;
|
|
8
|
+
link: string;
|
|
9
|
+
onClick?: React.MouseEventHandler;
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
endContent?: React.ReactNode;
|
|
12
|
+
items?: SidebarItemVariants[];
|
|
13
|
+
}
|
|
14
|
+
interface SidebarItem {
|
|
15
|
+
key: string;
|
|
16
|
+
align?: 'top' | 'center' | 'bottom';
|
|
17
|
+
}
|
|
18
|
+
interface SidebarItemNavigation extends SidebarItem {
|
|
19
|
+
type: 'navigation';
|
|
20
|
+
label?: string;
|
|
21
|
+
navigation: SidebarNavigationItem[];
|
|
22
|
+
listboxProps?: Omit<ListboxProps, 'children'>;
|
|
23
|
+
}
|
|
24
|
+
interface SidebarItemUser extends SidebarItem {
|
|
25
|
+
type: 'user';
|
|
26
|
+
avatar?: AvatarProps;
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
dropdown?: Omit<DropdownProps, 'children'>;
|
|
30
|
+
dropdownItems?: (Omit<DropdownItemProps, 'children'> & {
|
|
31
|
+
label: string;
|
|
32
|
+
})[];
|
|
33
|
+
}
|
|
34
|
+
interface SidebarItemCustom extends SidebarItem {
|
|
35
|
+
type: 'custom';
|
|
36
|
+
render: React.ReactNode;
|
|
37
|
+
showCollapsed?: boolean;
|
|
38
|
+
}
|
|
39
|
+
type SidebarItemVariants = SidebarItemNavigation | SidebarItemUser | SidebarItemCustom;
|
|
40
|
+
export interface SidebarProps {
|
|
41
|
+
items: SidebarItemVariants[];
|
|
42
|
+
layout?: 'collapsed' | 'expanded';
|
|
43
|
+
autoLayout?: boolean;
|
|
44
|
+
currentPath?: string;
|
|
45
|
+
}
|
|
46
|
+
export declare const Sidebar: React.FC<SidebarProps>;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Sidebar } from "./Sidebar";
|
|
3
|
+
declare const meta: Meta<typeof Sidebar>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const Collapsed: Story;
|
|
8
|
+
export declare const Auto: Story;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Button, Card, Input } from "@nextui-org/react";
|
|
2
|
+
import { IconBox, IconBoxMultiple, IconCirclePlus, IconHome, IconMessageCircle, } from "@tabler/icons-react";
|
|
3
|
+
import { Sidebar } from "./Sidebar";
|
|
4
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
|
|
5
|
+
const meta = {
|
|
6
|
+
title: "components/Sidebar",
|
|
7
|
+
component: Sidebar,
|
|
8
|
+
// tags: ['autodocs'],
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: "fullscreen",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
15
|
+
export const Primary = {
|
|
16
|
+
args: {
|
|
17
|
+
currentPath: "/projects",
|
|
18
|
+
items: [
|
|
19
|
+
{
|
|
20
|
+
type: "user",
|
|
21
|
+
key: "user",
|
|
22
|
+
name: "Tony Reichert",
|
|
23
|
+
description: "ACME Inc.",
|
|
24
|
+
avatar: {
|
|
25
|
+
src: "https://i.pravatar.cc/150?u=a042581f4e29026024d",
|
|
26
|
+
},
|
|
27
|
+
dropdownItems: [
|
|
28
|
+
{
|
|
29
|
+
label: "My Profile",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: "Settings",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "Organization Settings",
|
|
36
|
+
showDivider: true,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "Logout",
|
|
40
|
+
color: "danger",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: "custom",
|
|
46
|
+
key: "search",
|
|
47
|
+
render: <Input label="Search..."/>,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: "navigation",
|
|
51
|
+
key: "navigation-overview",
|
|
52
|
+
label: "Overview",
|
|
53
|
+
navigation: [
|
|
54
|
+
{
|
|
55
|
+
label: "Home",
|
|
56
|
+
link: "/",
|
|
57
|
+
icon: <IconHome stroke={1.5}/>,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: "My Projects",
|
|
61
|
+
link: "/projects",
|
|
62
|
+
icon: <IconBoxMultiple stroke={1.5}/>,
|
|
63
|
+
endContent: (<Button size="sm" variant="light" isIconOnly>
|
|
64
|
+
<IconCirclePlus size={18}/>
|
|
65
|
+
</Button>),
|
|
66
|
+
items: [
|
|
67
|
+
{
|
|
68
|
+
type: "navigation",
|
|
69
|
+
key: "navigation-projects",
|
|
70
|
+
navigation: [
|
|
71
|
+
{
|
|
72
|
+
label: "Project 1",
|
|
73
|
+
link: "/projects/1",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: "Project 2",
|
|
77
|
+
link: "/projects/2",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: "Project 3",
|
|
81
|
+
link: "/projects/3",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: "Chat",
|
|
89
|
+
link: "/chat",
|
|
90
|
+
icon: <IconMessageCircle stroke={1.5}/>,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: "navigation",
|
|
96
|
+
key: "navigation-projects",
|
|
97
|
+
label: "Projects",
|
|
98
|
+
navigation: [
|
|
99
|
+
{
|
|
100
|
+
label: "Project 1",
|
|
101
|
+
link: "/projects/1",
|
|
102
|
+
icon: <IconBox stroke={1.5}/>,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
label: "Project 2",
|
|
106
|
+
link: "/projects/2",
|
|
107
|
+
icon: <IconBox stroke={1.5}/>,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: "Project 3",
|
|
111
|
+
link: "/projects/3",
|
|
112
|
+
icon: <IconBox stroke={1.5}/>,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: "custom",
|
|
118
|
+
key: "bottom-banner",
|
|
119
|
+
render: (<Card radius="lg" className="border-none">
|
|
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>),
|
|
122
|
+
align: "bottom",
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
export const Collapsed = {
|
|
128
|
+
args: Object.assign(Object.assign({}, Primary.args), { layout: "collapsed" }),
|
|
129
|
+
};
|
|
130
|
+
export const Auto = {
|
|
131
|
+
args: Object.assign(Object.assign({}, Primary.args), { autoLayout: true }),
|
|
132
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useGreater: (k: "sm" | "md" | "lg" | "xl" | "2xl") => boolean, useBetween: (a: "sm" | "md" | "lg" | "xl" | "2xl", b: "sm" | "md" | "lg" | "xl" | "2xl") => boolean, useSmaller: (k: "sm" | "md" | "lg" | "xl" | "2xl") => boolean;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fragment-build/ui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/fragment-build/fragment-ui.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@storybook/addon-a11y": "8.0.0",
|
|
13
|
+
"@storybook/addon-essentials": "8.0.0",
|
|
14
|
+
"@storybook/addon-interactions": "8.0.0",
|
|
15
|
+
"@storybook/addon-links": "8.0.0",
|
|
16
|
+
"@storybook/addon-styling": "1.3.7",
|
|
17
|
+
"@storybook/blocks": "8.0.0",
|
|
18
|
+
"@storybook/react": "8.0.0",
|
|
19
|
+
"@storybook/react-vite": "8.0.0",
|
|
20
|
+
"@types/react": "18.2.65",
|
|
21
|
+
"@types/react-dom": "18.2.21",
|
|
22
|
+
"@typescript-eslint/eslint-plugin": "7.2.0",
|
|
23
|
+
"@typescript-eslint/parser": "7.2.0",
|
|
24
|
+
"@vitejs/plugin-react": "4.2.1",
|
|
25
|
+
"@vitejs/plugin-react-swc": "3.6.0",
|
|
26
|
+
"autoprefixer": "10.4.18",
|
|
27
|
+
"eslint": "8.57.0",
|
|
28
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
29
|
+
"eslint-plugin-react-refresh": "0.4.5",
|
|
30
|
+
"eslint-plugin-storybook": "0.8.0",
|
|
31
|
+
"postcss": "8.4.35",
|
|
32
|
+
"react": "18.2.0",
|
|
33
|
+
"react-dom": "18.2.0",
|
|
34
|
+
"storybook": "8.0.0",
|
|
35
|
+
"storybook-dark-mode": "4.0.0",
|
|
36
|
+
"typescript": "5.4.2",
|
|
37
|
+
"vite": "5.1.6"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
42
|
+
"storybook": "storybook dev -p 6006",
|
|
43
|
+
"build-storybook": "storybook build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@nextui-org/react": "2.2.10",
|
|
47
|
+
"@react-hooks-library/core": "0.6.2",
|
|
48
|
+
"@storybook/test": "8.0.0",
|
|
49
|
+
"@tabler/icons-react": "3.0.1",
|
|
50
|
+
"framer-motion": "10.18.0",
|
|
51
|
+
"react-color-palette": "7.1.0",
|
|
52
|
+
"tailwindcss": "3.4.1"
|
|
53
|
+
}
|
|
54
|
+
}
|