@licklist/design 0.78.5-dev.45 → 0.78.5-dev.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/v2/{navigation/icons → icons}/index.d.ts +6 -0
- package/dist/v2/icons/index.d.ts.map +1 -0
- package/dist/v2/icons/index.js +115 -0
- package/dist/v2/index.d.ts +3 -1
- package/dist/v2/index.d.ts.map +1 -1
- package/dist/v2/navigation/DashboardLayout/TopNavigation.scss.js +1 -1
- package/dist/v2/pages/Settings/SettingsPage.d.ts +13 -0
- package/dist/v2/pages/Settings/SettingsPage.d.ts.map +1 -0
- package/dist/v2/pages/Settings/SettingsPage.js +88 -0
- package/dist/v2/pages/Settings/SettingsPage.scss.js +6 -0
- package/dist/v2/pages/Settings/SettingsTabs.d.ts +14 -0
- package/dist/v2/pages/Settings/SettingsTabs.d.ts.map +1 -0
- package/dist/v2/pages/Settings/SettingsTabs.js +29 -0
- package/dist/v2/pages/Settings/SettingsTabs.scss.js +6 -0
- package/dist/v2/pages/Settings/components/SidebarCustomisation.d.ts +20 -0
- package/dist/v2/pages/Settings/components/SidebarCustomisation.d.ts.map +1 -0
- package/dist/v2/pages/Settings/components/SidebarCustomisation.js +276 -0
- package/dist/v2/pages/Settings/components/SidebarCustomisation.scss.js +6 -0
- package/dist/v2/pages/Settings/components/SidebarNavItem.d.ts +19 -0
- package/dist/v2/pages/Settings/components/SidebarNavItem.d.ts.map +1 -0
- package/dist/v2/pages/Settings/components/SidebarNavItem.js +41 -0
- package/dist/v2/pages/Settings/components/SidebarNavItem.scss.js +6 -0
- package/dist/v2/pages/Settings/components/index.d.ts +5 -0
- package/dist/v2/pages/Settings/components/index.d.ts.map +1 -0
- package/dist/v2/pages/Settings/index.d.ts +7 -0
- package/dist/v2/pages/Settings/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/v2/icons/index.tsx +105 -0
- package/src/v2/index.ts +10 -2
- package/src/v2/navigation/DashboardLayout/TopNavigation.scss +1 -0
- package/src/v2/pages/Settings/SettingsContentPlaceholder.scss +24 -0
- package/src/v2/pages/Settings/SettingsPage.scss +52 -0
- package/src/v2/pages/Settings/SettingsPage.tsx +46 -0
- package/src/v2/pages/Settings/SettingsTabs.scss +44 -0
- package/src/v2/pages/Settings/SettingsTabs.tsx +36 -0
- package/src/v2/pages/Settings/components/SidebarCustomisation.scss +150 -0
- package/src/v2/pages/Settings/components/SidebarCustomisation.stories.tsx +48 -0
- package/src/v2/pages/Settings/components/SidebarCustomisation.tsx +166 -0
- package/src/v2/pages/Settings/components/SidebarNavItem.scss +76 -0
- package/src/v2/pages/Settings/components/SidebarNavItem.stories.tsx +50 -0
- package/src/v2/pages/Settings/components/SidebarNavItem.tsx +52 -0
- package/src/v2/pages/Settings/components/index.ts +5 -0
- package/src/v2/pages/Settings/index.ts +8 -0
- package/dist/v2/navigation/icons/index.d.ts.map +0 -1
- package/src/v2/navigation/icons/index.tsx +0 -72
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@import '../../styles/tokens/typography';
|
|
2
|
+
@import '../../styles/tokens/colors';
|
|
3
|
+
|
|
4
|
+
.settings-content-placeholder {
|
|
5
|
+
padding: 24px 0;
|
|
6
|
+
width: 100%;
|
|
7
|
+
font-family: var(--font-family-sans);
|
|
8
|
+
|
|
9
|
+
&__title {
|
|
10
|
+
@include typography('heading.h2');
|
|
11
|
+
margin: 0 0 16px 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&__description {
|
|
15
|
+
@include typography('text.regular');
|
|
16
|
+
color: var(--label-secondary);
|
|
17
|
+
margin: 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.settings-tabs-standalone {
|
|
22
|
+
border-bottom: 1px solid var(--border-primary);
|
|
23
|
+
padding-bottom: 0;
|
|
24
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
@import '../../styles/tokens/typography';
|
|
2
|
+
@import '../../styles/tokens/colors';
|
|
3
|
+
|
|
4
|
+
.settings-page {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
align-items: flex-start;
|
|
8
|
+
gap: 24px;
|
|
9
|
+
align-self: stretch;
|
|
10
|
+
font-family: var(--font-family-sans);
|
|
11
|
+
|
|
12
|
+
&__header {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: flex-start;
|
|
16
|
+
align-self: stretch;
|
|
17
|
+
border-bottom: 1px solid var(--border-primary);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__title-row {
|
|
21
|
+
display: flex;
|
|
22
|
+
height: 72px;
|
|
23
|
+
justify-content: space-between;
|
|
24
|
+
align-items: center;
|
|
25
|
+
align-self: stretch;
|
|
26
|
+
padding: 24px 0 8px 8px;
|
|
27
|
+
|
|
28
|
+
@media (max-width: $bp-mobile-max) {
|
|
29
|
+
height: auto;
|
|
30
|
+
padding: 16px 0 8px 8px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&__title {
|
|
35
|
+
@include typography('heading.h1');
|
|
36
|
+
margin: 0;
|
|
37
|
+
|
|
38
|
+
@media (max-width: $bp-mobile-max) {
|
|
39
|
+
@include typography('heading.h1.mobile');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&__content {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
align-items: stretch;
|
|
47
|
+
gap: 16px;
|
|
48
|
+
align-self: stretch;
|
|
49
|
+
width: 100%;
|
|
50
|
+
padding: 0 8px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import './SettingsPage.scss'
|
|
3
|
+
import { SettingsTabs, SettingsTab } from './SettingsTabs'
|
|
4
|
+
|
|
5
|
+
export interface SettingsPageProps {
|
|
6
|
+
title?: string
|
|
7
|
+
tabs: SettingsTab[]
|
|
8
|
+
defaultTab?: string
|
|
9
|
+
onTabChange?: (tabId: string) => void
|
|
10
|
+
children?: React.ReactNode
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const SettingsPage: React.FC<SettingsPageProps> = ({
|
|
14
|
+
title = 'Settings',
|
|
15
|
+
tabs,
|
|
16
|
+
defaultTab,
|
|
17
|
+
onTabChange,
|
|
18
|
+
children,
|
|
19
|
+
}) => {
|
|
20
|
+
const [activeTab, setActiveTab] = useState(defaultTab || tabs[0]?.id || '')
|
|
21
|
+
|
|
22
|
+
const handleTabChange = (tabId: string) => {
|
|
23
|
+
setActiveTab(tabId)
|
|
24
|
+
onTabChange?.(tabId)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className="settings-page">
|
|
29
|
+
<header className="settings-page__header">
|
|
30
|
+
<div className="settings-page__title-row">
|
|
31
|
+
<h1 className="settings-page__title">{title}</h1>
|
|
32
|
+
</div>
|
|
33
|
+
<SettingsTabs
|
|
34
|
+
tabs={tabs}
|
|
35
|
+
activeTab={activeTab}
|
|
36
|
+
onTabChange={handleTabChange}
|
|
37
|
+
/>
|
|
38
|
+
</header>
|
|
39
|
+
<div className="settings-page__content">
|
|
40
|
+
{children}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default SettingsPage
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
@import '../../styles/tokens/typography';
|
|
2
|
+
@import '../../styles/tokens/colors';
|
|
3
|
+
|
|
4
|
+
.settings-tabs {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: flex-start;
|
|
7
|
+
gap: 24px;
|
|
8
|
+
align-self: stretch;
|
|
9
|
+
font-family: var(--font-family-sans);
|
|
10
|
+
|
|
11
|
+
&__tab {
|
|
12
|
+
display: flex;
|
|
13
|
+
padding: 12px 0;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 8px;
|
|
17
|
+
background: none;
|
|
18
|
+
border: none;
|
|
19
|
+
border-bottom: 2px solid transparent;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
transition: border-color 0.2s ease, color 0.2s ease;
|
|
22
|
+
|
|
23
|
+
&:hover {
|
|
24
|
+
.settings-tabs__tab-label {
|
|
25
|
+
color: var(--label-primary);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&--active {
|
|
30
|
+
border-bottom-color: var(--fill-primary);
|
|
31
|
+
|
|
32
|
+
.settings-tabs__tab-label {
|
|
33
|
+
color: var(--label-primary);
|
|
34
|
+
font-weight: 600;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&__tab-label {
|
|
40
|
+
@include typography('text.regular');
|
|
41
|
+
color: var(--label-secondary);
|
|
42
|
+
transition: color 0.2s ease;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import './SettingsTabs.scss'
|
|
3
|
+
|
|
4
|
+
export interface SettingsTab {
|
|
5
|
+
id: string
|
|
6
|
+
label: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SettingsTabsProps {
|
|
10
|
+
tabs: SettingsTab[]
|
|
11
|
+
activeTab: string
|
|
12
|
+
onTabChange: (tabId: string) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const SettingsTabs: React.FC<SettingsTabsProps> = ({
|
|
16
|
+
tabs,
|
|
17
|
+
activeTab,
|
|
18
|
+
onTabChange,
|
|
19
|
+
}) => {
|
|
20
|
+
return (
|
|
21
|
+
<nav className="settings-tabs">
|
|
22
|
+
{tabs.map((tab) => (
|
|
23
|
+
<button
|
|
24
|
+
key={tab.id}
|
|
25
|
+
onClick={() => onTabChange(tab.id)}
|
|
26
|
+
className={`settings-tabs__tab ${activeTab === tab.id ? 'settings-tabs__tab--active' : ''}`}
|
|
27
|
+
>
|
|
28
|
+
<span className="settings-tabs__label">{tab.label}</span>
|
|
29
|
+
<div className="settings-tabs__indicator" />
|
|
30
|
+
</button>
|
|
31
|
+
))}
|
|
32
|
+
</nav>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default SettingsTabs
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
@import '../../../styles/tokens/typography';
|
|
2
|
+
@import '../../../styles/tokens/colors';
|
|
3
|
+
|
|
4
|
+
.sidebar-customisation {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: 16px;
|
|
8
|
+
width: 100%;
|
|
9
|
+
font-family: var(--font-family-sans);
|
|
10
|
+
|
|
11
|
+
&__header {
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&__title {
|
|
18
|
+
@include typography('text.small.bold');
|
|
19
|
+
margin: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__cancel-btn {
|
|
23
|
+
@include typography('text.regular');
|
|
24
|
+
color: var(--label-danger);
|
|
25
|
+
background: none;
|
|
26
|
+
border: none;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
padding: 0;
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
text-decoration: underline;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&__edit-btn {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
gap: 6px;
|
|
39
|
+
@include typography('text.regular');
|
|
40
|
+
color: var(--label-primary);
|
|
41
|
+
background: none;
|
|
42
|
+
border: none;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
padding: 0;
|
|
45
|
+
|
|
46
|
+
svg {
|
|
47
|
+
color: var(--fill-primary);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&:hover {
|
|
51
|
+
text-decoration: underline;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Edit mode grid
|
|
56
|
+
&__grid {
|
|
57
|
+
display: grid;
|
|
58
|
+
grid-template-columns: repeat(3, 1fr);
|
|
59
|
+
gap: 16px;
|
|
60
|
+
width: 100%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// View mode grid
|
|
64
|
+
&__view-grid {
|
|
65
|
+
display: grid;
|
|
66
|
+
grid-template-columns: repeat(3, 1fr);
|
|
67
|
+
gap: 12px;
|
|
68
|
+
width: 100%;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&__view-item {
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
gap: 12px;
|
|
75
|
+
padding: 12px;
|
|
76
|
+
border: 1px solid var(--border-primary);
|
|
77
|
+
border-radius: 8px;
|
|
78
|
+
background-color: var(--surface-secondary);
|
|
79
|
+
min-width: 0;
|
|
80
|
+
|
|
81
|
+
&--hidden {
|
|
82
|
+
opacity: 0.5;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&__view-icon {
|
|
87
|
+
width: 24px;
|
|
88
|
+
height: 24px;
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
justify-content: center;
|
|
92
|
+
color: var(--fill-primary);
|
|
93
|
+
flex-shrink: 0;
|
|
94
|
+
|
|
95
|
+
svg {
|
|
96
|
+
width: 24px;
|
|
97
|
+
height: 24px;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&__view-label {
|
|
102
|
+
@include typography('text.small.emphasis');
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
text-overflow: ellipsis;
|
|
105
|
+
white-space: nowrap;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&__actions {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
gap: 12px;
|
|
112
|
+
margin-top: 8px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&__save-btn {
|
|
116
|
+
@include typography('text.regular');
|
|
117
|
+
font-weight: 600;
|
|
118
|
+
padding: 10px 20px;
|
|
119
|
+
border-radius: 8px;
|
|
120
|
+
border: none;
|
|
121
|
+
background-color: var(--fill-action);
|
|
122
|
+
color: var(--label-white);
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
transition: background-color 0.2s ease;
|
|
125
|
+
|
|
126
|
+
&:hover {
|
|
127
|
+
background-color: var(--actions-dark);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&:focus-visible {
|
|
131
|
+
outline: 2px solid var(--border-action);
|
|
132
|
+
outline-offset: 2px;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&__reset-btn {
|
|
137
|
+
@include typography('text.small');
|
|
138
|
+
font-weight: 500;
|
|
139
|
+
color: var(--label-secondary);
|
|
140
|
+
background: none;
|
|
141
|
+
border: none;
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
padding: 0;
|
|
144
|
+
|
|
145
|
+
&:hover {
|
|
146
|
+
color: var(--label-primary);
|
|
147
|
+
text-decoration: underline;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
3
|
+
import { SidebarCustomisation, defaultSidebarItems, SidebarItem } from './SidebarCustomisation'
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof SidebarCustomisation> = {
|
|
6
|
+
title: 'V2/Pages/Settings/SidebarCustomisation',
|
|
7
|
+
component: SidebarCustomisation,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'padded',
|
|
10
|
+
},
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default meta
|
|
14
|
+
type Story = StoryObj<typeof SidebarCustomisation>
|
|
15
|
+
|
|
16
|
+
const InteractiveSidebarCustomisation = () => {
|
|
17
|
+
const [items, setItems] = useState<SidebarItem[]>(defaultSidebarItems)
|
|
18
|
+
|
|
19
|
+
const handleSave = (updatedItems: SidebarItem[]) => {
|
|
20
|
+
console.log('Saved items:', updatedItems)
|
|
21
|
+
alert('Settings saved!')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const handleReset = () => {
|
|
25
|
+
setItems(defaultSidebarItems)
|
|
26
|
+
console.log('Reset to defaults')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const handleCancel = () => {
|
|
30
|
+
console.log('Cancelled')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div style={{ maxWidth: '900px' }}>
|
|
35
|
+
<SidebarCustomisation
|
|
36
|
+
items={items}
|
|
37
|
+
onItemsChange={setItems}
|
|
38
|
+
onSave={handleSave}
|
|
39
|
+
onReset={handleReset}
|
|
40
|
+
onCancel={handleCancel}
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const Default: Story = {
|
|
47
|
+
render: () => <InteractiveSidebarCustomisation />,
|
|
48
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { SidebarNavItem } from './SidebarNavItem'
|
|
3
|
+
import './SidebarCustomisation.scss'
|
|
4
|
+
import {
|
|
5
|
+
CalendarIcon,
|
|
6
|
+
BookingsIcon,
|
|
7
|
+
BookingTypesIcon,
|
|
8
|
+
LoyaltyIcon,
|
|
9
|
+
CustomersIcon,
|
|
10
|
+
MarketingIcon,
|
|
11
|
+
WaiversIcon,
|
|
12
|
+
SettingsIcon,
|
|
13
|
+
EditIcon,
|
|
14
|
+
} from '../../../icons'
|
|
15
|
+
|
|
16
|
+
export interface SidebarItem {
|
|
17
|
+
id: string
|
|
18
|
+
label: string
|
|
19
|
+
icon: React.ReactNode
|
|
20
|
+
visible: boolean
|
|
21
|
+
locked?: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SidebarCustomisationProps {
|
|
25
|
+
items: SidebarItem[]
|
|
26
|
+
onItemsChange?: (items: SidebarItem[]) => void
|
|
27
|
+
onSave?: (items: SidebarItem[]) => void
|
|
28
|
+
onReset?: () => void
|
|
29
|
+
onCancel?: () => void
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Default sidebar items - IDs must match useProviderNavigation.tsx
|
|
33
|
+
export const defaultSidebarItems: SidebarItem[] = [
|
|
34
|
+
{ id: 'events', label: 'Dates & Events', icon: <CalendarIcon />, visible: true },
|
|
35
|
+
{ id: 'sales', label: 'Bookings & Enquiries', icon: <BookingsIcon />, visible: true },
|
|
36
|
+
{ id: 'product-sets', label: 'Booking Types', icon: <BookingTypesIcon />, visible: true },
|
|
37
|
+
{ id: 'loyalty', label: 'Loyalty', icon: <LoyaltyIcon />, visible: true },
|
|
38
|
+
{ id: 'customers', label: 'Customers', icon: <CustomersIcon />, visible: true },
|
|
39
|
+
{ id: 'emails', label: 'Email & SMS', icon: <MarketingIcon />, visible: true },
|
|
40
|
+
{ id: 'waivers', label: 'Waivers', icon: <WaiversIcon />, visible: true },
|
|
41
|
+
{ id: 'settings', label: 'Settings', icon: <SettingsIcon />, visible: true, locked: true },
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
export const SidebarCustomisation: React.FC<SidebarCustomisationProps> = ({
|
|
45
|
+
items: initialItems,
|
|
46
|
+
onItemsChange,
|
|
47
|
+
onSave,
|
|
48
|
+
onReset,
|
|
49
|
+
onCancel,
|
|
50
|
+
}) => {
|
|
51
|
+
const [items, setItems] = useState<SidebarItem[]>(initialItems)
|
|
52
|
+
const [isEditing, setIsEditing] = useState(false)
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
setItems(initialItems)
|
|
56
|
+
}, [initialItems])
|
|
57
|
+
|
|
58
|
+
const handleLabelChange = (id: string, newLabel: string) => {
|
|
59
|
+
const updatedItems = items.map((item) =>
|
|
60
|
+
item.id === id ? { ...item, label: newLabel } : item
|
|
61
|
+
)
|
|
62
|
+
setItems(updatedItems)
|
|
63
|
+
onItemsChange?.(updatedItems)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const handleSave = () => {
|
|
67
|
+
onSave?.(items)
|
|
68
|
+
setIsEditing(false)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const handleReset = () => {
|
|
72
|
+
setItems(defaultSidebarItems)
|
|
73
|
+
onReset?.()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const handleCancel = () => {
|
|
77
|
+
setItems(initialItems)
|
|
78
|
+
onCancel?.()
|
|
79
|
+
setIsEditing(false)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const handleEdit = () => {
|
|
83
|
+
setIsEditing(true)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div className="sidebar-customisation">
|
|
88
|
+
<div className="sidebar-customisation__header">
|
|
89
|
+
<h3 className="sidebar-customisation__title">Sidebar Customisation</h3>
|
|
90
|
+
{isEditing ? (
|
|
91
|
+
<button
|
|
92
|
+
type="button"
|
|
93
|
+
className="sidebar-customisation__cancel-btn"
|
|
94
|
+
onClick={handleCancel}
|
|
95
|
+
>
|
|
96
|
+
Cancel
|
|
97
|
+
</button>
|
|
98
|
+
) : (
|
|
99
|
+
<button
|
|
100
|
+
type="button"
|
|
101
|
+
className="sidebar-customisation__edit-btn"
|
|
102
|
+
onClick={handleEdit}
|
|
103
|
+
>
|
|
104
|
+
<EditIcon />
|
|
105
|
+
<span>Edit Side Bar</span>
|
|
106
|
+
</button>
|
|
107
|
+
)}
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
{isEditing ? (
|
|
111
|
+
<>
|
|
112
|
+
<div className="sidebar-customisation__grid">
|
|
113
|
+
{items.map((item) => {
|
|
114
|
+
const defaultItem = defaultSidebarItems.find(d => d.id === item.id)
|
|
115
|
+
return (
|
|
116
|
+
<SidebarNavItem
|
|
117
|
+
key={item.id}
|
|
118
|
+
id={item.id}
|
|
119
|
+
label={item.label}
|
|
120
|
+
defaultLabel={defaultItem?.label || item.label}
|
|
121
|
+
icon={item.icon}
|
|
122
|
+
onLabelChange={handleLabelChange}
|
|
123
|
+
/>
|
|
124
|
+
)
|
|
125
|
+
})}
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<div className="sidebar-customisation__actions">
|
|
129
|
+
<button
|
|
130
|
+
type="button"
|
|
131
|
+
className="sidebar-customisation__save-btn"
|
|
132
|
+
onClick={handleSave}
|
|
133
|
+
>
|
|
134
|
+
Save Changes
|
|
135
|
+
</button>
|
|
136
|
+
<button
|
|
137
|
+
type="button"
|
|
138
|
+
className="sidebar-customisation__reset-btn"
|
|
139
|
+
onClick={handleReset}
|
|
140
|
+
>
|
|
141
|
+
Reset to defaults
|
|
142
|
+
</button>
|
|
143
|
+
</div>
|
|
144
|
+
</>
|
|
145
|
+
) : (
|
|
146
|
+
<div className="sidebar-customisation__view-grid">
|
|
147
|
+
{items.map((item) => (
|
|
148
|
+
<div
|
|
149
|
+
key={item.id}
|
|
150
|
+
className={`sidebar-customisation__view-item ${!item.visible ? 'sidebar-customisation__view-item--hidden' : ''}`}
|
|
151
|
+
>
|
|
152
|
+
<span className="sidebar-customisation__view-icon">
|
|
153
|
+
{item.icon}
|
|
154
|
+
</span>
|
|
155
|
+
<span className="sidebar-customisation__view-label">
|
|
156
|
+
{item.label}
|
|
157
|
+
</span>
|
|
158
|
+
</div>
|
|
159
|
+
))}
|
|
160
|
+
</div>
|
|
161
|
+
)}
|
|
162
|
+
</div>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export default SidebarCustomisation
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
@import '../../../styles/tokens/typography';
|
|
2
|
+
@import '../../../styles/tokens/colors';
|
|
3
|
+
|
|
4
|
+
.sidebar-nav-item {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: 8px;
|
|
8
|
+
font-family: var(--font-family-sans);
|
|
9
|
+
|
|
10
|
+
&__header {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&__info {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: 8px;
|
|
20
|
+
|
|
21
|
+
&--disabled {
|
|
22
|
+
.sidebar-nav-item__icon {
|
|
23
|
+
color: var(--fill-disabled);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sidebar-nav-item__name {
|
|
27
|
+
color: var(--label-status-disabled);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&__icon {
|
|
33
|
+
width: 24px;
|
|
34
|
+
height: 24px;
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
color: var(--fill-primary);
|
|
39
|
+
|
|
40
|
+
svg {
|
|
41
|
+
width: 24px;
|
|
42
|
+
height: 24px;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&__name {
|
|
47
|
+
@include typography('text.small.emphasis');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&__input {
|
|
51
|
+
@include typography('text.small');
|
|
52
|
+
height: 40px;
|
|
53
|
+
width: 100%;
|
|
54
|
+
padding: 8px 12px;
|
|
55
|
+
border: 1px solid var(--border-primary);
|
|
56
|
+
border-radius: 6px;
|
|
57
|
+
background-color: var(--surface-secondary);
|
|
58
|
+
color: var(--label-primary);
|
|
59
|
+
outline: none;
|
|
60
|
+
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
61
|
+
|
|
62
|
+
&::placeholder {
|
|
63
|
+
color: var(--label-secondary);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:focus {
|
|
67
|
+
outline: none;
|
|
68
|
+
box-shadow: 0 0 0 2px var(--surface-primary), 0 0 0 4px var(--actions-regular);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&--disabled {
|
|
72
|
+
opacity: 0.5;
|
|
73
|
+
cursor: not-allowed;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
3
|
+
import { SidebarNavItem } from './SidebarNavItem'
|
|
4
|
+
|
|
5
|
+
const HomeIcon = () => (
|
|
6
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
7
|
+
<path d="M17.7273 20.1182H6.27273C5.82086 20.1182 5.45455 19.7423 5.45455 19.2785V11.7207H3L11.4496 3.83661C11.7617 3.54543 12.2383 3.54543 12.5504 3.83661L21 11.7207H18.5455V19.2785C18.5455 19.7423 18.1792 20.1182 17.7273 20.1182ZM7.09091 18.4387H16.9091V10.1734L12 5.59288L7.09091 10.1734V18.4387Z" fill="currentColor" />
|
|
8
|
+
</svg>
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof SidebarNavItem> = {
|
|
12
|
+
title: 'V2/Pages/Settings/SidebarNavItem',
|
|
13
|
+
component: SidebarNavItem,
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: 'padded',
|
|
16
|
+
},
|
|
17
|
+
argTypes: {
|
|
18
|
+
label: {
|
|
19
|
+
control: 'text',
|
|
20
|
+
description: 'Display label for the item',
|
|
21
|
+
},
|
|
22
|
+
disabled: {
|
|
23
|
+
control: 'boolean',
|
|
24
|
+
description: 'Whether the input is disabled',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default meta
|
|
30
|
+
type Story = StoryObj<typeof SidebarNavItem>
|
|
31
|
+
|
|
32
|
+
const InteractiveSidebarNavItem = () => {
|
|
33
|
+
const [label, setLabel] = useState('Home')
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div style={{ maxWidth: '300px' }}>
|
|
37
|
+
<SidebarNavItem
|
|
38
|
+
id="home"
|
|
39
|
+
label={label}
|
|
40
|
+
defaultLabel="Home"
|
|
41
|
+
icon={<HomeIcon />}
|
|
42
|
+
onLabelChange={(id, newLabel) => setLabel(newLabel)}
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const Default: Story = {
|
|
49
|
+
render: () => <InteractiveSidebarNavItem />,
|
|
50
|
+
}
|