@mich8060/chg-design-system 0.1.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/.github/workflows/figma-sync.yml +30 -0
- package/ARCHITECTURE_FIX.md +241 -0
- package/LICENSE +21 -0
- package/README.lib.md +103 -0
- package/README.md +177 -0
- package/figma.config.json +9 -0
- package/package.json +67 -0
- package/package.lib.json +49 -0
- package/public/data/figma-variables.json +40026 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +46 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/public/styles/tokens.css +1994 -0
- package/scripts/index.js +896 -0
- package/scripts/publish-lib.js +150 -0
- package/scripts/validate.js +94 -0
- package/src/App.css +457 -0
- package/src/App.css.map +1 -0
- package/src/App.js +161 -0
- package/src/App.scss +548 -0
- package/src/App.test.js +8 -0
- package/src/assets/images/.gitkeep +0 -0
- package/src/assets/images/doctors/Avatar-1.png +0 -0
- package/src/assets/images/doctors/Avatar-10.png +0 -0
- package/src/assets/images/doctors/Avatar-11.png +0 -0
- package/src/assets/images/doctors/Avatar-12.png +0 -0
- package/src/assets/images/doctors/Avatar-13.png +0 -0
- package/src/assets/images/doctors/Avatar-14.png +0 -0
- package/src/assets/images/doctors/Avatar-15.png +0 -0
- package/src/assets/images/doctors/Avatar-16.png +0 -0
- package/src/assets/images/doctors/Avatar-17.png +0 -0
- package/src/assets/images/doctors/Avatar-18.png +0 -0
- package/src/assets/images/doctors/Avatar-19.png +0 -0
- package/src/assets/images/doctors/Avatar-2.png +0 -0
- package/src/assets/images/doctors/Avatar-20.png +0 -0
- package/src/assets/images/doctors/Avatar-21.png +0 -0
- package/src/assets/images/doctors/Avatar-3.png +0 -0
- package/src/assets/images/doctors/Avatar-4.png +0 -0
- package/src/assets/images/doctors/Avatar-5.png +0 -0
- package/src/assets/images/doctors/Avatar-6.png +0 -0
- package/src/assets/images/doctors/Avatar-7.png +0 -0
- package/src/assets/images/doctors/Avatar-8.png +0 -0
- package/src/assets/images/doctors/Avatar-9.png +0 -0
- package/src/assets/images/doctors/Avatar.png +0 -0
- package/src/assets/images/doctors/index.js +141 -0
- package/src/data/figma-variables.json +90305 -0
- package/src/index.js +20 -0
- package/src/index.scss +10 -0
- package/src/pages/AccordionDemo.jsx +206 -0
- package/src/pages/AccordionDemo.scss +34 -0
- package/src/pages/ActionMenuDemo.jsx +957 -0
- package/src/pages/ActionMenuDemo.scss +34 -0
- package/src/pages/AvatarDemo.jsx +328 -0
- package/src/pages/AvatarDemo.scss +40 -0
- package/src/pages/BadgeDemo.jsx +254 -0
- package/src/pages/BadgeDemo.scss +40 -0
- package/src/pages/BorderRadiusDemo.jsx +112 -0
- package/src/pages/BorderRadiusDemo.scss +50 -0
- package/src/pages/BrandingDemo.jsx +117 -0
- package/src/pages/BreadcrumbDemo.jsx +172 -0
- package/src/pages/ButtonDemo.jsx +708 -0
- package/src/pages/ButtonDemo.scss +34 -0
- package/src/pages/CheckboxDemo.jsx +194 -0
- package/src/pages/ChipDemo.jsx +359 -0
- package/src/pages/ChipDemo.scss +40 -0
- package/src/pages/ColorsDemo.jsx +566 -0
- package/src/pages/ColorsDemo.scss +243 -0
- package/src/pages/ComponentsUsage.jsx +401 -0
- package/src/pages/DatepickerDemo.jsx +223 -0
- package/src/pages/DividerDemo.jsx +337 -0
- package/src/pages/DotStatusDemo.jsx +223 -0
- package/src/pages/DropdownDemo.jsx +229 -0
- package/src/pages/FieldDemo.jsx +253 -0
- package/src/pages/FigmaVariablesDemo.jsx +426 -0
- package/src/pages/FigmaVariablesDemo.scss +316 -0
- package/src/pages/FileUploadDemo.jsx +186 -0
- package/src/pages/FlexDemo.jsx +144 -0
- package/src/pages/FlexDemo.scss +119 -0
- package/src/pages/FontInstallation.jsx +252 -0
- package/src/pages/FontInstallation.scss +40 -0
- package/src/pages/Home.jsx +3156 -0
- package/src/pages/IconDemo.jsx +1680 -0
- package/src/pages/ImageAspectDemo.jsx +152 -0
- package/src/pages/InputDemo.jsx +245 -0
- package/src/pages/Installation.jsx +257 -0
- package/src/pages/Installation.scss +40 -0
- package/src/pages/KeyDemo.jsx +184 -0
- package/src/pages/MenuDemo.jsx +139 -0
- package/src/pages/MicroCalendarDemo.jsx +165 -0
- package/src/pages/PaginationDemo.jsx +176 -0
- package/src/pages/PillToggleDemo.jsx +212 -0
- package/src/pages/ProgressCircleDemo.jsx +206 -0
- package/src/pages/ProgressIndicatorDemo.jsx +227 -0
- package/src/pages/RadioDemo.jsx +282 -0
- package/src/pages/ShadowsDemo.jsx +118 -0
- package/src/pages/ShadowsDemo.scss +93 -0
- package/src/pages/SliderDemo.jsx +226 -0
- package/src/pages/SpacingDemo.jsx +160 -0
- package/src/pages/SpacingDemo.scss +107 -0
- package/src/pages/StatusDemo.jsx +196 -0
- package/src/pages/StepsDemo.jsx +308 -0
- package/src/pages/TableDemo.jsx +376 -0
- package/src/pages/TabsDemo.jsx +221 -0
- package/src/pages/ToastDemo.jsx +195 -0
- package/src/pages/ToggleDemo.jsx +187 -0
- package/src/pages/TokensDemo.jsx +637 -0
- package/src/pages/TokensDemo.scss +270 -0
- package/src/pages/TokensUsage.jsx +220 -0
- package/src/pages/TooltipDemo.jsx +170 -0
- package/src/pages/TypographyDemo.jsx +229 -0
- package/src/pages/TypographyDemo.scss +105 -0
- package/src/pages/UtilitiesDemo.jsx +381 -0
- package/src/pages/UtilitiesDemo.scss +214 -0
- package/src/reportWebVitals.js +13 -0
- package/src/setupTests.js +5 -0
- package/src/styles/_typography.scss +932 -0
- package/src/styles/_utilities.scss +3635 -0
- package/src/styles/_variables.scss +887 -0
- package/src/styles/prism-custom.css +206 -0
- package/src/styles/prism-custom.css.map +1 -0
- package/src/styles/prism-custom.scss +205 -0
- package/src/styles/tokens.css +4416 -0
- package/src/styles/tokens.css.map +1 -0
- package/src/styles/tokens.scss +1456 -0
- package/src/ui/Accordion/Accordion.jsx +70 -0
- package/src/ui/Accordion/Accordion.scss +82 -0
- package/src/ui/Accordion/index.js +1 -0
- package/src/ui/ActionMenu/ActionMenu.jsx +383 -0
- package/src/ui/ActionMenu/ActionMenu.scss +198 -0
- package/src/ui/ActionMenu/index.js +1 -0
- package/src/ui/Avatar/Avatar.jsx +49 -0
- package/src/ui/Avatar/Avatar.scss +82 -0
- package/src/ui/Avatar/index.js +1 -0
- package/src/ui/Badge/Badge.jsx +64 -0
- package/src/ui/Badge/Badge.scss +84 -0
- package/src/ui/Badge/index.js +1 -0
- package/src/ui/Branding/Branding.jsx +65 -0
- package/src/ui/Branding/Branding.scss +116 -0
- package/src/ui/Branding/index.js +1 -0
- package/src/ui/Breadcrumb/Breadcrumb.jsx +162 -0
- package/src/ui/Breadcrumb/Breadcrumb.scss +46 -0
- package/src/ui/Breadcrumb/index.js +2 -0
- package/src/ui/Button/Button.figma.tsx +49 -0
- package/src/ui/Button/Button.jsx +135 -0
- package/src/ui/Button/Button.scss +188 -0
- package/src/ui/Button/index.js +1 -0
- package/src/ui/Card/Card.jsx +25 -0
- package/src/ui/Card/Card.scss +47 -0
- package/src/ui/Card/index.js +1 -0
- package/src/ui/Checkbox/Checkbox.jsx +70 -0
- package/src/ui/Checkbox/Checkbox.scss +96 -0
- package/src/ui/Checkbox/index.js +1 -0
- package/src/ui/Chip/Chip.jsx +104 -0
- package/src/ui/Chip/Chip.scss +118 -0
- package/src/ui/Chip/index.js +1 -0
- package/src/ui/CopyButton/CopyButton.jsx +102 -0
- package/src/ui/CopyButton/CopyButton.scss +56 -0
- package/src/ui/CopyButton/index.js +1 -0
- package/src/ui/Datepicker/Datepicker.jsx +326 -0
- package/src/ui/Datepicker/Datepicker.scss +187 -0
- package/src/ui/Datepicker/index.js +2 -0
- package/src/ui/Divider/Divider.jsx +89 -0
- package/src/ui/Divider/Divider.scss +112 -0
- package/src/ui/Divider/index.js +1 -0
- package/src/ui/DotStatus/DotStatus.jsx +64 -0
- package/src/ui/DotStatus/DotStatus.scss +87 -0
- package/src/ui/DotStatus/index.js +1 -0
- package/src/ui/Dropdown/Dropdown.jsx +200 -0
- package/src/ui/Dropdown/Dropdown.scss +156 -0
- package/src/ui/Dropdown/index.js +1 -0
- package/src/ui/Field/Field.jsx +89 -0
- package/src/ui/Field/Field.scss +119 -0
- package/src/ui/Field/index.js +1 -0
- package/src/ui/FileUpload/FileUpload.figma.tsx +28 -0
- package/src/ui/FileUpload/FileUpload.jsx +153 -0
- package/src/ui/FileUpload/FileUpload.scss +78 -0
- package/src/ui/FileUpload/index.js +2 -0
- package/src/ui/Flex/Flex.jsx +42 -0
- package/src/ui/Flex/Flex.scss +119 -0
- package/src/ui/Flex/index.js +1 -0
- package/src/ui/Icon/Icon.figma.tsx +22 -0
- package/src/ui/Icon/Icon.jsx +47 -0
- package/src/ui/Icon/index.js +1 -0
- package/src/ui/ImageAspect/ImageAspect.jsx +56 -0
- package/src/ui/ImageAspect/ImageAspect.scss +62 -0
- package/src/ui/ImageAspect/index.js +1 -0
- package/src/ui/Input/Input.figma.tsx +35 -0
- package/src/ui/Input/Input.jsx +68 -0
- package/src/ui/Input/Input.scss +64 -0
- package/src/ui/Input/index.js +2 -0
- package/src/ui/Key/Key.jsx +37 -0
- package/src/ui/Key/Key.scss +34 -0
- package/src/ui/Key/index.js +1 -0
- package/src/ui/Menu/Menu.jsx +389 -0
- package/src/ui/Menu/Menu.scss +382 -0
- package/src/ui/Menu/index.js +1 -0
- package/src/ui/MicroCalendar/MicroCalendar.jsx +392 -0
- package/src/ui/MicroCalendar/MicroCalendar.scss +277 -0
- package/src/ui/MicroCalendar/index.js +1 -0
- package/src/ui/Pagination/Pagination.jsx +237 -0
- package/src/ui/Pagination/Pagination.scss +182 -0
- package/src/ui/Pagination/index.js +1 -0
- package/src/ui/PillToggle/PillToggle.jsx +56 -0
- package/src/ui/PillToggle/PillToggle.scss +84 -0
- package/src/ui/PillToggle/index.js +1 -0
- package/src/ui/Playground/Playground.jsx +524 -0
- package/src/ui/Playground/Playground.scss +310 -0
- package/src/ui/Playground/index.js +2 -0
- package/src/ui/ProgressCircle/ProgressCircle.jsx +147 -0
- package/src/ui/ProgressCircle/ProgressCircle.scss +143 -0
- package/src/ui/ProgressCircle/index.js +1 -0
- package/src/ui/ProgressIndicator/ProgressIndicator.jsx +92 -0
- package/src/ui/ProgressIndicator/ProgressIndicator.scss +133 -0
- package/src/ui/ProgressIndicator/index.js +1 -0
- package/src/ui/Radio/Radio.jsx +57 -0
- package/src/ui/Radio/Radio.scss +84 -0
- package/src/ui/Radio/index.js +1 -0
- package/src/ui/Slider/Slider.jsx +283 -0
- package/src/ui/Slider/Slider.scss +156 -0
- package/src/ui/Slider/index.js +1 -0
- package/src/ui/Status/Status.jsx +66 -0
- package/src/ui/Status/Status.scss +90 -0
- package/src/ui/Status/index.js +1 -0
- package/src/ui/Steps/Steps.jsx +201 -0
- package/src/ui/Steps/Steps.scss +240 -0
- package/src/ui/Steps/index.js +1 -0
- package/src/ui/Table/Table.jsx +143 -0
- package/src/ui/Table/Table.scss +90 -0
- package/src/ui/Table/index.js +1 -0
- package/src/ui/Tabs/TabItem.jsx +86 -0
- package/src/ui/Tabs/Tabs.figma.tsx +30 -0
- package/src/ui/Tabs/Tabs.jsx +318 -0
- package/src/ui/Tabs/Tabs.scss +164 -0
- package/src/ui/Tabs/Untitled +1 -0
- package/src/ui/Tabs/index.js +3 -0
- package/src/ui/Tag/Tag.figma.tsx +29 -0
- package/src/ui/Tag/Tag.jsx +93 -0
- package/src/ui/Tag/Tag.scss +229 -0
- package/src/ui/Tag/index.js +2 -0
- package/src/ui/Textarea/Textarea.figma.tsx +35 -0
- package/src/ui/Textarea/Textarea.jsx +68 -0
- package/src/ui/Textarea/Textarea.scss +69 -0
- package/src/ui/Textarea/index.js +2 -0
- package/src/ui/Toast/Toast.jsx +75 -0
- package/src/ui/Toast/Toast.scss +132 -0
- package/src/ui/Toast/index.js +2 -0
- package/src/ui/Toggle/Toggle.jsx +73 -0
- package/src/ui/Toggle/Toggle.scss +139 -0
- package/src/ui/Toggle/index.js +1 -0
- package/src/ui/Tooltip/Tooltip.figma.tsx +24 -0
- package/src/ui/Tooltip/Tooltip.jsx +123 -0
- package/src/ui/Tooltip/Tooltip.scss +80 -0
- package/src/ui/Tooltip/index.js +2 -0
- package/src/ui/index.js +63 -0
- package/src/utils/formatDate.js +27 -0
- package/src/utils/headerVariants.js +69 -0
- package/vite.config.lib.js +55 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Link } from "react-router-dom";
|
|
3
|
+
import Table from "../ui/Table/Table";
|
|
4
|
+
import Badge from "../ui/Badge/Badge";
|
|
5
|
+
import Status from "../ui/Status/Status";
|
|
6
|
+
import Checkbox from "../ui/Checkbox/Checkbox";
|
|
7
|
+
import Button from "../ui/Button/Button";
|
|
8
|
+
import Flex from "../ui/Flex/Flex";
|
|
9
|
+
import Breadcrumb from "../ui/Breadcrumb/Breadcrumb";
|
|
10
|
+
import Divider from "../ui/Divider/Divider";
|
|
11
|
+
import { formatLastUpdated } from "../utils/formatDate";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Table Component Demo & Documentation
|
|
15
|
+
*
|
|
16
|
+
* This page demonstrates the Table component and its various configurations.
|
|
17
|
+
*
|
|
18
|
+
* ## Table Component Props:
|
|
19
|
+
*
|
|
20
|
+
* ### Required Props:
|
|
21
|
+
* - `columns` (array): Array of column definitions
|
|
22
|
+
* - `data` (array): Array of data rows
|
|
23
|
+
*
|
|
24
|
+
* ### Optional Props:
|
|
25
|
+
* - `className` (string): Additional CSS classes
|
|
26
|
+
*
|
|
27
|
+
* ## Column Definition:
|
|
28
|
+
* - `key` (string): Unique key for the column (used to access row data)
|
|
29
|
+
* - `label` (string): Header label text
|
|
30
|
+
* - `icon` (string): Icon name for header cell
|
|
31
|
+
* - `sortable` (boolean): Whether the column is sortable
|
|
32
|
+
* - `filterable` (boolean): Whether the column is filterable
|
|
33
|
+
* - `align` (string): Text alignment: 'left', 'center', or 'right'
|
|
34
|
+
* - `render` (function): Custom render function for cell content: (row, rowIndex, colIndex) => ReactNode
|
|
35
|
+
* - `className` (string): Additional CSS classes for the cell
|
|
36
|
+
*
|
|
37
|
+
* ## Usage Examples:
|
|
38
|
+
*
|
|
39
|
+
* Basic table:
|
|
40
|
+
* ```jsx
|
|
41
|
+
* const columns = [
|
|
42
|
+
* { key: 'name', label: 'Name' },
|
|
43
|
+
* { key: 'email', label: 'Email' },
|
|
44
|
+
* ];
|
|
45
|
+
* const data = [
|
|
46
|
+
* { name: 'John', email: 'john@example.com' },
|
|
47
|
+
* { name: 'Jane', email: 'jane@example.com' },
|
|
48
|
+
* ];
|
|
49
|
+
* <Table columns={columns} data={data} />
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
const basicColumns = [
|
|
54
|
+
{ key: "name", label: "Name" },
|
|
55
|
+
{ key: "email", label: "Email" },
|
|
56
|
+
{ key: "phone", label: "Phone" },
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const basicData = [
|
|
60
|
+
{ name: "John Doe", email: "john@example.com", phone: "555-0100" },
|
|
61
|
+
{ name: "Jane Smith", email: "jane@example.com", phone: "555-0101" },
|
|
62
|
+
{ name: "Bob Johnson", email: "bob@example.com", phone: "555-0102" },
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const headerColumns = [
|
|
66
|
+
{ key: "name", label: "Name", icon: "User" },
|
|
67
|
+
{ key: "email", label: "Email", icon: "Envelope", sortable: true },
|
|
68
|
+
{ key: "status", label: "Status", icon: "Info", filterable: true },
|
|
69
|
+
{ key: "role", label: "Role", sortable: true, filterable: true },
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
const headerData = [
|
|
73
|
+
{
|
|
74
|
+
name: "John Doe",
|
|
75
|
+
email: "john@example.com",
|
|
76
|
+
status: "Active",
|
|
77
|
+
role: "Admin",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "Jane Smith",
|
|
81
|
+
email: "jane@example.com",
|
|
82
|
+
status: "Inactive",
|
|
83
|
+
role: "User",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "Bob Johnson",
|
|
87
|
+
email: "bob@example.com",
|
|
88
|
+
status: "Active",
|
|
89
|
+
role: "User",
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
export default function TableDemo() {
|
|
94
|
+
const [selectedRows, setSelectedRows] = useState([]);
|
|
95
|
+
|
|
96
|
+
const columnsWithActions = [
|
|
97
|
+
{
|
|
98
|
+
key: "select",
|
|
99
|
+
label: "",
|
|
100
|
+
render: (row, rowIndex) => (
|
|
101
|
+
<Checkbox
|
|
102
|
+
checked={selectedRows.includes(rowIndex)}
|
|
103
|
+
onChange={(checked) => {
|
|
104
|
+
if (checked) {
|
|
105
|
+
setSelectedRows([...selectedRows, rowIndex]);
|
|
106
|
+
} else {
|
|
107
|
+
setSelectedRows(selectedRows.filter((i) => i !== rowIndex));
|
|
108
|
+
}
|
|
109
|
+
}}
|
|
110
|
+
/>
|
|
111
|
+
),
|
|
112
|
+
},
|
|
113
|
+
{ key: "name", label: "Name" },
|
|
114
|
+
{ key: "email", label: "Email" },
|
|
115
|
+
{
|
|
116
|
+
key: "status",
|
|
117
|
+
label: "Status",
|
|
118
|
+
render: (row) => (
|
|
119
|
+
<Status
|
|
120
|
+
label={row.status}
|
|
121
|
+
variant={row.status === "Active" ? "green" : "red"}
|
|
122
|
+
shape="pill"
|
|
123
|
+
/>
|
|
124
|
+
),
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
key: "actions",
|
|
128
|
+
label: "Actions",
|
|
129
|
+
align: "right",
|
|
130
|
+
render: (row) => (
|
|
131
|
+
<Flex direction="row" gap="8">
|
|
132
|
+
<Button
|
|
133
|
+
appearance="text"
|
|
134
|
+
layout="icon-only"
|
|
135
|
+
icon="Pencil"
|
|
136
|
+
size="small"
|
|
137
|
+
aria-label="Edit"
|
|
138
|
+
/>
|
|
139
|
+
<Button
|
|
140
|
+
appearance="text"
|
|
141
|
+
layout="icon-only"
|
|
142
|
+
icon="Trash"
|
|
143
|
+
size="small"
|
|
144
|
+
aria-label="Delete"
|
|
145
|
+
/>
|
|
146
|
+
</Flex>
|
|
147
|
+
),
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
const dataWithActions = [
|
|
152
|
+
{ name: "John Doe", email: "john@example.com", status: "Active" },
|
|
153
|
+
{ name: "Jane Smith", email: "jane@example.com", status: "Inactive" },
|
|
154
|
+
{ name: "Bob Johnson", email: "bob@example.com", status: "Active" },
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
const columnsWithIndicators = [
|
|
158
|
+
{ key: "name", label: "Name" },
|
|
159
|
+
{ key: "email", label: "Email" },
|
|
160
|
+
{
|
|
161
|
+
key: "badge",
|
|
162
|
+
label: "Badge",
|
|
163
|
+
render: (row) => <Badge count={row.badge} variant="blue" />,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
key: "status",
|
|
167
|
+
label: "Status",
|
|
168
|
+
render: (row) => (
|
|
169
|
+
<Status label={row.status} variant={row.statusVariant} shape="pill" />
|
|
170
|
+
),
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
const dataWithIndicators = [
|
|
175
|
+
{
|
|
176
|
+
name: "John Doe",
|
|
177
|
+
email: "john@example.com",
|
|
178
|
+
badge: 5,
|
|
179
|
+
status: "Active",
|
|
180
|
+
statusVariant: "green",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "Jane Smith",
|
|
184
|
+
email: "jane@example.com",
|
|
185
|
+
badge: 12,
|
|
186
|
+
status: "Pending",
|
|
187
|
+
statusVariant: "yellow",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "Bob Johnson",
|
|
191
|
+
email: "bob@example.com",
|
|
192
|
+
badge: 0,
|
|
193
|
+
status: "Inactive",
|
|
194
|
+
statusVariant: "red",
|
|
195
|
+
},
|
|
196
|
+
];
|
|
197
|
+
|
|
198
|
+
const columnsWithInputs = [
|
|
199
|
+
{
|
|
200
|
+
key: "checkbox",
|
|
201
|
+
label: "",
|
|
202
|
+
render: (row, rowIndex) => (
|
|
203
|
+
<Checkbox
|
|
204
|
+
checked={selectedRows.includes(rowIndex)}
|
|
205
|
+
onChange={(checked) => {
|
|
206
|
+
if (checked) {
|
|
207
|
+
setSelectedRows([...selectedRows, rowIndex]);
|
|
208
|
+
} else {
|
|
209
|
+
setSelectedRows(selectedRows.filter((i) => i !== rowIndex));
|
|
210
|
+
}
|
|
211
|
+
}}
|
|
212
|
+
/>
|
|
213
|
+
),
|
|
214
|
+
},
|
|
215
|
+
{ key: "name", label: "Name" },
|
|
216
|
+
{ key: "email", label: "Email" },
|
|
217
|
+
{
|
|
218
|
+
key: "toggle",
|
|
219
|
+
label: "Enabled",
|
|
220
|
+
render: (row) => (
|
|
221
|
+
<Flex direction="row" gap="8" alignItems="center">
|
|
222
|
+
<span>{row.enabled ? "Yes" : "No"}</span>
|
|
223
|
+
</Flex>
|
|
224
|
+
),
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
const dataWithInputs = [
|
|
229
|
+
{ name: "John Doe", email: "john@example.com", enabled: true },
|
|
230
|
+
{ name: "Jane Smith", email: "jane@example.com", enabled: false },
|
|
231
|
+
{ name: "Bob Johnson", email: "bob@example.com", enabled: true },
|
|
232
|
+
];
|
|
233
|
+
|
|
234
|
+
const columnsAligned = [
|
|
235
|
+
{ key: "name", label: "Name", align: "left" },
|
|
236
|
+
{ key: "email", label: "Email", align: "center" },
|
|
237
|
+
{ key: "amount", label: "Amount", align: "right" },
|
|
238
|
+
];
|
|
239
|
+
|
|
240
|
+
const dataAligned = [
|
|
241
|
+
{ name: "John Doe", email: "john@example.com", amount: "$1,234.56" },
|
|
242
|
+
{ name: "Jane Smith", email: "jane@example.com", amount: "$2,345.67" },
|
|
243
|
+
{ name: "Bob Johnson", email: "bob@example.com", amount: "$3,456.78" },
|
|
244
|
+
];
|
|
245
|
+
|
|
246
|
+
return (
|
|
247
|
+
<section className="page">
|
|
248
|
+
<header className="page__header">
|
|
249
|
+
<div className="page__header-container">
|
|
250
|
+
<Breadcrumb />
|
|
251
|
+
<div className="page__header-info">
|
|
252
|
+
<div className="page__header-content">
|
|
253
|
+
<h1 className="page__header-title">Table</h1>
|
|
254
|
+
<p className="page__header-description">
|
|
255
|
+
The Table component displays tabular data with flexible cell content.
|
|
256
|
+
Supports custom cell rendering, header icons, sortable/filterable
|
|
257
|
+
columns, and various cell types including actions, indicators, and
|
|
258
|
+
inputs.
|
|
259
|
+
</p>
|
|
260
|
+
</div>
|
|
261
|
+
<div className="page__header-metadata">
|
|
262
|
+
<div className="page__metadata-row">
|
|
263
|
+
<p className="page__metadata-label">Author</p>
|
|
264
|
+
<a
|
|
265
|
+
href="https://chgit.slack.com/team/U06V9C0K06S"
|
|
266
|
+
className="page__metadata-link"
|
|
267
|
+
target="_blank"
|
|
268
|
+
rel="noopener noreferrer"
|
|
269
|
+
>
|
|
270
|
+
@Michael-Stevens
|
|
271
|
+
</a>
|
|
272
|
+
</div>
|
|
273
|
+
<div className="page__metadata-row">
|
|
274
|
+
<p className="page__metadata-label">Last updated</p>
|
|
275
|
+
<p className="page__metadata-value">{formatLastUpdated()}</p>
|
|
276
|
+
</div>
|
|
277
|
+
<div className="page__metadata-row">
|
|
278
|
+
<p className="page__metadata-label">Version</p>
|
|
279
|
+
<Flex direction="row" gap="8" alignItems="center">
|
|
280
|
+
<p className="page__metadata-value">1.0.0</p>
|
|
281
|
+
<span className="page__version-badge">BETA</span>
|
|
282
|
+
</Flex>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
</header>
|
|
288
|
+
<main className="page__content">
|
|
289
|
+
<div className="page__examples-section">
|
|
290
|
+
<div className="demo-group">
|
|
291
|
+
<h2 className="demo-group__heading">Basic Table</h2>
|
|
292
|
+
<p className="demo-group__description">
|
|
293
|
+
A simple table displaying basic data with columns and rows.
|
|
294
|
+
</p>
|
|
295
|
+
<div className="demo-content">
|
|
296
|
+
<Table columns={basicColumns} data={basicData} />
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
|
|
300
|
+
<div className="demo-group">
|
|
301
|
+
<h2 className="demo-group__heading">With Header Icons</h2>
|
|
302
|
+
<p className="demo-group__description">
|
|
303
|
+
Table headers can include icons and support sortable and filterable indicators.
|
|
304
|
+
</p>
|
|
305
|
+
<div className="demo-content">
|
|
306
|
+
<Table columns={headerColumns} data={headerData} />
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|
|
309
|
+
|
|
310
|
+
<div className="demo-group">
|
|
311
|
+
<h2 className="demo-group__heading">With Actions</h2>
|
|
312
|
+
<p className="demo-group__description">
|
|
313
|
+
Tables can include action columns with buttons, checkboxes for row selection, and custom cell rendering.
|
|
314
|
+
</p>
|
|
315
|
+
<div className="demo-content">
|
|
316
|
+
<Table columns={columnsWithActions} data={dataWithActions} />
|
|
317
|
+
</div>
|
|
318
|
+
</div>
|
|
319
|
+
|
|
320
|
+
<div className="demo-group">
|
|
321
|
+
<h2 className="demo-group__heading">With Indicators</h2>
|
|
322
|
+
<p className="demo-group__description">
|
|
323
|
+
Tables can display badges, status indicators, and other visual elements in cells using custom render functions.
|
|
324
|
+
</p>
|
|
325
|
+
<div className="demo-content">
|
|
326
|
+
<Table columns={columnsWithIndicators} data={dataWithIndicators} />
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
<div className="demo-group">
|
|
331
|
+
<h2 className="demo-group__heading">With Inputs</h2>
|
|
332
|
+
<p className="demo-group__description">
|
|
333
|
+
Tables can include interactive elements like checkboxes and toggles in cells.
|
|
334
|
+
</p>
|
|
335
|
+
<div className="demo-content">
|
|
336
|
+
<Table columns={columnsWithInputs} data={dataWithInputs} />
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
|
|
340
|
+
<div className="demo-group">
|
|
341
|
+
<h2 className="demo-group__heading">Text Alignment</h2>
|
|
342
|
+
<p className="demo-group__description">
|
|
343
|
+
Table cells support different text alignments: left, center, or right. Useful for numbers, currency, or specific formatting needs.
|
|
344
|
+
</p>
|
|
345
|
+
<div className="demo-content">
|
|
346
|
+
<Table columns={columnsAligned} data={dataAligned} />
|
|
347
|
+
</div>
|
|
348
|
+
</div>
|
|
349
|
+
</div>
|
|
350
|
+
|
|
351
|
+
<Divider variant="solid" />
|
|
352
|
+
|
|
353
|
+
<div className="page__tabs-content-container">
|
|
354
|
+
<div className="demo-group">
|
|
355
|
+
<div className="page__navigation">
|
|
356
|
+
<Link
|
|
357
|
+
to="/steps"
|
|
358
|
+
className="page__nav-link page__nav-link--prev"
|
|
359
|
+
>
|
|
360
|
+
<span className="page__nav-label">Previous</span>
|
|
361
|
+
<span className="page__nav-title">Steps</span>
|
|
362
|
+
</Link>
|
|
363
|
+
<Link
|
|
364
|
+
to="/tabs"
|
|
365
|
+
className="page__nav-link page__nav-link--next"
|
|
366
|
+
>
|
|
367
|
+
<span className="page__nav-label">Next</span>
|
|
368
|
+
<span className="page__nav-title">Tabs</span>
|
|
369
|
+
</Link>
|
|
370
|
+
</div>
|
|
371
|
+
</div>
|
|
372
|
+
</div>
|
|
373
|
+
</main>
|
|
374
|
+
</section>
|
|
375
|
+
);
|
|
376
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Link } from "react-router-dom";
|
|
3
|
+
import Tabs from "../ui/Tabs/Tabs";
|
|
4
|
+
import Flex from "../ui/Flex/Flex";
|
|
5
|
+
import Breadcrumb from "../ui/Breadcrumb/Breadcrumb";
|
|
6
|
+
import Divider from "../ui/Divider/Divider";
|
|
7
|
+
import { formatLastUpdated } from "../utils/formatDate";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Tabs Component Demo & Documentation
|
|
11
|
+
*
|
|
12
|
+
* This page demonstrates the Tabs component and its various configurations.
|
|
13
|
+
*/
|
|
14
|
+
export default function TabsDemo() {
|
|
15
|
+
|
|
16
|
+
const [underlineTab, setUnderlineTab] = useState(0);
|
|
17
|
+
const [blockTab, setBlockTab] = useState(0);
|
|
18
|
+
const [blockInvertedTab, setBlockInvertedTab] = useState(0);
|
|
19
|
+
const [fillTab, setFillTab] = useState(0);
|
|
20
|
+
|
|
21
|
+
const basicTabs = [
|
|
22
|
+
{ label: "Tab 1" },
|
|
23
|
+
{ label: "Tab 2" },
|
|
24
|
+
{ label: "Tab 3" },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const tabsWithIcons = [
|
|
28
|
+
{ label: "Home", icon: "House" },
|
|
29
|
+
{ label: "Settings", icon: "Gear" },
|
|
30
|
+
{ label: "Profile", icon: "User" },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const tabsWithTags = [
|
|
34
|
+
{ label: "Inbox", tag: 5, tagVariant: "red" },
|
|
35
|
+
{ label: "Drafts", tag: 2, tagVariant: "blue" },
|
|
36
|
+
{ label: "Sent", tag: false },
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const tabsWithIconsAndTags = [
|
|
40
|
+
{ label: "Messages", icon: "Envelope", tag: 12, tagVariant: "red" },
|
|
41
|
+
{ label: "Notifications", icon: "Bell", tag: 3, tagVariant: "blue" },
|
|
42
|
+
{ label: "Tasks", icon: "CheckSquare", tag: false },
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<section className="page">
|
|
47
|
+
<header className="page__header">
|
|
48
|
+
<div className="page__header-container">
|
|
49
|
+
<Breadcrumb />
|
|
50
|
+
<div className="page__header-info">
|
|
51
|
+
<div className="page__header-content">
|
|
52
|
+
<h1 className="page__header-title">Tabs</h1>
|
|
53
|
+
<p className="page__header-description">
|
|
54
|
+
The Tabs component provides a way to organize content into multiple
|
|
55
|
+
sections that can be switched between. Supports different
|
|
56
|
+
appearances (underline, block, block-inverted) and optional icons
|
|
57
|
+
and badges.
|
|
58
|
+
</p>
|
|
59
|
+
</div>
|
|
60
|
+
<div className="page__header-metadata">
|
|
61
|
+
<div className="page__metadata-row">
|
|
62
|
+
<p className="page__metadata-label">Author</p>
|
|
63
|
+
<a
|
|
64
|
+
href="https://chgit.slack.com/team/U06V9C0K06S"
|
|
65
|
+
className="page__metadata-link"
|
|
66
|
+
target="_blank"
|
|
67
|
+
rel="noopener noreferrer"
|
|
68
|
+
>
|
|
69
|
+
@Michael-Stevens
|
|
70
|
+
</a>
|
|
71
|
+
</div>
|
|
72
|
+
<div className="page__metadata-row">
|
|
73
|
+
<p className="page__metadata-label">Last updated</p>
|
|
74
|
+
<p className="page__metadata-value">{formatLastUpdated()}</p>
|
|
75
|
+
</div>
|
|
76
|
+
<div className="page__metadata-row">
|
|
77
|
+
<p className="page__metadata-label">Version</p>
|
|
78
|
+
<Flex direction="row" gap="8" alignItems="center">
|
|
79
|
+
<p className="page__metadata-value">1.0.0</p>
|
|
80
|
+
<span className="page__version-badge">BETA</span>
|
|
81
|
+
</Flex>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</header>
|
|
87
|
+
<main className="page__content">
|
|
88
|
+
<div className="page__examples-section">
|
|
89
|
+
<div className="demo-group">
|
|
90
|
+
<h2 className="demo-group__heading">Basic Tabs</h2>
|
|
91
|
+
<p className="demo-group__description">
|
|
92
|
+
Simple tabs with labels. The underline appearance is the default style.
|
|
93
|
+
</p>
|
|
94
|
+
<div className="demo-content">
|
|
95
|
+
<Tabs
|
|
96
|
+
tabs={basicTabs}
|
|
97
|
+
activeTab={underlineTab}
|
|
98
|
+
onTabChange={(index) => setUnderlineTab(index)}
|
|
99
|
+
appearance="underline"
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div className="demo-group">
|
|
105
|
+
<h2 className="demo-group__heading">With Icons</h2>
|
|
106
|
+
<p className="demo-group__description">
|
|
107
|
+
Tabs can include icons alongside labels to provide visual context.
|
|
108
|
+
</p>
|
|
109
|
+
<div className="demo-content">
|
|
110
|
+
<Tabs
|
|
111
|
+
tabs={tabsWithIcons}
|
|
112
|
+
activeTab={underlineTab}
|
|
113
|
+
onTabChange={(index) => setUnderlineTab(index)}
|
|
114
|
+
appearance="underline"
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div className="demo-group">
|
|
120
|
+
<h2 className="demo-group__heading">With Tags</h2>
|
|
121
|
+
<p className="demo-group__description">
|
|
122
|
+
Tabs can display tags (badges) with counts or indicators. Tags can have different color variants.
|
|
123
|
+
</p>
|
|
124
|
+
<div className="demo-content">
|
|
125
|
+
<Tabs
|
|
126
|
+
tabs={tabsWithTags}
|
|
127
|
+
activeTab={underlineTab}
|
|
128
|
+
onTabChange={(index) => setUnderlineTab(index)}
|
|
129
|
+
appearance="underline"
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<div className="demo-group">
|
|
135
|
+
<h2 className="demo-group__heading">With Icons and Tags</h2>
|
|
136
|
+
<p className="demo-group__description">
|
|
137
|
+
Tabs can combine icons and tags for rich visual information.
|
|
138
|
+
</p>
|
|
139
|
+
<div className="demo-content">
|
|
140
|
+
<Tabs
|
|
141
|
+
tabs={tabsWithIconsAndTags}
|
|
142
|
+
activeTab={underlineTab}
|
|
143
|
+
onTabChange={(index) => setUnderlineTab(index)}
|
|
144
|
+
appearance="underline"
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<div className="demo-group">
|
|
150
|
+
<h2 className="demo-group__heading">Block Appearance</h2>
|
|
151
|
+
<p className="demo-group__description">
|
|
152
|
+
The block appearance provides a filled background for the active tab.
|
|
153
|
+
</p>
|
|
154
|
+
<div className="demo-content">
|
|
155
|
+
<Tabs
|
|
156
|
+
tabs={basicTabs}
|
|
157
|
+
activeTab={blockTab}
|
|
158
|
+
onTabChange={(index) => setBlockTab(index)}
|
|
159
|
+
appearance="block"
|
|
160
|
+
/>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<div className="demo-group">
|
|
165
|
+
<h2 className="demo-group__heading">Block Inverted Appearance</h2>
|
|
166
|
+
<p className="demo-group__description">
|
|
167
|
+
The block-inverted appearance provides an inverted color scheme for the active tab.
|
|
168
|
+
</p>
|
|
169
|
+
<div className="demo-content">
|
|
170
|
+
<Tabs
|
|
171
|
+
tabs={basicTabs}
|
|
172
|
+
activeTab={blockInvertedTab}
|
|
173
|
+
onTabChange={(index) => setBlockInvertedTab(index)}
|
|
174
|
+
appearance="block-inverted"
|
|
175
|
+
/>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<div className="demo-group">
|
|
180
|
+
<h2 className="demo-group__heading">Fill Width</h2>
|
|
181
|
+
<p className="demo-group__description">
|
|
182
|
+
Tabs can fill the available width, distributing space evenly across all tabs.
|
|
183
|
+
</p>
|
|
184
|
+
<div className="demo-content">
|
|
185
|
+
<Tabs
|
|
186
|
+
tabs={basicTabs}
|
|
187
|
+
activeTab={fillTab}
|
|
188
|
+
onTabChange={(index) => setFillTab(index)}
|
|
189
|
+
appearance="underline"
|
|
190
|
+
fill
|
|
191
|
+
/>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<Divider variant="solid" />
|
|
197
|
+
|
|
198
|
+
<div className="page__tabs-content-container">
|
|
199
|
+
<div className="demo-group">
|
|
200
|
+
<div className="page__navigation">
|
|
201
|
+
<Link
|
|
202
|
+
to="/table"
|
|
203
|
+
className="page__nav-link page__nav-link--prev"
|
|
204
|
+
>
|
|
205
|
+
<span className="page__nav-label">Previous</span>
|
|
206
|
+
<span className="page__nav-title">Table</span>
|
|
207
|
+
</Link>
|
|
208
|
+
<Link
|
|
209
|
+
to="/toast"
|
|
210
|
+
className="page__nav-link page__nav-link--next"
|
|
211
|
+
>
|
|
212
|
+
<span className="page__nav-label">Next</span>
|
|
213
|
+
<span className="page__nav-title">Toast</span>
|
|
214
|
+
</Link>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
</main>
|
|
219
|
+
</section>
|
|
220
|
+
);
|
|
221
|
+
}
|