goobs-frontend 0.8.17 → 0.8.18
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/package.json +1 -1
- package/src/components/Tabs/index.tsx +63 -111
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goobs-frontend",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A comprehensive React-based UI library built on Material-UI, offering a wide range of customizable components including grids, typography, buttons, cards, forms, navigation, pricing tables, steppers, tooltips, accordions, and more. Designed for building responsive and consistent user interfaces with advanced features like form validation, theming, and code syntax highlighting.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1,46 +1,27 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import React, { useState, useEffect } from 'react'
|
|
3
|
-
import { AppBar,
|
|
3
|
+
import { AppBar, Tabs as MuiTabs, Tab } from '@mui/material'
|
|
4
4
|
import { usePathname } from 'next/navigation'
|
|
5
|
+
// Import your black palette color
|
|
6
|
+
import { black } from '../../styles/palette'
|
|
5
7
|
|
|
6
|
-
/** Represents the shape of each tab item in the horizontal nav. */
|
|
7
8
|
export interface TabsItem {
|
|
8
|
-
/** The text/title displayed on the tab */
|
|
9
9
|
title?: string
|
|
10
|
-
|
|
11
|
-
/** The URL route */
|
|
12
10
|
route?: string
|
|
13
|
-
|
|
14
|
-
/** The trigger type: 'route' | 'onClick' */
|
|
15
11
|
trigger?: 'route' | 'onClick'
|
|
16
|
-
|
|
17
|
-
/** OnClick callback */
|
|
18
12
|
onClick?: () => void
|
|
19
|
-
|
|
20
|
-
/** Optional left border */
|
|
21
13
|
hasleftborder?: string
|
|
22
|
-
|
|
23
|
-
/** Optional right border */
|
|
24
14
|
hasrightborder?: string
|
|
25
15
|
}
|
|
26
16
|
|
|
27
|
-
/** Represents the currently active/selected tab */
|
|
28
17
|
export interface ActiveTabValue {
|
|
29
18
|
tabId: string | false
|
|
30
19
|
}
|
|
31
20
|
|
|
32
|
-
/** Props for the horizontal Tabs component. */
|
|
33
21
|
export interface TabsProps {
|
|
34
|
-
/** Array of horizontal items (TabsItem). */
|
|
35
22
|
items: TabsItem[]
|
|
36
|
-
|
|
37
|
-
/** Height of the tabs bar. */
|
|
38
23
|
height?: string
|
|
39
|
-
|
|
40
|
-
/** MUI alignment. */
|
|
41
24
|
alignment?: 'left' | 'center' | 'right' | 'inherit' | 'justify'
|
|
42
|
-
|
|
43
|
-
/** Unique name for this tab set (for managing active tab). */
|
|
44
25
|
navname?: string
|
|
45
26
|
}
|
|
46
27
|
|
|
@@ -59,11 +40,8 @@ function Tabs({
|
|
|
59
40
|
const pathname = usePathname()
|
|
60
41
|
|
|
61
42
|
useEffect(() => {
|
|
62
|
-
|
|
63
|
-
* Find the item whose route matches the current path
|
|
64
|
-
*/
|
|
43
|
+
// Find the item whose route matches the current path
|
|
65
44
|
const currentTab = items.find(item => item.route === pathname)
|
|
66
|
-
|
|
67
45
|
setActiveTabValues(prev => ({
|
|
68
46
|
...prev,
|
|
69
47
|
[navname]: { tabId: currentTab?.title || false },
|
|
@@ -71,8 +49,7 @@ function Tabs({
|
|
|
71
49
|
}, [items, navname, pathname])
|
|
72
50
|
|
|
73
51
|
/**
|
|
74
|
-
* When user changes tab via click,
|
|
75
|
-
* update the activeTabValues record.
|
|
52
|
+
* When user changes tab via click, update the activeTabValues record.
|
|
76
53
|
*/
|
|
77
54
|
const handleTabChange = (event: React.SyntheticEvent, newValue: string) => {
|
|
78
55
|
setActiveTabValues(prev => ({
|
|
@@ -97,97 +74,72 @@ function Tabs({
|
|
|
97
74
|
return (
|
|
98
75
|
<AppBar
|
|
99
76
|
position="sticky"
|
|
77
|
+
elevation={0} // Remove MUI's default shadow
|
|
100
78
|
sx={{
|
|
101
|
-
backgroundColor:
|
|
102
|
-
color: '
|
|
79
|
+
backgroundColor: black.main, // Ensure the AppBar is black
|
|
80
|
+
color: '#fff',
|
|
81
|
+
overflow: 'hidden', // Prevent hover effects from spilling
|
|
82
|
+
height,
|
|
83
|
+
minHeight: height,
|
|
84
|
+
display: 'flex',
|
|
85
|
+
justifyContent: 'center',
|
|
86
|
+
boxShadow: 'none',
|
|
103
87
|
}}
|
|
104
88
|
>
|
|
105
|
-
<
|
|
106
|
-
|
|
89
|
+
<MuiTabs
|
|
90
|
+
value={activeTabValues[navname]?.tabId || false}
|
|
91
|
+
onChange={handleTabChange}
|
|
92
|
+
variant="fullWidth"
|
|
93
|
+
aria-label="nav tabs"
|
|
107
94
|
sx={{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
height:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}}
|
|
114
|
-
>
|
|
115
|
-
<Box
|
|
116
|
-
sx={{
|
|
117
|
-
width: '100%',
|
|
95
|
+
// Make the entire Tabs area black too
|
|
96
|
+
backgroundColor: black.main,
|
|
97
|
+
height: '100%',
|
|
98
|
+
'& .MuiTabs-flexContainer': {
|
|
99
|
+
height: '100%',
|
|
118
100
|
display: 'flex',
|
|
119
|
-
flexDirection: 'row',
|
|
120
101
|
justifyContent: alignment === 'left' ? 'flex-start' : alignment,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
102
|
+
// The container is also black
|
|
103
|
+
backgroundColor: black.main,
|
|
104
|
+
},
|
|
105
|
+
'& .MuiTab-root': {
|
|
106
|
+
height: '100%',
|
|
107
|
+
minHeight: 'unset',
|
|
108
|
+
display: 'flex',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
textTransform: 'none',
|
|
111
|
+
boxSizing: 'border-box',
|
|
112
|
+
backgroundColor: black.main,
|
|
113
|
+
color: '#fff',
|
|
114
|
+
fontWeight: 500,
|
|
115
|
+
fontFamily: 'Merriweather',
|
|
116
|
+
fontSize: 16,
|
|
117
|
+
'&:hover': {
|
|
118
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
|
119
|
+
},
|
|
120
|
+
'&.Mui-selected': {
|
|
121
|
+
backgroundColor: 'rgba(255, 255, 255, 0.2)',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
{items.map(item => (
|
|
127
|
+
<Tab
|
|
128
|
+
key={item.title}
|
|
129
|
+
value={item.title || ''}
|
|
130
|
+
label={item.title || ''}
|
|
131
|
+
onClick={() => handleTabClick(item)}
|
|
124
132
|
sx={{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
...(item.hasleftborder === 'true' && {
|
|
134
|
+
borderLeft: '1px solid white',
|
|
135
|
+
}),
|
|
136
|
+
...(item.hasrightborder === 'true' && {
|
|
137
|
+
borderRight: '1px solid white',
|
|
138
|
+
}),
|
|
131
139
|
}}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
onChange={handleTabChange}
|
|
136
|
-
aria-label="nav tabs"
|
|
137
|
-
variant="fullWidth"
|
|
138
|
-
sx={{
|
|
139
|
-
height: height,
|
|
140
|
-
'& .MuiTabs-flexContainer': {
|
|
141
|
-
height: '100%',
|
|
142
|
-
},
|
|
143
|
-
'& .MuiTab-root': {
|
|
144
|
-
height: '100%',
|
|
145
|
-
minHeight: 'unset',
|
|
146
|
-
},
|
|
147
|
-
}}
|
|
148
|
-
>
|
|
149
|
-
{items.map(item => (
|
|
150
|
-
<Tab
|
|
151
|
-
key={item.title}
|
|
152
|
-
value={item.title || ''}
|
|
153
|
-
label={item.title || ''}
|
|
154
|
-
onClick={() => handleTabClick(item)}
|
|
155
|
-
sx={{
|
|
156
|
-
flex: 1,
|
|
157
|
-
textTransform: 'none',
|
|
158
|
-
boxSizing: 'border-box',
|
|
159
|
-
backgroundColor: 'black',
|
|
160
|
-
color: '#fff',
|
|
161
|
-
fontWeight: 500,
|
|
162
|
-
fontFamily: 'Merriweather',
|
|
163
|
-
fontSize: 16,
|
|
164
|
-
height: height,
|
|
165
|
-
'&:hover': {
|
|
166
|
-
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
|
167
|
-
},
|
|
168
|
-
'& .MuiTouchRipple-root': {
|
|
169
|
-
color: '#fff',
|
|
170
|
-
},
|
|
171
|
-
'&.Mui-selected': {
|
|
172
|
-
color: '#fff',
|
|
173
|
-
backgroundColor: 'rgba(255, 255, 255, 0.2)',
|
|
174
|
-
},
|
|
175
|
-
'& .MuiSvgIcon-root': {
|
|
176
|
-
color: '#fff',
|
|
177
|
-
},
|
|
178
|
-
...(item.hasleftborder === 'true' && {
|
|
179
|
-
borderLeft: '1px solid white',
|
|
180
|
-
}),
|
|
181
|
-
...(item.hasrightborder === 'true' && {
|
|
182
|
-
borderRight: '1px solid white',
|
|
183
|
-
}),
|
|
184
|
-
}}
|
|
185
|
-
/>
|
|
186
|
-
))}
|
|
187
|
-
</MuiTabs>
|
|
188
|
-
</Box>
|
|
189
|
-
</Box>
|
|
190
|
-
</Toolbar>
|
|
140
|
+
/>
|
|
141
|
+
))}
|
|
142
|
+
</MuiTabs>
|
|
191
143
|
</AppBar>
|
|
192
144
|
)
|
|
193
145
|
}
|