|
1 | | -import { createSystem, defaultConfig } from "@chakra-ui/react" |
2 | | -import { buttonRecipe } from "./theme/button.recipe" |
| 1 | +import { |
| 2 | + extendTheme, |
| 3 | + createMultiStyleConfigHelpers, |
| 4 | + Textarea, |
| 5 | + defineStyle, |
| 6 | + defineStyleConfig, |
| 7 | +} from "@chakra-ui/react"; |
| 8 | +import { sliderAnatomy as parts } from "@chakra-ui/anatomy"; |
| 9 | +import { inputAnatomy, } from "@chakra-ui/anatomy"; |
3 | 10 |
|
4 | | -export const system = createSystem(defaultConfig, { |
5 | | - globalCss: { |
6 | | - html: { |
7 | | - fontSize: "16px", |
| 11 | + |
| 12 | + |
| 13 | +const { definePartsStyle, defineMultiStyleConfig } = |
| 14 | + createMultiStyleConfigHelpers(inputAnatomy.keys); |
| 15 | + |
| 16 | +const textareaoutline = defineStyle({ |
| 17 | + border: "2px dashed", // change the appearance of the border |
| 18 | + borderRadius: 0, |
| 19 | + bg: "white", |
| 20 | + // remove the border radius |
| 21 | + fontWeight: "semibold", // change the font weight |
| 22 | + _hover: { |
| 23 | + bg: "green.50", |
| 24 | + borderColor: "009688", |
| 25 | + _dark: { |
| 26 | + bg: "whiteAlpha.100", |
| 27 | + } |
| 28 | + }, |
| 29 | + _focus: { |
| 30 | + borderColor: "green.500", |
| 31 | + borderWidth: 2, |
| 32 | + _dark: { |
| 33 | + bg: "whiteAlpha.100", |
| 34 | + }, |
| 35 | + }, |
| 36 | +}); |
| 37 | + |
| 38 | +const textareaTheme = defineStyleConfig({ |
| 39 | + variants: { outline: textareaoutline }, |
| 40 | +}); |
| 41 | +// default base style from the Input theme |
| 42 | +const baseStyle = definePartsStyle({ |
| 43 | + field: { |
| 44 | + width: "100%", |
| 45 | + minWidth: 0, |
| 46 | + outline: 0, |
| 47 | + position: "relative", |
| 48 | + appearance: "none", |
| 49 | + transitionProperty: "common", |
| 50 | + transitionDuration: "normal", |
| 51 | + _disabled: { |
| 52 | + opacity: 0.4, |
| 53 | + cursor: "not-allowed", |
8 | 54 | }, |
9 | | - body: { |
10 | | - fontSize: "0.875rem", |
11 | | - margin: 0, |
12 | | - padding: 0, |
| 55 | + }, |
| 56 | +}); |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +const variantInput = definePartsStyle((props) => { |
| 62 | + return { |
| 63 | + field: { |
| 64 | + fontFamily: "cursive", // change font family to mono |
| 65 | + bg: "white", |
| 66 | + borderColor: "009688", |
| 67 | + fontsize: "large", |
| 68 | + |
| 69 | + _focus: { |
| 70 | + borderColor: "green.500", |
| 71 | + borderWidth: 2, |
| 72 | + _dark: { |
| 73 | + bg: "whiteAlpha.100", |
| 74 | + }, |
| 75 | + }, |
| 76 | + _hover: { |
| 77 | + bg: "green.50", |
| 78 | + borderColor: "009688", |
| 79 | + _dark: { |
| 80 | + bg: "whiteAlpha.100", |
| 81 | + }, |
| 82 | + }, |
| 83 | + }, |
| 84 | + }; |
| 85 | +}); |
| 86 | + |
| 87 | +const variantTextArea = definePartsStyle((props) => { |
| 88 | + return { |
| 89 | + field: { |
| 90 | + fontFamily: "cursive", // change font family to mono |
| 91 | + bg: "white", |
| 92 | + |
| 93 | + borderColor: "green.500", |
| 94 | + borderWidth: "2px", |
| 95 | + fontsize: "XX-large", |
| 96 | + |
| 97 | + _focus: { |
| 98 | + borderColor: "green.500", |
| 99 | + borderWidth: 2, |
| 100 | + _dark: { |
| 101 | + bg: "whiteAlpha.100", |
| 102 | + }, |
| 103 | + }, |
| 104 | + _focusWithin: { borderColor: "green.500" }, |
| 105 | + _hover: { |
| 106 | + bg: "green.500", |
| 107 | + borderColor: "009688", |
| 108 | + }, |
13 | 109 | }, |
14 | | - ".main-link": { |
15 | | - color: "ui.main", |
16 | | - fontWeight: "bold", |
| 110 | + }; |
| 111 | +}); |
| 112 | + |
| 113 | +const disabledStyles = { |
| 114 | + _disabled: { |
| 115 | + backgroundColor: "ui.light", |
| 116 | + }, |
| 117 | +}; |
| 118 | +const variants = { |
| 119 | + outline: variantInput, |
| 120 | + line: variantTextArea, |
| 121 | +}; |
| 122 | +const inputTheme = defineMultiStyleConfig({ |
| 123 | + baseStyle, |
| 124 | + variants, |
| 125 | + defaultProps: { |
| 126 | + size: "md", |
| 127 | + variant: "outline", |
| 128 | + }, |
| 129 | +}); |
| 130 | + |
| 131 | +const TextAreaTheme = defineMultiStyleConfig({ |
| 132 | + baseStyle, |
| 133 | + variants, |
| 134 | + defaultProps: { |
| 135 | + size: "md", |
| 136 | + variant: "textArea", |
| 137 | + }, |
| 138 | +}); |
| 139 | + |
| 140 | +const theme = extendTheme({ |
| 141 | + colors: { |
| 142 | + ui: { |
| 143 | + main: "#009688", |
| 144 | + secondary: "#EDF2F7", |
| 145 | + success: "#48BB78", |
| 146 | + danger: "#E53E3E", |
| 147 | + light: "B7E0FF", |
| 148 | + dark: "#1A202C", |
| 149 | + darkSlate: "#252D3D", |
| 150 | + dim: "#A0AEC0", |
17 | 151 | }, |
18 | 152 | }, |
19 | | - theme: { |
20 | | - tokens: { |
21 | | - colors: { |
22 | | - ui: { |
23 | | - main: { value: "#009688" }, |
| 153 | + components: { |
| 154 | + Textarea: textareaTheme, |
| 155 | + Input: inputTheme, |
| 156 | + Button: { |
| 157 | + variants: { |
| 158 | + primary: { |
| 159 | + backgroundColor: "ui.main", |
| 160 | + |
| 161 | + color: "white", |
| 162 | + _hover: { |
| 163 | + backgroundColor: "#00766C", |
| 164 | + }, |
| 165 | + _disabled: { |
| 166 | + ...disabledStyles, |
| 167 | + _hover: { |
| 168 | + ...disabledStyles, |
| 169 | + }, |
| 170 | + }, |
| 171 | + }, |
| 172 | + danger: { |
| 173 | + backgroundColor: "ui.danger", |
| 174 | + color: "ui.light", |
| 175 | + _hover: { |
| 176 | + backgroundColor: "#E32727", |
| 177 | + }, |
24 | 178 | }, |
25 | 179 | }, |
26 | 180 | }, |
27 | | - recipes: { |
28 | | - button: buttonRecipe, |
| 181 | + Tabs: { |
| 182 | + variants: { |
| 183 | + enclosed: { |
| 184 | + tab: { |
| 185 | + _selected: { |
| 186 | + color: "ui.main", |
| 187 | + }, |
| 188 | + }, |
| 189 | + }, |
| 190 | + }, |
29 | 191 | }, |
30 | 192 | }, |
31 | | -}) |
| 193 | + |
| 194 | + styles: { |
| 195 | + global: (props) => ({ |
| 196 | + body: { |
| 197 | + bg: "antiqueWhite", |
| 198 | + fontFamily: "cursive", |
| 199 | + fontSize: "large", |
| 200 | + }, |
| 201 | + }), |
| 202 | + }, |
| 203 | +}); |
| 204 | + |
| 205 | +export default theme; |
0 commit comments