MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / tailwindPlugin

Function tailwindPlugin

src/ext/tailwind.js:1–45  ·  view source on GitHub ↗
(_hyperscript)

Source from the content-addressed store, hash-verified

1export default function tailwindPlugin(_hyperscript) {
2 _hyperscript.config.hideShowStrategies = {
3 twDisplay: function (op, element, arg) {
4 if (op === "toggle") {
5 if (element.classList.contains("hidden")) {
6 _hyperscript.config.hideShowStrategies.twDisplay("show", element, arg);
7 } else {
8 _hyperscript.config.hideShowStrategies.twDisplay("hide", element, arg);
9 }
10 } else if (op === "hide") {
11 element.classList.add('hidden');
12 } else {
13 element.classList.remove('hidden');
14 }
15 },
16
17 twVisibility: function (op, element, arg) {
18 if (op === "toggle") {
19 if (element.classList.contains("invisible")) {
20 _hyperscript.config.hideShowStrategies.twVisibility("show", element, arg);
21 } else {
22 _hyperscript.config.hideShowStrategies.twVisibility("hide", element, arg);
23 }
24 } else if (op === "hide") {
25 element.classList.add('invisible');
26 } else {
27 element.classList.remove('invisible');
28 }
29 },
30
31 twOpacity: function (op, element, arg) {
32 if (op === "toggle") {
33 if (element.classList.contains("opacity-0")) {
34 _hyperscript.config.hideShowStrategies.twOpacity("show", element, arg);
35 } else {
36 _hyperscript.config.hideShowStrategies.twOpacity("hide", element, arg);
37 }
38 } else if (op === "hide") {
39 element.classList.add('opacity-0');
40 } else {
41 element.classList.remove('opacity-0');
42 }
43 }
44 };
45}
46
47// Auto-register when imported
48if (typeof self !== 'undefined' && self._hyperscript) {

Callers

nothing calls this directly

Calls 1

containsMethod · 0.45

Tested by

no test coverage detected