-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathTimezoneCategoryChip.tsx
More file actions
69 lines (59 loc) · 1.64 KB
/
TimezoneCategoryChip.tsx
File metadata and controls
69 lines (59 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import {Chip} from "@mui/joy";
import {DefaultColorPalette} from "@mui/joy/styles/types/colorSystem";
import {TIMEZONE_CATEGORY} from "../../../typings/date";
import "./TimezoneCategoryChip.css";
interface TimezoneTypeMetadata {
label: string;
color: DefaultColorPalette;
}
const TIMEZONE_CATEGORY_METADATA: Record<TIMEZONE_CATEGORY, TimezoneTypeMetadata> = {
[TIMEZONE_CATEGORY.DEFAULT]: {
label: "Default",
color: "neutral",
},
[TIMEZONE_CATEGORY.BROWSER]: {
label: "Browser",
color: "warning",
},
[TIMEZONE_CATEGORY.LOGGER]: {
label: "Logger",
color: "primary",
},
[TIMEZONE_CATEGORY.MANUAL]: {
label: "Manual",
color: "success",
},
};
interface TimezoneCategoryChipProps {
category: TIMEZONE_CATEGORY;
disabled: boolean;
}
/**
* Render a chip that represents the category of the timezone.
*
* @param props
* @param props.category
* @param props.disabled
* @return
*/
const TimezoneCategoryChip = ({
category,
disabled,
}: TimezoneCategoryChipProps) => {
const isDefault = category === TIMEZONE_CATEGORY.DEFAULT;
return (
<Chip
color={TIMEZONE_CATEGORY_METADATA[category].color}
disabled={disabled}
sx={{borderRadius: "xs"}}
className={`timezone-category-chip ${isDefault ?
"timezone-category-chip-default-timezone" :
""}`}
>
{"Timezone"}
{false === isDefault && " | "}
{false === isDefault && TIMEZONE_CATEGORY_METADATA[category].label}
</Chip>
);
};
export default TimezoneCategoryChip;