-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
25 lines (23 loc) · 665 Bytes
/
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
const plugin = require('tailwindcss/plugin');
const _ = require('lodash');
module.exports = plugin(function({ theme, variants, e, addUtilities }) {
const aspectRatioUtilities = _.fromPairs(
_.map(theme('aspectRatio'), (value, modifier) => {
const aspectRatio = _.isArray(value) ? value[0] / value[1] : value;
return [
`.${e(`aspect-ratio-${modifier}`)}`,
{
paddingBottom: aspectRatio == 0 ? '0' : `${1 / aspectRatio * 100}%`,
},
];
})
);
addUtilities(aspectRatioUtilities, variants('aspectRatio'));
}, {
theme: {
aspectRatio: {},
},
variants: {
aspectRatio: ['responsive'],
},
});