-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtailwind.config.js
More file actions
128 lines (119 loc) · 2.94 KB
/
tailwind.config.js
File metadata and controls
128 lines (119 loc) · 2.94 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
const defaultTheme = require('tailwindcss/defaultTheme')
const toRgba = (hexCode, opacity = 50) => {
let hex = hexCode.replace('#', '');
if (hex.length === 3) {
hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
}
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
return `rgba(${r},${g},${b},${opacity / 100})`;
};
const flattenColorPalette = (obj, sep='-') => Object.assign(
{},
...function _flatten(o, p='') {
return [].concat(...Object.keys(o)
.map(k =>
typeof o[k] === 'object' ?
_flatten(o[k],k+sep) :
({[p+k]: o[k]})
)
);
}(obj)
);
module.exports = {
purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {
fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
},
},
fontSize: {
'2xs': '.55rem',
'1xs': '.65rem',
'xs': '.75rem',
'sm': '.875rem',
'tiny': '.875rem',
'base': '1rem',
'lg': '1.125rem',
'xl': '1.25rem',
'2xl': '1.5rem',
'3xl': '1.875rem',
'4xl': '2.25rem',
'5xl': '3rem',
'6xl': '4rem',
'7xl': '5rem',
},
keyframes: {
wiggle: {
'0%, 100%': {
transform: 'rotate(-1deg)'
},
'50%': {
transform: 'rotate(1deg)'
}
}
},
animation: {
wiggle: 'wiggle 20s ease-in-out infinite'
},
zIndex: {
'0': 0,
'10': 10,
'11': 11,
'12': 12,
'13': 13,
'14': 14,
'15': 15,
'16': 16,
'17': 17,
'18': 18,
'19': 19,
'20': 20,
'21': 21,
'30': 30,
'40': 40,
'50': 50,
'25': 25,
'50': 50,
'75': 75,
'100': 100,
'auto': 'auto',
}
},
variants: {
extend: {
display: ['group-hover'],
},
},
plugins: [
require('@tailwindcss/forms'),
function ({ addUtilities, theme }) {
const utilities = {
'.bg-stripes': {
backgroundImage:
'linear-gradient(45deg, var(--stripes-color) 12.50%, transparent 12.50%, transparent 50%, var(--stripes-color) 50%, var(--stripes-color) 62.50%, transparent 62.50%, transparent 100%)',
backgroundSize: '5.66px 5.66px',
},
}
const addColor = (name, color) =>
(utilities[`.bg-stripes-${name}`] = { '--stripes-color': color })
const colors = flattenColorPalette(theme('backgroundColor'))
for (let name in colors) {
try {
const [r, g, b, a] = toRgba(colors[name])
if (a !== undefined) {
addColor(name, colors[name])
} else {
addColor(name, `rgba(${r}, ${g}, ${b}, 0.4)`)
}
} catch (_) {
addColor(name, colors[name])
}
}
addUtilities(utilities)
},
],
}