@blockbite/tailwind 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +2 -0
- package/.tool-versions +1 -0
- package/README.md +75 -0
- package/blockbite-tailwind.code-workspace +7 -0
- package/components/anchor-position.js +110 -0
- package/components/fluid-container.js +34 -0
- package/components/grid-container.js +37 -0
- package/components/interaction.js +37 -0
- package/components/swiper.js +13 -0
- package/deprecated/fluid-container-aside.js +48 -0
- package/deprecated/fluid-container-half.js +48 -0
- package/gridarea/index.js +6 -0
- package/gridarea/utilities/area-dimensions.js +13 -0
- package/gridarea/utilities/grid-area.js +51 -0
- package/index.d.ts +17 -0
- package/index.html +46 -0
- package/index.js +30 -0
- package/lib/aspect-ratio.js +6 -0
- package/lib/colors.js +59 -0
- package/lib/container.js +10 -0
- package/lib/screens.js +13 -0
- package/lib/spacing.js +215 -0
- package/lib/theme-parser.js +83 -0
- package/motion/index.js +14 -0
- package/motion/theme.js +174 -0
- package/motion/utilities/delay.js +7 -0
- package/motion/utilities/direction.js +14 -0
- package/motion/utilities/duration.js +7 -0
- package/motion/utilities/fillMode.js +14 -0
- package/motion/utilities/iterationCount.js +14 -0
- package/motion/utilities/offset.js +11 -0
- package/motion/utilities/playState.js +14 -0
- package/motion/utilities/timingFunction.js +14 -0
- package/package.json +25 -0
- package/plugins/viewport-dimensions.js +33 -0
- package/postcss.config.js +6 -0
- package/tailwind.config.js +18 -0
- package/theme-example.json +329 -0
- package/themecolors/index.js +66 -0
- package/vite.css +8 -0
- package/vite.js +64 -0
package/.gitattributes
ADDED
package/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nodejs 22.14.0
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# blockbite-tailwind
|
|
2
|
+
|
|
3
|
+
wordpress theme.json parser to blockbite tailwind theme
|
|
4
|
+
|
|
5
|
+
https://github.com/merijnponzo/blockbite-tailwind
|
|
6
|
+
|
|
7
|
+
(for owner)
|
|
8
|
+
npm version <update_type>
|
|
9
|
+
npm publish
|
|
10
|
+
|
|
11
|
+
# extend your tailwindconfig for wordpress
|
|
12
|
+
|
|
13
|
+
• uses a 16px grid system for spacing and dimensions like p-16 or w-128, or with default prefixing b_p-16 etc
|
|
14
|
+
(easy to remember, consistent layouts)
|
|
15
|
+
• use dynamic font sizes in 8 steps, easy
|
|
16
|
+
(easy to remember, consistent layouts)
|
|
17
|
+
|
|
18
|
+
example
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
import { themeParser } from 'blockbite-tailwind'
|
|
22
|
+
const fluidContainer = require('blockbite-tailwind/components/fluid-container')
|
|
23
|
+
|
|
24
|
+
// load theme.json
|
|
25
|
+
const themeJson = require('./theme.json')
|
|
26
|
+
// parse it to tailwind values
|
|
27
|
+
// https://www.blockbite.dev/documentation/api/themeParser
|
|
28
|
+
const theme = themeParser(themeJson, {
|
|
29
|
+
prefixScreens: 'b_',
|
|
30
|
+
prefixAspectRatio: 'b_',
|
|
31
|
+
prefixContainer: 'b_',
|
|
32
|
+
prefixSpacing: 'b_',
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
/** @type {import('tailwindcss').Config} */
|
|
36
|
+
module.exports = {
|
|
37
|
+
content: [
|
|
38
|
+
'./blocks/**/*.{html,js,php}',
|
|
39
|
+
'./templates/**/*.{html,js,php}',
|
|
40
|
+
'./views/**/*.twig',
|
|
41
|
+
],
|
|
42
|
+
/* give the blockbite class a lower priority then the inline editor styles from the plugin ! */
|
|
43
|
+
important: '.theme',
|
|
44
|
+
safelist: [
|
|
45
|
+
'container-fluid',
|
|
46
|
+
'relative',
|
|
47
|
+
'w-full',
|
|
48
|
+
'-right-512',
|
|
49
|
+
'right-0',
|
|
50
|
+
'shadow-xl',
|
|
51
|
+
'bg-white',
|
|
52
|
+
],
|
|
53
|
+
theme: {
|
|
54
|
+
fontFamily: theme.fonts,
|
|
55
|
+
container: theme.container,
|
|
56
|
+
extend: {
|
|
57
|
+
fontSize: theme.fontSizes,
|
|
58
|
+
fontWeight: theme.fontWeights,
|
|
59
|
+
colors: theme.colors,
|
|
60
|
+
spacing: theme.spacing,
|
|
61
|
+
gap: theme.spacing,
|
|
62
|
+
minWidth: theme.spacing,
|
|
63
|
+
maxWidth: theme.spacing,
|
|
64
|
+
minHeight: theme.spacing,
|
|
65
|
+
maxHeight: theme.spacing,
|
|
66
|
+
aspectRatio: theme.aspectRatio,
|
|
67
|
+
screens: theme.screens,
|
|
68
|
+
backgroundImage: {
|
|
69
|
+
'bk-circle': "url('../resources/images/bgcircle.svg')",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
plugins: [fluidContainer],
|
|
74
|
+
}
|
|
75
|
+
```
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
module.exports = function ({ addComponents, theme }) {
|
|
2
|
+
const anchorTopCenter = {
|
|
3
|
+
".b_anchor-top-center": {
|
|
4
|
+
position: "absolute",
|
|
5
|
+
top: "0",
|
|
6
|
+
left: "50%",
|
|
7
|
+
transform: "translate(-50%, -50%)",
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const anchorTopLeft = {
|
|
12
|
+
".b_anchor-top-left": {
|
|
13
|
+
position: "absolute",
|
|
14
|
+
top: "0",
|
|
15
|
+
left: "0",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const anchorTopRight = {
|
|
20
|
+
".b_anchor-top-right": {
|
|
21
|
+
position: "absolute",
|
|
22
|
+
top: "0",
|
|
23
|
+
right: "0",
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const anchorBottomCenter = {
|
|
28
|
+
".b_anchor-bottom-center": {
|
|
29
|
+
position: "absolute",
|
|
30
|
+
bottom: "0",
|
|
31
|
+
left: "50%",
|
|
32
|
+
transform: "translate(-50%, 50%)",
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const anchorBottomLeft = {
|
|
37
|
+
".b_anchor-bottom-left": {
|
|
38
|
+
position: "absolute",
|
|
39
|
+
bottom: "0",
|
|
40
|
+
left: "0",
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const anchorBottomRight = {
|
|
45
|
+
".b_anchor-bottom-right": {
|
|
46
|
+
position: "absolute",
|
|
47
|
+
bottom: "0",
|
|
48
|
+
right: "0",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const anchorCenterLeft = {
|
|
53
|
+
".b_anchor-center-left": {
|
|
54
|
+
position: "absolute",
|
|
55
|
+
top: "50%",
|
|
56
|
+
left: "0",
|
|
57
|
+
transform: "translate(-50%, -50%)",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const anchorCenterRight = {
|
|
62
|
+
".b_anchor-center-right": {
|
|
63
|
+
position: "absolute",
|
|
64
|
+
top: "50%",
|
|
65
|
+
right: "0",
|
|
66
|
+
transform: "translate(50%, -50%)",
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const anchorCenterCenter = {
|
|
71
|
+
".b_anchor-center-center": {
|
|
72
|
+
position: "absolute",
|
|
73
|
+
top: "50%",
|
|
74
|
+
left: "50%",
|
|
75
|
+
transform: "translate(-50%, -50%)",
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const anchorCenterTop = {
|
|
80
|
+
".b_anchor-center-top": {
|
|
81
|
+
position: "absolute",
|
|
82
|
+
top: "0",
|
|
83
|
+
left: "50%",
|
|
84
|
+
transform: "translate(-50%, 0%)",
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const anchorCenterBottom = {
|
|
89
|
+
".b_anchor-center-bottom": {
|
|
90
|
+
position: "absolute",
|
|
91
|
+
bottom: "0",
|
|
92
|
+
left: "50%",
|
|
93
|
+
transform: "translate(-50%, 0%)",
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
addComponents([
|
|
98
|
+
anchorTopCenter,
|
|
99
|
+
anchorTopLeft,
|
|
100
|
+
anchorTopRight,
|
|
101
|
+
anchorBottomCenter,
|
|
102
|
+
anchorBottomLeft,
|
|
103
|
+
anchorBottomRight,
|
|
104
|
+
anchorCenterLeft,
|
|
105
|
+
anchorCenterRight,
|
|
106
|
+
anchorCenterCenter,
|
|
107
|
+
anchorCenterTop,
|
|
108
|
+
anchorCenterBottom,
|
|
109
|
+
]);
|
|
110
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
--b_container-fluid-xs: 98vw;
|
|
3
|
+
--b_container-fluid-xl: 95vw;
|
|
4
|
+
--b_padding: 1rem;
|
|
5
|
+
*/
|
|
6
|
+
module.exports = function ({ addComponents, theme, config }) {
|
|
7
|
+
const important = config("important");
|
|
8
|
+
const prefix = typeof important === "string" ? important : "";
|
|
9
|
+
|
|
10
|
+
const container = {
|
|
11
|
+
[`${prefix} .b_container-fluid`]: {
|
|
12
|
+
marginLeft: "auto",
|
|
13
|
+
marginRight: "auto",
|
|
14
|
+
paddingLeft: "var(--b_padding, 4vw)",
|
|
15
|
+
paddingRight: "var(--b_padding, 4vw)",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const maxWidth2xl = theme("screens.2xl");
|
|
20
|
+
// Add a media query for screens at '2xl' size
|
|
21
|
+
if (maxWidth2xl) {
|
|
22
|
+
container[`@media (min-width: ${maxWidth2xl})`] = {
|
|
23
|
+
[`${prefix} .b_container-fluid`]: {
|
|
24
|
+
maxWidth: maxWidth2xl,
|
|
25
|
+
marginLeft: "auto",
|
|
26
|
+
marginRight: "auto",
|
|
27
|
+
paddingLeft: "var(--b_padding, 1rem)",
|
|
28
|
+
paddingRight: "var(--b_padding, 1rem)",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
addComponents(container);
|
|
34
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module.exports = function ({ addComponents, theme, config }) {
|
|
2
|
+
const maxWidthLg = theme("screens.lg");
|
|
3
|
+
const maxWidth2xl = theme("screens.2xl");
|
|
4
|
+
|
|
5
|
+
const important = config("important");
|
|
6
|
+
const cssVars = config("cssVars") | false;
|
|
7
|
+
const prefix = typeof important === "string" ? important : "";
|
|
8
|
+
|
|
9
|
+
const container = {
|
|
10
|
+
[`${prefix} .b_grid-container`]: {
|
|
11
|
+
display: "grid",
|
|
12
|
+
gridTemplateColumns: "1fr repeat(12, var(--b_col-width)) 1fr!important",
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
// skip adding the breakpoint-specific variables if cssVars is false
|
|
16
|
+
if (cssVars) {
|
|
17
|
+
const breakpoints = {
|
|
18
|
+
[maxWidthLg]: {
|
|
19
|
+
"--b_col-width": "calc((100% - ((var(--b_padding, 4vw) ) * 2)) / 12)",
|
|
20
|
+
"--b_fr-size": "4vw",
|
|
21
|
+
},
|
|
22
|
+
[maxWidth2xl]: {
|
|
23
|
+
"--b_col-width": `calc((${maxWidth2xl} - (var(--b_padding, 1rem) * 2)) / 12)`,
|
|
24
|
+
"--b_padding": "var(--b_padding, 1rem)",
|
|
25
|
+
"--b_fr-size": `calc(100% - ${maxWidth2xl} / 2)`,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Add breakpoint-specific variables
|
|
30
|
+
for (const [breakpoint, vars] of Object.entries(breakpoints)) {
|
|
31
|
+
container[`@media (min-width: ${breakpoint})`] = {
|
|
32
|
+
":root": vars,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
addComponents(container);
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module.exports = function ({ addComponents }) {
|
|
2
|
+
const b_tileslide_in = {
|
|
3
|
+
".b_tile-in-left": {
|
|
4
|
+
position: "absolute!important",
|
|
5
|
+
top: 0,
|
|
6
|
+
left: 0,
|
|
7
|
+
right: 0,
|
|
8
|
+
bottom: 0,
|
|
9
|
+
zIndex: 10,
|
|
10
|
+
overflow: "hidden",
|
|
11
|
+
transition: "transform 0.5s",
|
|
12
|
+
transform: "translateX(-100%)",
|
|
13
|
+
},
|
|
14
|
+
".b_active .b_tile-in-left": {
|
|
15
|
+
transform: "translateX(0%)",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const b_tilefade_in = {
|
|
20
|
+
".b_tile-in-fade": {
|
|
21
|
+
opacity: 0,
|
|
22
|
+
transition: "opacity 0.5s",
|
|
23
|
+
position: "absolute!important",
|
|
24
|
+
top: 0,
|
|
25
|
+
left: 0,
|
|
26
|
+
right: 0,
|
|
27
|
+
bottom: 0,
|
|
28
|
+
zIndex: 10,
|
|
29
|
+
overflow: "hidden",
|
|
30
|
+
},
|
|
31
|
+
".b_active .b_tile-in-fade": {
|
|
32
|
+
opacity: 1,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
addComponents([b_tileslide_in, b_tilefade_in]);
|
|
37
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module.exports = function ({ addComponents }) {
|
|
2
|
+
// allows infinite loop for swiper continues
|
|
3
|
+
const b_newsticker = {
|
|
4
|
+
".b_newsticker": {
|
|
5
|
+
"& > .swiper-free-mode > .swiper-wrapper": {
|
|
6
|
+
"-webkit-transition-timing-function": "linear !important",
|
|
7
|
+
"-o-transition-timing-function": "linear !important",
|
|
8
|
+
"transition-timing-function": "linear !important",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
addComponents(b_newsticker);
|
|
13
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module.exports = function ({ addComponents, theme }) {
|
|
2
|
+
const container = {
|
|
3
|
+
".b_container-fluid-aside-r": {
|
|
4
|
+
width: "var(--container-fluid-xs)",
|
|
5
|
+
marginLeft: "auto",
|
|
6
|
+
marginRight: "auto",
|
|
7
|
+
paddingLeft: "1rem",
|
|
8
|
+
paddingRight: "1rem",
|
|
9
|
+
},
|
|
10
|
+
".b_container-fluid-aside-l": {
|
|
11
|
+
width: "var(--container-fluid-xs)",
|
|
12
|
+
marginLeft: "auto",
|
|
13
|
+
marginRight: "auto",
|
|
14
|
+
paddingLeft: "1rem",
|
|
15
|
+
paddingRight: "1rem",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const maxWidth2xl = theme("screens.2xl");
|
|
20
|
+
const minWidthLg = theme("screens.lg");
|
|
21
|
+
|
|
22
|
+
if (minWidthLg) {
|
|
23
|
+
container[`@media (min-width: ${minWidthLg})`] = {
|
|
24
|
+
".b_container-fluid-aside-l": {
|
|
25
|
+
width: "var(--container-fluid-xl)",
|
|
26
|
+
marginLeft: `calc((100% - var(--container-fluid-xl)) / 2)`,
|
|
27
|
+
},
|
|
28
|
+
".b_container-fluid-aside-r": {
|
|
29
|
+
width: "var(--container-fluid-xl)",
|
|
30
|
+
marginRight: `calc((100% - var(--container-fluid-xl)) / 2 )`,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (maxWidth2xl) {
|
|
35
|
+
container[`@media (min-width: ${maxWidth2xl})`] = {
|
|
36
|
+
".b_container-fluid-aside-l": {
|
|
37
|
+
width: `calc(100% - (100% - ${maxWidth2xl}) / 2)`,
|
|
38
|
+
marginLeft: `calc((100% - ${maxWidth2xl}) / 2)`,
|
|
39
|
+
},
|
|
40
|
+
".b_container-fluid-aside-r": {
|
|
41
|
+
width: `calc(100% - (100% - ${maxWidth2xl}) / 2)`,
|
|
42
|
+
marginRight: `calc((100% - ${maxWidth2xl}) / 2)`,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
addComponents(container);
|
|
48
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module.exports = function ({ addComponents, theme }) {
|
|
2
|
+
const container = {
|
|
3
|
+
".b_container-fluid-half-r": {
|
|
4
|
+
width: "var(--container-fluid-xs)",
|
|
5
|
+
marginLeft: "auto",
|
|
6
|
+
marginRight: "auto",
|
|
7
|
+
paddingLeft: "1rem",
|
|
8
|
+
paddingRight: "1rem",
|
|
9
|
+
},
|
|
10
|
+
".b_container-fluid-half-l": {
|
|
11
|
+
width: "var(--container-fluid-xs)",
|
|
12
|
+
marginLeft: "auto",
|
|
13
|
+
marginRight: "auto",
|
|
14
|
+
paddingLeft: "1rem",
|
|
15
|
+
paddingRight: "1rem",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const maxWidth2xl = theme("screens.2xl");
|
|
20
|
+
const minWidthLg = theme("screens.lg");
|
|
21
|
+
|
|
22
|
+
if (minWidthLg) {
|
|
23
|
+
container[`@media (min-width: ${minWidthLg})`] = {
|
|
24
|
+
".b_container-fluid-half-l": {
|
|
25
|
+
width: "50%",
|
|
26
|
+
marginLeft: `calc((100% - var(--container-fluid-xl)) / 2)`,
|
|
27
|
+
},
|
|
28
|
+
".b_container-fluid-half-r": {
|
|
29
|
+
width: "50%",
|
|
30
|
+
marginRight: `calc((100% - var(--container-fluid-xl)) / 2 )`,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (maxWidth2xl) {
|
|
35
|
+
container[`@media (min-width: ${maxWidth2xl})`] = {
|
|
36
|
+
".b_container-fluid-half-l": {
|
|
37
|
+
width: `calc(${maxWidth2xl} / 2)`,
|
|
38
|
+
marginLeft: `calc((100% - ${maxWidth2xl}) / 2)`,
|
|
39
|
+
},
|
|
40
|
+
".b_container-fluid-half-r": {
|
|
41
|
+
width: `calc(${maxWidth2xl} / 2)`,
|
|
42
|
+
marginRight: `calc((100% - ${maxWidth2xl}) / 2)`,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
addComponents(container);
|
|
48
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module.exports = function ({ addUtilities, theme, e }) {
|
|
2
|
+
const newUtilities = {};
|
|
3
|
+
|
|
4
|
+
// 96 is max resolution
|
|
5
|
+
for (let i = 0; i <= 97; i++) {
|
|
6
|
+
newUtilities[`.${e(`b_area-x-${i}`)}`] = { "--b_area-x": `${i}` };
|
|
7
|
+
newUtilities[`.${e(`b_area-y-${i}`)}`] = { "--b_area-y": `${i}` };
|
|
8
|
+
newUtilities[`.${e(`b_area-w-${i}`)}`] = { "--b_area-w": `${i}` };
|
|
9
|
+
newUtilities[`.${e(`b_area-h-${i}`)}`] = { "--b_area-h": `${i}` };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
addUtilities(newUtilities, ["responsive"]);
|
|
13
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const plugin = require("tailwindcss/plugin");
|
|
2
|
+
|
|
3
|
+
module.exports = function ({ addComponents, matchUtilities, theme, config }) {
|
|
4
|
+
const important = config("important");
|
|
5
|
+
const prefix = typeof important === "string" ? important : "";
|
|
6
|
+
// Predefined grid-area utilities
|
|
7
|
+
addComponents({
|
|
8
|
+
[`${prefix} .b_area`]: {
|
|
9
|
+
gridArea:
|
|
10
|
+
"var(--b_area-y) / var(--b_area-x) / calc(var(--b_area-y) + var(--b_area-h)) / calc(var(--b_area-x) + var(--b_area-w))",
|
|
11
|
+
},
|
|
12
|
+
[`${prefix} .b_grid-area-16`]: {
|
|
13
|
+
display: "grid",
|
|
14
|
+
gridTemplateColumns: "repeat(16, 1fr)",
|
|
15
|
+
gridTemplateRows: "repeat(16, 1fr)",
|
|
16
|
+
"--init-area": "1 / 1 / 4 / 4",
|
|
17
|
+
},
|
|
18
|
+
[`${prefix} .b_grid-area-32`]: {
|
|
19
|
+
display: "grid",
|
|
20
|
+
gridTemplateColumns: "repeat(32, 1fr)",
|
|
21
|
+
gridTemplateRows: "repeat(32, 1fr)",
|
|
22
|
+
"--init-area": "1 / 1 / 8 / 8",
|
|
23
|
+
},
|
|
24
|
+
[`${prefix} .b_grid-area-64`]: {
|
|
25
|
+
display: "grid",
|
|
26
|
+
gridTemplateColumns: "repeat(64, 1fr)",
|
|
27
|
+
gridTemplateRows: "repeat(64, 1fr)",
|
|
28
|
+
"--init-area": "1 / 1 / 16 / 16",
|
|
29
|
+
},
|
|
30
|
+
[`${prefix} .b_grid-area-96`]: {
|
|
31
|
+
display: "grid",
|
|
32
|
+
gridTemplateColumns: "repeat(96, 1fr)",
|
|
33
|
+
gridTemplateRows: "repeat(96, 1fr)",
|
|
34
|
+
"--init-area": "1 / 1 / 24 / 24",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
matchUtilities(
|
|
38
|
+
{
|
|
39
|
+
b_area: (value) => {
|
|
40
|
+
// Remove the square brackets and split the value by "/"
|
|
41
|
+
const parts = value.split("-"); // slice to remove the square brackets
|
|
42
|
+
if (parts.length === 4) {
|
|
43
|
+
return {
|
|
44
|
+
"grid-area": `${parts[0]} / ${parts[1]} / ${parts[2]} / ${parts[3]}`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{ values: {} } // Allow arbitrary values like b_area[1/4/4/3]
|
|
50
|
+
);
|
|
51
|
+
};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module "blockbite-tailwind" {
|
|
2
|
+
// Function declarations
|
|
3
|
+
export function getAspectRatio(...args: any[]): any;
|
|
4
|
+
export function getContainer(...args: any[]): any;
|
|
5
|
+
export function getScreens(...args: any[]): any;
|
|
6
|
+
export function getColors(...args: any[]): any;
|
|
7
|
+
export function getColorObject(...args: any[]): any;
|
|
8
|
+
export function themeParser(...args: any[]): any;
|
|
9
|
+
|
|
10
|
+
// Constant declarations
|
|
11
|
+
export const gridSpacing: any;
|
|
12
|
+
export const fluidSpacing: any;
|
|
13
|
+
export const screenSpacing: any;
|
|
14
|
+
export const percentSpacing: any;
|
|
15
|
+
export const nativeSpacing: any;
|
|
16
|
+
export const spanSpacing: any;
|
|
17
|
+
}
|
package/index.html
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite App</title>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
<script type="module">
|
|
11
|
+
import buildCss from "https://esm.sh/tailwindcss-in-browser@0.1.3";
|
|
12
|
+
|
|
13
|
+
const markup = `
|
|
14
|
+
<div class="p-6 max-w-sm mx-auto bg-white rounded-xl shadow-md space-y-4">
|
|
15
|
+
<h1 class="text-2xl font-bold">Hello, Tailwind CSS v4!</h1>
|
|
16
|
+
<p class="text-gray-500">This is a sample component styled with Tailwind CSS v4 in the browser.</p>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
const configurationCss = `
|
|
21
|
+
@theme {
|
|
22
|
+
--color-primary: #3b82f6;
|
|
23
|
+
--color-secondary: #64748b;
|
|
24
|
+
--font-sans: 'Inter', sans-serif;
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
buildCss(markup, configurationCss).then((css) => {
|
|
29
|
+
const styleTag = document.createElement("style");
|
|
30
|
+
styleTag.textContent = css;
|
|
31
|
+
document.head.appendChild(styleTag);
|
|
32
|
+
});
|
|
33
|
+
</script>
|
|
34
|
+
</head>
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
<body>
|
|
38
|
+
<div class="p-6 max-w-sm mx-auto bg-white rounded-xl shadow-md space-y-4">
|
|
39
|
+
<h1 class="text-2xl font-bold">Hello, Tailwind CSS v4!</h1>
|
|
40
|
+
<p class="text-gray-500">This is a sample component styled with Tailwind CSS v4 in the browser.</p>
|
|
41
|
+
</div>
|
|
42
|
+
<div id="app"></div>
|
|
43
|
+
<script type="module" src="/vite.js"></script>
|
|
44
|
+
</body>
|
|
45
|
+
|
|
46
|
+
</html>
|
package/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Import functions and constants
|
|
2
|
+
import { getAspectRatio } from "./lib/aspect-ratio";
|
|
3
|
+
import { getContainer } from "./lib/container";
|
|
4
|
+
import {
|
|
5
|
+
gridSpacing,
|
|
6
|
+
fluidSpacing,
|
|
7
|
+
screenSpacing,
|
|
8
|
+
percentSpacing,
|
|
9
|
+
nativeSpacing,
|
|
10
|
+
spanSpacing,
|
|
11
|
+
} from "./lib/spacing";
|
|
12
|
+
import { getScreens } from "./lib/screens";
|
|
13
|
+
import { getColors, getColorObject } from "./lib/colors";
|
|
14
|
+
import { themeParser } from "./lib/theme-parser";
|
|
15
|
+
|
|
16
|
+
// Export functions and constants
|
|
17
|
+
export {
|
|
18
|
+
getAspectRatio,
|
|
19
|
+
getContainer,
|
|
20
|
+
gridSpacing,
|
|
21
|
+
fluidSpacing,
|
|
22
|
+
screenSpacing,
|
|
23
|
+
percentSpacing,
|
|
24
|
+
nativeSpacing,
|
|
25
|
+
spanSpacing,
|
|
26
|
+
getScreens,
|
|
27
|
+
getColors,
|
|
28
|
+
getColorObject,
|
|
29
|
+
themeParser,
|
|
30
|
+
};
|
package/lib/colors.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const colors = [
|
|
2
|
+
"b_theme",
|
|
3
|
+
"black",
|
|
4
|
+
"white",
|
|
5
|
+
"transparent",
|
|
6
|
+
"inherit",
|
|
7
|
+
"current",
|
|
8
|
+
"gray",
|
|
9
|
+
"red",
|
|
10
|
+
"yellow",
|
|
11
|
+
"green",
|
|
12
|
+
"blue",
|
|
13
|
+
"indigo",
|
|
14
|
+
"purple",
|
|
15
|
+
"pink",
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
19
|
+
|
|
20
|
+
export const isSpecialColor = (color) =>
|
|
21
|
+
["black", "white", "transparent", "inherit", "current", "b_theme"].includes(
|
|
22
|
+
color
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const getColors = () => {
|
|
26
|
+
const tailwindColors = {};
|
|
27
|
+
|
|
28
|
+
colors.forEach((color) => {
|
|
29
|
+
if (isSpecialColor(color)) {
|
|
30
|
+
tailwindColors[color] = color;
|
|
31
|
+
} else {
|
|
32
|
+
shades.forEach((shade) => {
|
|
33
|
+
tailwindColors[`${color}-${shade}`] = `${color}-${shade}`;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return tailwindColors;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const getColorObject = () => {
|
|
42
|
+
const colorObjects = colors.flatMap((color) => {
|
|
43
|
+
if (isSpecialColor(color)) {
|
|
44
|
+
return {
|
|
45
|
+
label: `${color.charAt(0).toUpperCase() + color.slice(1)}`,
|
|
46
|
+
id: color,
|
|
47
|
+
};
|
|
48
|
+
} else {
|
|
49
|
+
return shades.map((shade) => ({
|
|
50
|
+
label: `${color.charAt(0).toUpperCase() + color.slice(1)} ${shade}`,
|
|
51
|
+
id: `${color}-${shade}`,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return colorObjects;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default { getColors, getColorObject };
|
package/lib/container.js
ADDED
package/lib/screens.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const getScreens = (
|
|
2
|
+
prefix = "b_",
|
|
3
|
+
minxmax = { min: "768px", max: "1100px", max2xl: "1440px" }
|
|
4
|
+
) => {
|
|
5
|
+
// max 320px
|
|
6
|
+
const screens = {};
|
|
7
|
+
screens[prefix + "xs"] = { max: minxmax.min };
|
|
8
|
+
screens[prefix + "md"] = { min: minxmax.min, max: minxmax.max };
|
|
9
|
+
screens[prefix + "xl"] = { min: minxmax.max };
|
|
10
|
+
screens[prefix + "sm"] = { max: minxmax.max };
|
|
11
|
+
screens[prefix + "2xl"] = { min: minxmax.max2xl };
|
|
12
|
+
return screens;
|
|
13
|
+
};
|