forked from cwsdigital/tailwind-utopia
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
57 lines (50 loc) · 1.41 KB
/
index.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
const plugin = require('tailwindcss/plugin')
const text = require('./lib/text')
const spacing = require('./lib/spacing')
const defaultOptions = {
prefix: 'fl-',
baseKey: 'base'
}
module.exports = plugin.withOptions(function (options) {
options = Object.assign({}, defaultOptions, options)
return function ({ addBase, theme }) {
const { minWidth, maxWidth } = theme('utopia')
addBase({
':root': {
'--fluid-min-width': minWidth.toString(),
'--fluid-max-width': maxWidth.toString(),
'--fluid-screen': '100vw',
'--fluid-bp': `calc(
(var(--fluid-screen) - var(--fluid-min-width) / 16 * 1rem) /
(var(--fluid-max-width) - var(--fluid-min-width))
)`
},
[`@media (min-width: ${maxWidth}px)`]: {
':root': {
'--fluid-screen': 'calc(var(--fluid-max-width) * 1px)'
}
}
})
addBase({ ':root': text.customProperties(theme, options) })
}
}, function (options) {
options = Object.assign({}, defaultOptions, options)
return {
theme: {
extend: {
fontSize: theme => text.sizes(theme, options),
spacing: theme => spacing.sizes(theme, options)
},
utopia: {
minWidth: 320,
minSize: 21,
minScale: 1.2,
maxWidth: 1140,
maxSize: 24,
maxScale: 1.25,
spacing: spacing.defaults,
fontSize: text.defaults
}
}
}
})