Last active
May 26, 2022 02:18
-
-
Save yuheiy/f9165ad3e51acf4843ee1602c7ee06cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const plugin = require("tailwindcss/plugin"); | |
const fontFeature = plugin(function () { | |
const tags = { | |
locl: 1, | |
palt: 0, | |
}; | |
const cssFontFeatureSettingsValue = Object.keys(tags) | |
.map((tag) => `"${tag}" var(--tw-${tag})`) | |
.join(", "); | |
const defaults = {}; | |
for (const [key, value] of Object.entries(tags)) { | |
defaults[`--tw-${key}`] = value.toString(); | |
} | |
const utilities = {}; | |
for (const tag of Object.keys(tags)) { | |
utilities[`.${tag}`] = { | |
"@defaults font-feature-settings": {}, | |
[`--tw-${tag}`]: "1", | |
"font-feature-settings": cssFontFeatureSettingsValue, | |
}; | |
utilities[`.not-${tag}`] = { | |
"@defaults font-feature-settings": {}, | |
[`--tw-${tag}`]: "0", | |
"font-feature-settings": cssFontFeatureSettingsValue, | |
}; | |
} | |
return function ({ addDefaults, addUtilities }) { | |
addDefaults("font-feature-settings", defaults); | |
addUtilities(utilities); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment