-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
twind.ts
39 lines (34 loc) · 897 Bytes
/
twind.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
import { create, cssomSheet, ThemeConfiguration } from "twind"
import * as _colors from "twind/colors"
export function hexToRgb(hex: string, alpha?: number) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
if (!result) return hex
const r = parseInt(result[1], 16),
g = parseInt(result[2], 16),
b = parseInt(result[3], 16)
return alpha === undefined ? `rgb(${r},${g},${b})` : `rgba(${r},${g},${b}, ${alpha})`
}
export const sheet = cssomSheet({ target: new CSSStyleSheet() })
export const colors = {
black: _colors.black,
cyan: _colors.cyan,
while: _colors.white,
amber: _colors.amber,
gray: _colors.gray,
}
export const theme: ThemeConfiguration = {
colors,
minWidth: {
"1": "8px",
"2": "12px",
"3": "16px",
"4": "24px",
"5": "32px",
"6": "48px",
},
zIndex: {
"1": "1",
"9999": "9999",
},
}
export const { tw } = create({ sheet, theme })