-
Notifications
You must be signed in to change notification settings - Fork 76
/
tailwind.config.js
194 lines (180 loc) · 5.8 KB
/
tailwind.config.js
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// Please read the Theming.md file on Tweaking colors before applying changes to this file.
const plugin = require('tailwindcss/plugin')
const uiColors = require('@tailwindcss/ui/colors')
const fs = require('fs')
const yaml = require('js-yaml')
// Fetching the theme config
let themeConfig
const themeFile = './theme/tailwind.config.yml'
try {
let fileContents = fs.readFileSync(themeFile, 'utf8')
themeConfig = yaml.safeLoad(fileContents)
} catch (e) {
console.log(e)
}
// Setting defaults
let themeColors = {
primary: uiColors.indigo,
secondary: uiColors.purple,
}
// Parsing the theme config
Object.keys(themeColors).forEach((themeColor) => {
if (themeConfig && themeConfig.colors && Object.keys(themeConfig.colors).length > 0) {
if (themeConfig.colors[themeColor]) {
if (typeof themeConfig.colors[themeColor] === 'string' && themeConfig.colors[themeColor].startsWith('tailwind/ui/')) {
themeColors[themeColor] = uiColors[themeConfig.colors[themeColor].replace('tailwind/ui/', '')]
// arbitrary checking if this object has keys 50 & 900 corresponding to the tailwind color system
} else if (themeConfig.colors[themeColor][50] && themeConfig.colors[themeColor][900]) {
themeColors[themeColor] = themeConfig.colors[themeColor]
}
}
}
})
module.exports = {
theme: {
extend: {
colors: {
smoke: 'rgba(0, 0, 0, 0.5)',
primary: {
...themeColors.primary,
},
secondary: {
...themeColors.secondary,
},
'hero-black': '#3D3D3D',
'cat-education': '#F82B2B',
'cat-social-justice': '#FD813B',
'cat-business-directory': '#8921DC',
'cat-health': '#2987DE',
'cat-wealth': '#12CFA1',
},
maxHeight: {
'400px': '400px',
},
minHeight: {
'400px': '400px',
},
boxShadow: {
users: '0px 3px 16px rgba(0, 0, 0, 0.15)',
},
borderRadius: {
xl: '1.5rem',
}
},
container: {
center: true,
},
fontFamily: {
sans: 'Roboto, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
serif: '"Lora", Georgia, Cambria, "Times New Roman", Times, serif',
},
},
variants: {
translate: ['responsive', 'hover', 'focus', 'group-hover'],
display: ['responsive', 'hover', 'focus', 'group-hover'],
},
plugins: [
require('@tailwindcss/ui'),
/*
* Spacing utilities
* Ex: .space-y-bottom-2 space-x-right-4
*/
plugin(function ({ addUtilities, theme }) {
const property = 'margin'
const axes = ['x', 'y']
const directions = {
x: ['right', 'left'],
y: ['top', 'bottom'],
}
let utilities = {}
axes.forEach((axis) => {
directions[axis].forEach((direction) => {
const spacing = []
Object.keys(theme('spacing')).filter((key) => {
// fetching only the absolute values (numbers, no 1/2, 3/5, etc.)
if (!key.includes('/')) {
spacing[key] = theme('spacing')[key];
}
})
Object.keys(spacing).forEach((key) => {
const value = spacing[key]
const className = `.space-${axis}-${direction}-${key}`
const childrenProperties = {}
childrenProperties[`${property}-${direction}`] = value
const properties = {
'>*': childrenProperties,
}
utilities[className] = properties
})
})
})
addUtilities(utilities, { variants: ['responsive'] })
}),
plugin(function ({ addUtilities, theme }) {
const utilities = {
'.grid-auto-row-1fr': {
'grid-auto-rows': '1fr'
}
}
addUtilities(utilities)
}),
// buttons
plugin(function ({ addComponents, theme }) {
const styles = {
display: 'inline-flex',
alignItems: 'center',
fontSize: theme('fontSize.sm'),
padding: `${theme('spacing.2')} ${theme('spacing.4')}`,
fill: 'currentColor',
whiteSpace: 'nowrap',
backgroundColor: theme('colors.white'),
color: theme('colors.gray.900'),
border: `1px solid ${theme('colors.gray.100')}`,
transitionProperty: theme('transitionProperty.default'),
transitionDuration: theme('transitionDuration.100'),
borderRadius: theme('borderRadius.default'),
boxShadow: theme('boxShadow.default'),
'&:hover': {
backgroundColor: theme('colors.gray.100'),
},
'&:active': {
backgroundColor: theme('colors.gray.200'),
},
}
const buttons = {
'@variants responsive': {
'.button': {
...styles,
'&.button-lg': {
padding: `${theme('spacing.3')} ${theme('spacing.6')}`,
fontSize: theme('fontSize.lg'),
},
'&.button-sm': {
padding: `${theme('spacing.1')} ${theme('spacing.2')}`,
fontSize: theme('fontSize.sm'),
},
'&.button-xl': {
padding: `${theme('spacing.4')} ${theme('spacing.10')}`,
fontSize: theme('fontSize.2xl'),
},
},
'.button-primary': {
...styles,
color: theme('colors.white'),
backgroundColor: theme('colors.primary.600'),
'&:hover': {
backgroundColor: theme('colors.primary.700'),
},
'&:active': {
backgroundColor: theme('colors.primary.800'),
},
'&1active': {
backgroundColor: theme('colors.primary.800'),
},
}
},
}
addComponents(buttons)
})
],
}