refactor: flex basis plugin with options
This commit is contained in:
parent
317e1c10b7
commit
649fce7b67
|
@ -1,11 +1,21 @@
|
||||||
let plugin = require("tailwindcss/plugin");
|
let plugin = require("tailwindcss/plugin");
|
||||||
|
|
||||||
let flexBasisPlugin = plugin(function ({ addBase, addUtilities }) {
|
let flexBasisPlugin = plugin.withOptions(
|
||||||
let values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
|
function (options) {
|
||||||
|
return function ({ addUtilities }) {
|
||||||
|
let values = options?.values ?? [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
|
||||||
|
|
||||||
values.forEach((value) => {
|
values.forEach((value) => {
|
||||||
addUtilities({ [`.flex-basis-${value}`]: { flexBasis: `${value}%` } });
|
addUtilities({ [`.flex-basis-${value}`]: { flexBasis: `${value}%` } });
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
function (options) {
|
||||||
|
return {
|
||||||
|
values: options?.values ?? [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = flexBasisPlugin;
|
module.exports = flexBasisPlugin;
|
||||||
|
|
Loading…
Reference in a new issue