goobs-frontend 0.7.59 → 0.7.60
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 +2 -2
- package/src/components/ConfirmationCodeInput/index.tsx +1 -1
- package/src/components/Content/Structure/link/useLink.tsx +2 -1
- package/src/components/Nav/VerticalVariant/index.tsx +42 -74
- package/src/components/PricingTable/index.tsx +2 -5
- package/src/components/StyledComponent/hooks/useDropdown.tsx +7 -50
- package/src/components/Typography/index.tsx +18 -54
- package/src/index.ts +1 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goobs-frontend",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.60",
|
|
4
4
|
"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.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@mui/icons-material": "^5.16.0",
|
|
29
29
|
"@mui/material": "^5.16.0",
|
|
30
30
|
"@types/lodash": "^4.17.6",
|
|
31
|
-
"goobs-cache": "^1.3.
|
|
31
|
+
"goobs-cache": "^1.3.2",
|
|
32
32
|
"highlight.js": "^11.10.0",
|
|
33
33
|
"lodash": "^4.17.21",
|
|
34
34
|
"next": "14.2.5"
|
|
@@ -55,11 +55,12 @@ const useLink = (grid: {
|
|
|
55
55
|
...cellconfig,
|
|
56
56
|
},
|
|
57
57
|
component: (
|
|
58
|
-
<Link key={`link-${index}`} href={link} passHref
|
|
58
|
+
<Link key={`link-${index}`} href={link} passHref>
|
|
59
59
|
<Typography
|
|
60
60
|
text={text}
|
|
61
61
|
fontvariant={fontvariant}
|
|
62
62
|
fontcolor={fontcolor}
|
|
63
|
+
{...restProps}
|
|
63
64
|
/>
|
|
64
65
|
</Link>
|
|
65
66
|
),
|
|
@@ -4,7 +4,6 @@ import React from 'react'
|
|
|
4
4
|
import {
|
|
5
5
|
Drawer,
|
|
6
6
|
Box,
|
|
7
|
-
Typography,
|
|
8
7
|
Stack,
|
|
9
8
|
Divider,
|
|
10
9
|
MenuItem,
|
|
@@ -24,33 +23,25 @@ import {
|
|
|
24
23
|
ocean,
|
|
25
24
|
semiTransparentWhite,
|
|
26
25
|
} from '../../../styles/palette'
|
|
26
|
+
import { Typography } from './../../Typography'
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* Interface for the props of the VerticalVariant component
|
|
30
|
-
*/
|
|
31
28
|
export interface VerticalVariantProps {
|
|
32
|
-
items: (NavProps | SubNav | View)[]
|
|
33
|
-
showSearchbar: boolean
|
|
34
|
-
showDropdown: boolean
|
|
35
|
-
showTitle: boolean
|
|
36
|
-
showLine: boolean
|
|
37
|
-
verticalNavTitle: string
|
|
38
|
-
dropdownLabel: string
|
|
39
|
-
searchbarLabel: string
|
|
40
|
-
anchor: 'left' | 'right'
|
|
41
|
-
expandedNavs: string[]
|
|
42
|
-
setExpandedNavs: React.Dispatch<React.SetStateAction<string[]>>
|
|
43
|
-
expandedSubnavs: string[]
|
|
44
|
-
setExpandedSubnavs: React.Dispatch<React.SetStateAction<string[]>>
|
|
45
|
-
verticalNavWidth: string
|
|
46
|
-
selectedNav?: string // Currently selected navigation item
|
|
29
|
+
items: (NavProps | SubNav | View)[]
|
|
30
|
+
showSearchbar: boolean
|
|
31
|
+
showDropdown: boolean
|
|
32
|
+
showTitle: boolean
|
|
33
|
+
showLine: boolean
|
|
34
|
+
verticalNavTitle: string
|
|
35
|
+
dropdownLabel: string
|
|
36
|
+
searchbarLabel: string
|
|
37
|
+
anchor: 'left' | 'right'
|
|
38
|
+
expandedNavs: string[]
|
|
39
|
+
setExpandedNavs: React.Dispatch<React.SetStateAction<string[]>>
|
|
40
|
+
expandedSubnavs: string[]
|
|
41
|
+
setExpandedSubnavs: React.Dispatch<React.SetStateAction<string[]>>
|
|
42
|
+
verticalNavWidth: string
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
/**
|
|
50
|
-
* VerticalVariant component for rendering a vertical navigation drawer
|
|
51
|
-
* @param {VerticalVariantProps} props - The props for the component
|
|
52
|
-
* @returns {JSX.Element} The rendered VerticalVariant component
|
|
53
|
-
*/
|
|
54
45
|
function VerticalVariant({
|
|
55
46
|
items,
|
|
56
47
|
showSearchbar,
|
|
@@ -66,30 +57,13 @@ function VerticalVariant({
|
|
|
66
57
|
expandedSubnavs,
|
|
67
58
|
setExpandedSubnavs,
|
|
68
59
|
verticalNavWidth,
|
|
69
|
-
selectedNav,
|
|
70
60
|
}: VerticalVariantProps) {
|
|
71
61
|
const router = useRouter()
|
|
72
62
|
|
|
73
|
-
// Filter and map navigation options for the dropdown
|
|
74
63
|
const navOptions = items
|
|
75
64
|
.filter((item): item is NavProps => 'title' in item && 'subnavs' in item)
|
|
76
65
|
.map(nav => nav.title ?? '')
|
|
77
66
|
|
|
78
|
-
/**
|
|
79
|
-
* Handle dropdown change event
|
|
80
|
-
* @param {React.ChangeEvent<{ value: unknown }>} event - The change event
|
|
81
|
-
*/
|
|
82
|
-
const handleDropdownChange = (
|
|
83
|
-
event: React.ChangeEvent<{ value: unknown }>
|
|
84
|
-
) => {
|
|
85
|
-
const selectedOption = event.target.value as string
|
|
86
|
-
console.log('handleDropdownChange - selectedOption:', selectedOption)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Handle navigation item click event
|
|
91
|
-
* @param {NavProps} nav - The clicked navigation item
|
|
92
|
-
*/
|
|
93
67
|
const handleNavClick = (nav: NavProps) => {
|
|
94
68
|
console.log('Clicked Nav:', nav.title)
|
|
95
69
|
if (nav.trigger === 'route') {
|
|
@@ -103,20 +77,12 @@ function VerticalVariant({
|
|
|
103
77
|
}
|
|
104
78
|
}
|
|
105
79
|
|
|
106
|
-
/**
|
|
107
|
-
* Render a navigation item (NavProps, SubNav, or View)
|
|
108
|
-
* @param {NavProps | SubNav | View} item - The item to render
|
|
109
|
-
* @param {number} level - The nesting level of the item
|
|
110
|
-
* @param {string} activeAndHoverColor - The color for active and hover states
|
|
111
|
-
* @returns {JSX.Element | null} The rendered item
|
|
112
|
-
*/
|
|
113
80
|
const renderItem = (
|
|
114
81
|
item: NavProps | SubNav | View,
|
|
115
82
|
level: number,
|
|
116
83
|
activeAndHoverColor = semiTransparentWhite.main
|
|
117
84
|
) => {
|
|
118
85
|
if ('title' in item && 'subnavs' in item) {
|
|
119
|
-
// Render NavProps item
|
|
120
86
|
const nav = item as NavProps
|
|
121
87
|
const isExpanded = expandedNavs.includes(nav.title ?? '')
|
|
122
88
|
return (
|
|
@@ -180,15 +146,12 @@ function VerticalVariant({
|
|
|
180
146
|
}}
|
|
181
147
|
onClick={() => handleNavClick(nav)}
|
|
182
148
|
>
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
{nav.title}
|
|
190
|
-
</Typography>
|
|
191
|
-
)}
|
|
149
|
+
<Typography
|
|
150
|
+
fontvariant="merrih5"
|
|
151
|
+
fontcolor={white.main}
|
|
152
|
+
text={nav.title ?? ''}
|
|
153
|
+
marginLeft={4 * level}
|
|
154
|
+
/>
|
|
192
155
|
</AccordionSummary>
|
|
193
156
|
<AccordionDetails sx={{ border: 'none', p: 0 }}>
|
|
194
157
|
<List sx={{ py: 0 }}>
|
|
@@ -200,7 +163,6 @@ function VerticalVariant({
|
|
|
200
163
|
</MuiAccordion>
|
|
201
164
|
)
|
|
202
165
|
} else if ('title' in item && 'views' in item) {
|
|
203
|
-
// Render SubNav item
|
|
204
166
|
const subnav = item as SubNav
|
|
205
167
|
const isExpanded = expandedSubnavs.includes(subnav.title ?? '')
|
|
206
168
|
if (subnav.views?.length === 0) {
|
|
@@ -225,7 +187,11 @@ function VerticalVariant({
|
|
|
225
187
|
},
|
|
226
188
|
}}
|
|
227
189
|
>
|
|
228
|
-
<Typography
|
|
190
|
+
<Typography
|
|
191
|
+
fontvariant="merrih6"
|
|
192
|
+
text={subnav.title ?? ''}
|
|
193
|
+
fontcolor={white.main}
|
|
194
|
+
/>
|
|
229
195
|
</MenuItem>
|
|
230
196
|
</Link>
|
|
231
197
|
)
|
|
@@ -290,9 +256,12 @@ function VerticalVariant({
|
|
|
290
256
|
},
|
|
291
257
|
}}
|
|
292
258
|
>
|
|
293
|
-
<Typography
|
|
294
|
-
|
|
295
|
-
|
|
259
|
+
<Typography
|
|
260
|
+
fontvariant="merrih6"
|
|
261
|
+
fontcolor={white.main}
|
|
262
|
+
text={subnav.title ?? ''}
|
|
263
|
+
marginLeft={4}
|
|
264
|
+
/>
|
|
296
265
|
</AccordionSummary>
|
|
297
266
|
<AccordionDetails sx={{ border: 'none', p: 0 }}>
|
|
298
267
|
<List sx={{ py: 0 }}>
|
|
@@ -305,7 +274,6 @@ function VerticalVariant({
|
|
|
305
274
|
)
|
|
306
275
|
}
|
|
307
276
|
} else if ('title' in item && 'route' in item) {
|
|
308
|
-
// Render View item
|
|
309
277
|
const view = item as View
|
|
310
278
|
return (
|
|
311
279
|
<Link
|
|
@@ -328,7 +296,11 @@ function VerticalVariant({
|
|
|
328
296
|
},
|
|
329
297
|
}}
|
|
330
298
|
>
|
|
331
|
-
<Typography
|
|
299
|
+
<Typography
|
|
300
|
+
fontvariant="merriparagraph"
|
|
301
|
+
text={view.title ?? ''}
|
|
302
|
+
fontcolor={white.main}
|
|
303
|
+
/>
|
|
332
304
|
</MenuItem>
|
|
333
305
|
</Link>
|
|
334
306
|
)
|
|
@@ -359,7 +331,6 @@ function VerticalVariant({
|
|
|
359
331
|
// @ts-ignore
|
|
360
332
|
px={`15px`}
|
|
361
333
|
>
|
|
362
|
-
{/* Render title if showTitle is true */}
|
|
363
334
|
{showTitle && (
|
|
364
335
|
<Box pt="0px" pb="0px">
|
|
365
336
|
<Link
|
|
@@ -367,13 +338,14 @@ function VerticalVariant({
|
|
|
367
338
|
passHref
|
|
368
339
|
style={{ textDecoration: 'none' }}
|
|
369
340
|
>
|
|
370
|
-
<Typography
|
|
371
|
-
|
|
372
|
-
|
|
341
|
+
<Typography
|
|
342
|
+
fontvariant="merrih4"
|
|
343
|
+
fontcolor={white.main}
|
|
344
|
+
text={verticalNavTitle}
|
|
345
|
+
/>
|
|
373
346
|
</Link>
|
|
374
347
|
</Box>
|
|
375
348
|
)}
|
|
376
|
-
{/* Render dropdown and searchbar if either showDropdown or showSearchbar is true */}
|
|
377
349
|
{(showDropdown || showSearchbar) && (
|
|
378
350
|
<Stack mt={1} spacing={1}>
|
|
379
351
|
{showDropdown && (
|
|
@@ -382,8 +354,6 @@ function VerticalVariant({
|
|
|
382
354
|
componentvariant="dropdown"
|
|
383
355
|
outlinecolor="none"
|
|
384
356
|
options={navOptions}
|
|
385
|
-
value={selectedNav || navOptions[0]}
|
|
386
|
-
onChange={handleDropdownChange}
|
|
387
357
|
backgroundcolor={white.main}
|
|
388
358
|
shrunklabellocation="above"
|
|
389
359
|
shrunkfontcolor={white.main}
|
|
@@ -404,7 +374,6 @@ function VerticalVariant({
|
|
|
404
374
|
</Stack>
|
|
405
375
|
)}
|
|
406
376
|
</Box>
|
|
407
|
-
{/* Render divider line if showLine is true */}
|
|
408
377
|
{showLine && (
|
|
409
378
|
<Divider
|
|
410
379
|
sx={{
|
|
@@ -414,7 +383,6 @@ function VerticalVariant({
|
|
|
414
383
|
}}
|
|
415
384
|
/>
|
|
416
385
|
)}
|
|
417
|
-
{/* Render navigation items */}
|
|
418
386
|
{items.map(item => renderItem(item, 0))}
|
|
419
387
|
</Drawer>
|
|
420
388
|
)
|
|
@@ -88,9 +88,7 @@ const PricingTable: React.FC<PricingProps> = props => {
|
|
|
88
88
|
const config: PricingProps = { ...defaultConfig, ...props }
|
|
89
89
|
|
|
90
90
|
// State for selected package
|
|
91
|
-
const [selectedPackage
|
|
92
|
-
'goobs-frontend-unlimited'
|
|
93
|
-
)
|
|
91
|
+
const [selectedPackage] = useState<string>('goobs-frontend-unlimited')
|
|
94
92
|
|
|
95
93
|
const router = useRouter()
|
|
96
94
|
|
|
@@ -130,8 +128,7 @@ const PricingTable: React.FC<PricingProps> = props => {
|
|
|
130
128
|
value={selectedPackage}
|
|
131
129
|
outlinecolor={black.main}
|
|
132
130
|
backgroundcolor={semiTransparentBlack.main}
|
|
133
|
-
options={['
|
|
134
|
-
onChange={e => setSelectedPackage(e.target.value)}
|
|
131
|
+
options={['ThothOS']}
|
|
135
132
|
/>
|
|
136
133
|
),
|
|
137
134
|
})
|
|
@@ -13,12 +13,6 @@ const StyledSelectMenu = styled(MenuItem)({
|
|
|
13
13
|
},
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* useDropdown hook provides functionality for rendering a dropdown menu and handling option selection.
|
|
18
|
-
* @param props The props for the dropdown component.
|
|
19
|
-
* @param inputBoxRef A reference to the input box element.
|
|
20
|
-
* @returns An object containing the necessary state and handlers for the dropdown.
|
|
21
|
-
*/
|
|
22
16
|
export const useDropdown = (
|
|
23
17
|
props: StyledComponentProps,
|
|
24
18
|
inputBoxRef: React.RefObject<HTMLDivElement>
|
|
@@ -26,39 +20,22 @@ export const useDropdown = (
|
|
|
26
20
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false)
|
|
27
21
|
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)
|
|
28
22
|
const [filteredOptions, setFilteredOptions] = useState<string[]>([])
|
|
29
|
-
const [selectedOption, setSelectedOption] = useState(
|
|
23
|
+
const [selectedOption, setSelectedOption] = useState('')
|
|
30
24
|
const [isDropdownFocused, setIsDropdownFocused] = useState(false)
|
|
31
|
-
const { componentvariant, options,
|
|
25
|
+
const { componentvariant, options, value } = props
|
|
32
26
|
|
|
33
|
-
/**
|
|
34
|
-
* useEffect hook to update the filtered options and handle default value selection.
|
|
35
|
-
*/
|
|
36
27
|
useEffect(() => {
|
|
37
28
|
if (componentvariant === 'dropdown' && options) {
|
|
38
29
|
setFilteredOptions([...options])
|
|
39
|
-
if (defaultValue && options.includes(defaultValue) && !selectedOption) {
|
|
40
|
-
setSelectedOption(defaultValue)
|
|
41
|
-
if (onChange) {
|
|
42
|
-
onChange({
|
|
43
|
-
target: { value: defaultValue },
|
|
44
|
-
} as React.ChangeEvent<HTMLInputElement>)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
30
|
}
|
|
48
|
-
}, [componentvariant, options
|
|
31
|
+
}, [componentvariant, options])
|
|
49
32
|
|
|
50
|
-
/**
|
|
51
|
-
* useEffect hook to update the selected option when the value prop changes.
|
|
52
|
-
*/
|
|
53
33
|
useEffect(() => {
|
|
54
34
|
if (value !== undefined) {
|
|
55
35
|
setSelectedOption(value)
|
|
56
36
|
}
|
|
57
37
|
}, [value])
|
|
58
38
|
|
|
59
|
-
/**
|
|
60
|
-
* handleDropdownClick function toggles the dropdown menu when the input box is clicked.
|
|
61
|
-
*/
|
|
62
39
|
const handleDropdownClick = useCallback(() => {
|
|
63
40
|
if (componentvariant === 'dropdown') {
|
|
64
41
|
setAnchorEl(inputBoxRef.current)
|
|
@@ -66,28 +43,11 @@ export const useDropdown = (
|
|
|
66
43
|
}
|
|
67
44
|
}, [componentvariant, inputBoxRef, isDropdownOpen])
|
|
68
45
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*/
|
|
74
|
-
const handleOptionSelect = useCallback(
|
|
75
|
-
(option: string) => {
|
|
76
|
-
setSelectedOption(option)
|
|
77
|
-
if (onChange) {
|
|
78
|
-
onChange({
|
|
79
|
-
target: { value: option },
|
|
80
|
-
} as React.ChangeEvent<HTMLInputElement>)
|
|
81
|
-
}
|
|
82
|
-
setIsDropdownOpen(false)
|
|
83
|
-
},
|
|
84
|
-
[onChange]
|
|
85
|
-
)
|
|
46
|
+
const handleOptionSelect = useCallback((option: string) => {
|
|
47
|
+
setSelectedOption(option)
|
|
48
|
+
setIsDropdownOpen(false)
|
|
49
|
+
}, [])
|
|
86
50
|
|
|
87
|
-
/**
|
|
88
|
-
* handleInputFocus function updates the isDropdownFocused state when the input box is focused or blurred.
|
|
89
|
-
* @param focused A boolean indicating whether the input box is focused.
|
|
90
|
-
*/
|
|
91
51
|
const handleInputFocus = useCallback(
|
|
92
52
|
(focused: boolean) => {
|
|
93
53
|
if (componentvariant === 'dropdown') {
|
|
@@ -101,9 +61,6 @@ export const useDropdown = (
|
|
|
101
61
|
return {}
|
|
102
62
|
}
|
|
103
63
|
|
|
104
|
-
/**
|
|
105
|
-
* renderMenu variable renders the dropdown menu when the anchor element is available and the dropdown is open.
|
|
106
|
-
*/
|
|
107
64
|
const renderMenu = anchorEl !== null && isDropdownOpen !== undefined && (
|
|
108
65
|
<Menu
|
|
109
66
|
anchorEl={anchorEl}
|
|
@@ -3,18 +3,11 @@
|
|
|
3
3
|
import {
|
|
4
4
|
Typography as MuiTypography,
|
|
5
5
|
TypographyProps as MuiTypographyProps,
|
|
6
|
-
TypographyPropsVariantOverrides as MuiTypographyPropsVariantOverrides,
|
|
7
6
|
} from '@mui/material'
|
|
8
7
|
import React from 'react'
|
|
9
8
|
|
|
10
|
-
/**
|
|
11
|
-
* Type definition for supported font families
|
|
12
|
-
*/
|
|
13
9
|
export type FontFamily = 'arapey' | 'inter' | 'merri'
|
|
14
10
|
|
|
15
|
-
/**
|
|
16
|
-
* Type definition for typography variants
|
|
17
|
-
*/
|
|
18
11
|
export type TypographyVariant =
|
|
19
12
|
| 'h1'
|
|
20
13
|
| 'h2'
|
|
@@ -26,33 +19,15 @@ export type TypographyVariant =
|
|
|
26
19
|
| 'helperheader'
|
|
27
20
|
| 'helperfooter'
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
* Extend Material-UI's TypographyPropsVariantOverrides to include custom variants
|
|
31
|
-
*/
|
|
32
|
-
declare module '@mui/material/Typography' {
|
|
33
|
-
interface TypographyPropsVariantOverrides
|
|
34
|
-
extends Record<`${FontFamily}${TypographyVariant}`, true> {}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Custom type for TypographyPropsVariantOverrides
|
|
39
|
-
*/
|
|
40
|
-
export type TypographyPropsVariantOverrides =
|
|
41
|
-
MuiTypographyPropsVariantOverrides &
|
|
42
|
-
Record<`${FontFamily}${TypographyVariant}`, true>
|
|
22
|
+
type CustomTypographyVariant = `${FontFamily}${TypographyVariant}`
|
|
43
23
|
|
|
44
|
-
|
|
45
|
-
* Props interface for the custom Typography component
|
|
46
|
-
*/
|
|
47
|
-
export interface TypographyProps {
|
|
24
|
+
export interface TypographyProps extends Omit<MuiTypographyProps, 'variant'> {
|
|
48
25
|
text?: string
|
|
49
|
-
fontvariant?:
|
|
26
|
+
fontvariant?: CustomTypographyVariant
|
|
50
27
|
fontcolor?: string
|
|
28
|
+
variant?: CustomTypographyVariant | MuiTypographyProps['variant']
|
|
51
29
|
}
|
|
52
30
|
|
|
53
|
-
/**
|
|
54
|
-
* arapeyStyles object contains the styles for typography variants using the Arapey font family.
|
|
55
|
-
*/
|
|
56
31
|
const arapeyStyles: Record<TypographyVariant, React.CSSProperties> = {
|
|
57
32
|
h1: {
|
|
58
33
|
fontFamily: 'Arapey, serif',
|
|
@@ -110,9 +85,6 @@ const arapeyStyles: Record<TypographyVariant, React.CSSProperties> = {
|
|
|
110
85
|
},
|
|
111
86
|
}
|
|
112
87
|
|
|
113
|
-
/**
|
|
114
|
-
* interStyles object contains the styles for typography variants using the Inter font family.
|
|
115
|
-
*/
|
|
116
88
|
const interStyles: Record<TypographyVariant, React.CSSProperties> = {
|
|
117
89
|
h1: {
|
|
118
90
|
fontFamily: 'Inter, sans-serif',
|
|
@@ -170,9 +142,6 @@ const interStyles: Record<TypographyVariant, React.CSSProperties> = {
|
|
|
170
142
|
},
|
|
171
143
|
}
|
|
172
144
|
|
|
173
|
-
/**
|
|
174
|
-
* merriStyles object contains the styles for typography variants using the Merriweather font family.
|
|
175
|
-
*/
|
|
176
145
|
const merriStyles: Record<TypographyVariant, React.CSSProperties> = {
|
|
177
146
|
h1: {
|
|
178
147
|
fontFamily: 'Merriweather, serif',
|
|
@@ -230,43 +199,38 @@ const merriStyles: Record<TypographyVariant, React.CSSProperties> = {
|
|
|
230
199
|
},
|
|
231
200
|
}
|
|
232
201
|
|
|
233
|
-
|
|
234
|
-
* Typography component is a wrapper around MuiTypography that applies custom styles based on the fontvariant prop.
|
|
235
|
-
* It supports different font families (Arapey, Inter, Merriweather) and typography variants (h1, h2, h3, h4, h5, h6, paragraph, helperheader, helperfooter).
|
|
236
|
-
* @param {TypographyProps & MuiTypographyProps} props - The props for the Typography component.
|
|
237
|
-
* @returns {JSX.Element} The rendered Typography component.
|
|
238
|
-
*/
|
|
239
|
-
export const Typography: React.FC<TypographyProps & MuiTypographyProps> = ({
|
|
202
|
+
export const Typography: React.FC<TypographyProps> = ({
|
|
240
203
|
text,
|
|
241
204
|
fontcolor,
|
|
242
205
|
fontvariant,
|
|
206
|
+
variant,
|
|
243
207
|
...rest
|
|
244
208
|
}) => {
|
|
245
209
|
let variantStyle: React.CSSProperties = {}
|
|
210
|
+
const actualVariant = fontvariant || variant
|
|
246
211
|
|
|
247
|
-
if (
|
|
248
|
-
|
|
249
|
-
const fontFamily = fontvariant.startsWith('arapey')
|
|
212
|
+
if (typeof actualVariant === 'string') {
|
|
213
|
+
const fontFamily = actualVariant.startsWith('arapey')
|
|
250
214
|
? 'arapey'
|
|
251
|
-
:
|
|
215
|
+
: actualVariant.startsWith('inter')
|
|
252
216
|
? 'inter'
|
|
253
|
-
:
|
|
217
|
+
: actualVariant.startsWith('merri')
|
|
254
218
|
? 'merri'
|
|
255
219
|
: null
|
|
256
220
|
|
|
257
221
|
if (fontFamily) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
222
|
+
const variantPart = actualVariant.slice(
|
|
223
|
+
fontFamily.length
|
|
224
|
+
) as TypographyVariant
|
|
261
225
|
switch (fontFamily) {
|
|
262
226
|
case 'arapey':
|
|
263
|
-
variantStyle = arapeyStyles[
|
|
227
|
+
variantStyle = arapeyStyles[variantPart] || {}
|
|
264
228
|
break
|
|
265
229
|
case 'inter':
|
|
266
|
-
variantStyle = interStyles[
|
|
230
|
+
variantStyle = interStyles[variantPart] || {}
|
|
267
231
|
break
|
|
268
232
|
case 'merri':
|
|
269
|
-
variantStyle = merriStyles[
|
|
233
|
+
variantStyle = merriStyles[variantPart] || {}
|
|
270
234
|
break
|
|
271
235
|
}
|
|
272
236
|
}
|
|
@@ -278,7 +242,7 @@ export const Typography: React.FC<TypographyProps & MuiTypographyProps> = ({
|
|
|
278
242
|
color: fontcolor,
|
|
279
243
|
...variantStyle,
|
|
280
244
|
}}
|
|
281
|
-
variant={
|
|
245
|
+
variant={actualVariant as MuiTypographyProps['variant']}
|
|
282
246
|
{...rest}
|
|
283
247
|
>
|
|
284
248
|
{text}
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,6 @@ import StyledComponent, {
|
|
|
13
13
|
import Typography, {
|
|
14
14
|
FontFamily,
|
|
15
15
|
TypographyVariant,
|
|
16
|
-
TypographyPropsVariantOverrides,
|
|
17
16
|
TypographyProps,
|
|
18
17
|
} from './components/Typography'
|
|
19
18
|
import ConfirmationCodeInput, {
|
|
@@ -172,12 +171,7 @@ export type { ButtonAlignment }
|
|
|
172
171
|
export type { CustomGridProps }
|
|
173
172
|
export type { Alignment, BorderProp, columnconfig, gridconfig, cellconfig }
|
|
174
173
|
export type { StyledComponentProps }
|
|
175
|
-
export type {
|
|
176
|
-
FontFamily,
|
|
177
|
-
TypographyVariant,
|
|
178
|
-
TypographyPropsVariantOverrides,
|
|
179
|
-
TypographyProps,
|
|
180
|
-
}
|
|
174
|
+
export type { FontFamily, TypographyVariant, TypographyProps }
|
|
181
175
|
export type { ConfirmationCodeInputsProps }
|
|
182
176
|
export type { RadioOption, RadioGroupProps }
|
|
183
177
|
export type { PopupFormProps }
|