generated from creme332/mantine-next-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththeme.ts
60 lines (54 loc) · 1.37 KB
/
theme.ts
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
import {
createTheme,
Button,
Group,
MantineProvider,
defaultVariantColorsResolver,
VariantColorsResolver,
parseThemeColor,
rem,
rgba,
darken,
} from "@mantine/core";
const variantColorResolver: VariantColorsResolver = (input) => {
const defaultResolvedColors = defaultVariantColorsResolver(input);
const parsedColor = parseThemeColor({
color: input.color || input.theme.primaryColor,
theme: input.theme,
});
// Override some properties for variant
if (
parsedColor.isThemeColor &&
parsedColor.color === "lime" &&
input.variant === "filled"
) {
return {
...defaultResolvedColors,
color: "var(--mantine-color-black)",
hoverColor: "var(--mantine-color-black)",
};
}
// Completely override variant
if (input.variant === "light") {
return {
background: rgba(parsedColor.value, 0.1),
hover: rgba(parsedColor.value, 0.15),
border: `${rem(1)} solid ${parsedColor.value}`,
color: darken(parsedColor.value, 0.1),
};
}
// Add new variants support
if (input.variant === "danger") {
return {
background: "var(--mantine-color-red-9)",
hover: "var(--mantine-color-red-8)",
color: "var(--mantine-color-white)",
border: "none",
};
}
return defaultResolvedColors;
};
export const theme = createTheme({
primaryColor: "orange",
variantColorResolver,
});