-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtailwind.settings.fontSizes.js
45 lines (41 loc) · 1.24 KB
/
tailwind.settings.fontSizes.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
/*
* Tailwind Font Size Settings
*/
const settings = require('./tailwind.settings');
const fsMin = settings.typography.fontSizeMin;
const fsMax = settings.typography.fontSizeMax;
const msFactorMin = settings.typography.msFactorMin;
const msFactorMax = settings.typography.msFactorMax;
const screenMin = settings.screensRem.min;
const screenMax = settings.screensRem['2xl'];
// Calc Min and Max Fontsize
const calcMulti = (multiMin = 0, multiMax = null) => {
return {
fsMin: fsMin * Math.pow(msFactorMin, multiMin),
fsMax: fsMax * Math.pow(msFactorMax, multiMax || multiMin),
};
};
// build the clamp property
const clamp = (multiMin = 0, multiMax = null) => {
const _calcMulti = calcMulti(multiMin, multiMax || multiMin);
const _fsMin = _calcMulti.fsMin;
const _fsMax = _calcMulti.fsMax;
return `clamp(${_fsMin}rem, calc(${_fsMin}rem + (${_fsMax} - ${_fsMin}) * ((100vw - ${screenMin}rem) / (${screenMax} - ${screenMin}))), ${_fsMax}rem)`;
};
module.exports = {
'3xs': clamp(-4),
'2xs': clamp(-3),
xs: clamp(-2),
sm: clamp(-1),
base: clamp(0),
lg: clamp(1),
xl: clamp(2),
'2xl': clamp(3),
'3xl': clamp(4),
'4xl': clamp(5),
'5xl': clamp(6),
'6xl': clamp(7),
'7xl': clamp(8),
'8xl': clamp(9),
'9xl': clamp(10),
};