-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtodesktop-variants.js
More file actions
31 lines (28 loc) · 977 Bytes
/
todesktop-variants.js
File metadata and controls
31 lines (28 loc) · 977 Bytes
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
const plugin = require("tailwindcss/plugin");
const todesktopPlugin = plugin(function ({ addVariant, e }) {
// Add support for `todesktop` modifier
// Usage: <div class="todesktop:rounded-lg">...</div>
addVariant("todesktop", ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `html.todesktop .${e(`todesktop${separator}${className}`)}`;
});
});
// Add support for `mac`, `windows` and `linux` modifiers
// Usage: <div class="mac:hidden">...</div>
const platformMap = {
darwin: "mac",
win32: "windows",
linux: "linux",
};
Object.keys(platformMap).forEach((platform) => {
const variant = platformMap[platform];
addVariant(variant, ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `html.todesktop-platform-${platform} .${e(
`${variant}${separator}${className}`
)}`;
});
});
});
});
module.exports = todesktopPlugin;