@hiscovega/grisso 1.0.6 → 1.0.7
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/README.md +37 -9
- package/dist/grisso.css +1 -1
- package/lib/defaults.js +7 -0
- package/lib/generators.d.ts +7 -7
- package/lib/generators.js +46 -6
- package/lib/partials/backgrounds.js +8 -8
- package/lib/partials/borders.js +19 -19
- package/lib/partials/effects.js +4 -4
- package/lib/partials/flex-and-grid.js +46 -46
- package/lib/partials/icons.js +2 -2
- package/lib/partials/layout.js +23 -23
- package/lib/partials/sizing.js +9 -9
- package/lib/partials/spacing.js +15 -15
- package/lib/partials/typography.js +17 -17
- package/lib/tokens.js +1 -0
- package/lib/types.d.ts +3 -0
- package/package.json +1 -1
package/lib/defaults.js
CHANGED
|
@@ -10,6 +10,13 @@ const defaults = {
|
|
|
10
10
|
desktop: "(min-width: 1024px)",
|
|
11
11
|
ultrawide: "(min-width: 1680px)",
|
|
12
12
|
},
|
|
13
|
+
states: {
|
|
14
|
+
hover: ":hover",
|
|
15
|
+
focus: ":focus",
|
|
16
|
+
"focus-visible": ":focus-visible",
|
|
17
|
+
active: ":active",
|
|
18
|
+
disabled: ":disabled",
|
|
19
|
+
},
|
|
13
20
|
spacing: {
|
|
14
21
|
auto: "auto",
|
|
15
22
|
zero: "0",
|
package/lib/generators.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { Breakpoints, Declarations, TokenMap } from "./types.js";
|
|
1
|
+
import type { Breakpoints, Declarations, States, TokenMap } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Genera una clase simple con variantes responsive.
|
|
3
|
+
* Genera una clase simple con variantes responsive y de estado.
|
|
4
4
|
* Equivalente al mixin grisso_simple_class.
|
|
5
5
|
*/
|
|
6
|
-
export declare function simpleClass(className: string, property: string, value: string, breakpoints: Breakpoints): string;
|
|
6
|
+
export declare function simpleClass(className: string, property: string, value: string, breakpoints: Breakpoints, states?: States): string;
|
|
7
7
|
/**
|
|
8
|
-
* Genera clases basadas en un mapa de tokens con variantes responsive.
|
|
8
|
+
* Genera clases basadas en un mapa de tokens con variantes responsive y de estado.
|
|
9
9
|
* Equivalente al mixin grisso_complex_class.
|
|
10
10
|
*/
|
|
11
|
-
export declare function complexClass(prefix: string, properties: string | string[], tokens: TokenMap, breakpoints: Breakpoints): string;
|
|
11
|
+
export declare function complexClass(prefix: string, properties: string | string[], tokens: TokenMap, breakpoints: Breakpoints, states?: States): string;
|
|
12
12
|
/**
|
|
13
|
-
* Genera una clase con declaraciones custom y variantes responsive.
|
|
13
|
+
* Genera una clase con declaraciones custom y variantes responsive y de estado.
|
|
14
14
|
* Para casos especiales: divide >*+*, truncate, smoothing, outline-none, etc.
|
|
15
15
|
*/
|
|
16
|
-
export declare function customClass(className: string, declarations: Declarations, breakpoints: Breakpoints, selectorSuffix?: string): string;
|
|
16
|
+
export declare function customClass(className: string, declarations: Declarations, breakpoints: Breakpoints, selectorSuffix?: string, states?: States): string;
|
package/lib/generators.js
CHANGED
|
@@ -7,22 +7,34 @@ function escapeCSS(name) {
|
|
|
7
7
|
return name.replace(/\//g, "\\/");
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Genera una clase simple con variantes responsive.
|
|
10
|
+
* Genera una clase simple con variantes responsive y de estado.
|
|
11
11
|
* Equivalente al mixin grisso_simple_class.
|
|
12
12
|
*/
|
|
13
|
-
export function simpleClass(className, property, value, breakpoints) {
|
|
13
|
+
export function simpleClass(className, property, value, breakpoints, states) {
|
|
14
14
|
const escaped = escapeCSS(className);
|
|
15
15
|
let css = `.${escaped} { ${property}: ${value}; }\n`;
|
|
16
|
+
// Variantes de estado
|
|
17
|
+
if (states) {
|
|
18
|
+
for (const [state, pseudo] of Object.entries(states)) {
|
|
19
|
+
css += `.${state}-${escaped}${pseudo} { ${property}: ${value}; }\n`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
16
22
|
for (const [bp, mq] of Object.entries(breakpoints)) {
|
|
17
23
|
css += `@media ${mq} { .${bp}-${escaped} { ${property}: ${value}; } }\n`;
|
|
24
|
+
// Variantes responsive + estado
|
|
25
|
+
if (states) {
|
|
26
|
+
for (const [state, pseudo] of Object.entries(states)) {
|
|
27
|
+
css += `@media ${mq} { .${bp}-${state}-${escaped}${pseudo} { ${property}: ${value}; } }\n`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
18
30
|
}
|
|
19
31
|
return css;
|
|
20
32
|
}
|
|
21
33
|
/**
|
|
22
|
-
* Genera clases basadas en un mapa de tokens con variantes responsive.
|
|
34
|
+
* Genera clases basadas en un mapa de tokens con variantes responsive y de estado.
|
|
23
35
|
* Equivalente al mixin grisso_complex_class.
|
|
24
36
|
*/
|
|
25
|
-
export function complexClass(prefix, properties, tokens, breakpoints) {
|
|
37
|
+
export function complexClass(prefix, properties, tokens, breakpoints, states) {
|
|
26
38
|
const props = Array.isArray(properties) ? properties : [properties];
|
|
27
39
|
let css = "";
|
|
28
40
|
for (const [name, value] of Object.entries(tokens)) {
|
|
@@ -30,27 +42,55 @@ export function complexClass(prefix, properties, tokens, breakpoints) {
|
|
|
30
42
|
for (const prop of props) {
|
|
31
43
|
css += `.${escaped} { ${prop}: ${value}; }\n`;
|
|
32
44
|
}
|
|
45
|
+
// Variantes de estado
|
|
46
|
+
if (states) {
|
|
47
|
+
for (const [state, pseudo] of Object.entries(states)) {
|
|
48
|
+
for (const prop of props) {
|
|
49
|
+
css += `.${state}-${escaped}${pseudo} { ${prop}: ${value}; }\n`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
33
53
|
for (const [bp, mq] of Object.entries(breakpoints)) {
|
|
34
54
|
for (const prop of props) {
|
|
35
55
|
css += `@media ${mq} { .${bp}-${escaped} { ${prop}: ${value}; } }\n`;
|
|
36
56
|
}
|
|
57
|
+
// Variantes responsive + estado
|
|
58
|
+
if (states) {
|
|
59
|
+
for (const [state, pseudo] of Object.entries(states)) {
|
|
60
|
+
for (const prop of props) {
|
|
61
|
+
css += `@media ${mq} { .${bp}-${state}-${escaped}${pseudo} { ${prop}: ${value}; } }\n`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
37
65
|
}
|
|
38
66
|
}
|
|
39
67
|
return css;
|
|
40
68
|
}
|
|
41
69
|
/**
|
|
42
|
-
* Genera una clase con declaraciones custom y variantes responsive.
|
|
70
|
+
* Genera una clase con declaraciones custom y variantes responsive y de estado.
|
|
43
71
|
* Para casos especiales: divide >*+*, truncate, smoothing, outline-none, etc.
|
|
44
72
|
*/
|
|
45
|
-
export function customClass(className, declarations, breakpoints, selectorSuffix) {
|
|
73
|
+
export function customClass(className, declarations, breakpoints, selectorSuffix, states) {
|
|
46
74
|
const escaped = escapeCSS(className);
|
|
47
75
|
const suffix = selectorSuffix || "";
|
|
48
76
|
const decls = Object.entries(declarations)
|
|
49
77
|
.map(([p, v]) => `${p}: ${v}`)
|
|
50
78
|
.join("; ");
|
|
51
79
|
let css = `.${escaped}${suffix} { ${decls}; }\n`;
|
|
80
|
+
// Variantes de estado: pseudo va antes del selectorSuffix
|
|
81
|
+
if (states) {
|
|
82
|
+
for (const [state, pseudo] of Object.entries(states)) {
|
|
83
|
+
css += `.${state}-${escaped}${pseudo}${suffix} { ${decls}; }\n`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
52
86
|
for (const [bp, mq] of Object.entries(breakpoints)) {
|
|
53
87
|
css += `@media ${mq} { .${bp}-${escaped}${suffix} { ${decls}; } }\n`;
|
|
88
|
+
// Variantes responsive + estado
|
|
89
|
+
if (states) {
|
|
90
|
+
for (const [state, pseudo] of Object.entries(states)) {
|
|
91
|
+
css += `@media ${mq} { .${bp}-${state}-${escaped}${pseudo}${suffix} { ${decls}; } }\n`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
54
94
|
}
|
|
55
95
|
return css;
|
|
56
96
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { complexClass } from "../generators.js";
|
|
2
2
|
export default function backgrounds(config) {
|
|
3
|
-
const { breakpoints, backgroundColors } = config;
|
|
3
|
+
const { breakpoints, states, backgroundColors } = config;
|
|
4
4
|
let css = "";
|
|
5
5
|
// background-color
|
|
6
|
-
css += complexClass("bg-", "background-color", backgroundColors, breakpoints);
|
|
6
|
+
css += complexClass("bg-", "background-color", backgroundColors, breakpoints, states);
|
|
7
7
|
// background-attachment
|
|
8
8
|
const bgAttachment = {
|
|
9
9
|
fixed: "fixed",
|
|
10
10
|
local: "local",
|
|
11
11
|
scroll: "scroll",
|
|
12
12
|
};
|
|
13
|
-
css += complexClass("bg-", "background-attachment", bgAttachment, breakpoints);
|
|
13
|
+
css += complexClass("bg-", "background-attachment", bgAttachment, breakpoints, states);
|
|
14
14
|
// background-clip
|
|
15
15
|
const bgClip = {
|
|
16
16
|
border: "border-box",
|
|
@@ -18,14 +18,14 @@ export default function backgrounds(config) {
|
|
|
18
18
|
content: "content-box",
|
|
19
19
|
text: "text",
|
|
20
20
|
};
|
|
21
|
-
css += complexClass("bg-clip-", "background-clip", bgClip, breakpoints);
|
|
21
|
+
css += complexClass("bg-clip-", "background-clip", bgClip, breakpoints, states);
|
|
22
22
|
// background-origin
|
|
23
23
|
const bgOrigin = {
|
|
24
24
|
border: "border-box",
|
|
25
25
|
padding: "padding-box",
|
|
26
26
|
content: "content-box",
|
|
27
27
|
};
|
|
28
|
-
css += complexClass("bg-origin-", "background-origin", bgOrigin, breakpoints);
|
|
28
|
+
css += complexClass("bg-origin-", "background-origin", bgOrigin, breakpoints, states);
|
|
29
29
|
// background-position
|
|
30
30
|
const bgPosition = {
|
|
31
31
|
bottom: "bottom",
|
|
@@ -38,7 +38,7 @@ export default function backgrounds(config) {
|
|
|
38
38
|
"right-top": "right top",
|
|
39
39
|
top: "top",
|
|
40
40
|
};
|
|
41
|
-
css += complexClass("bg-", "background-position", bgPosition, breakpoints);
|
|
41
|
+
css += complexClass("bg-", "background-position", bgPosition, breakpoints, states);
|
|
42
42
|
// background-repeat
|
|
43
43
|
const bgRepeat = {
|
|
44
44
|
repeat: "repeat",
|
|
@@ -48,7 +48,7 @@ export default function backgrounds(config) {
|
|
|
48
48
|
"repeat-round": "round",
|
|
49
49
|
"repeat-space": "space",
|
|
50
50
|
};
|
|
51
|
-
css += complexClass("bg-", "background-repeat", bgRepeat, breakpoints);
|
|
51
|
+
css += complexClass("bg-", "background-repeat", bgRepeat, breakpoints, states);
|
|
52
52
|
// background-size
|
|
53
53
|
const bgSize = {
|
|
54
54
|
auto: "auto",
|
|
@@ -59,6 +59,6 @@ export default function backgrounds(config) {
|
|
|
59
59
|
revert: "revert",
|
|
60
60
|
unset: "unset",
|
|
61
61
|
};
|
|
62
|
-
css += complexClass("bg-", "background-size", bgSize, breakpoints);
|
|
62
|
+
css += complexClass("bg-", "background-size", bgSize, breakpoints, states);
|
|
63
63
|
return css;
|
|
64
64
|
}
|
package/lib/partials/borders.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { complexClass, customClass } from "../generators.js";
|
|
2
2
|
export default function borders(config) {
|
|
3
|
-
const { breakpoints, borderWidth, borderColors } = config;
|
|
3
|
+
const { breakpoints, states, borderWidth, borderColors } = config;
|
|
4
4
|
let css = "";
|
|
5
5
|
// Variables locales (equivale a borders/vars.scss)
|
|
6
6
|
const extendedColors = {
|
|
@@ -18,35 +18,35 @@ export default function borders(config) {
|
|
|
18
18
|
none: "none",
|
|
19
19
|
};
|
|
20
20
|
// border-width
|
|
21
|
-
css += complexClass("border-", "border-width", borderWidth, breakpoints);
|
|
21
|
+
css += complexClass("border-", "border-width", borderWidth, breakpoints, states);
|
|
22
22
|
// border-{side}-width
|
|
23
|
-
css += complexClass("border-t-", "border-top-width", borderWidth, breakpoints);
|
|
24
|
-
css += complexClass("border-r-", "border-right-width", borderWidth, breakpoints);
|
|
25
|
-
css += complexClass("border-b-", "border-bottom-width", borderWidth, breakpoints);
|
|
26
|
-
css += complexClass("border-l-", "border-left-width", borderWidth, breakpoints);
|
|
23
|
+
css += complexClass("border-t-", "border-top-width", borderWidth, breakpoints, states);
|
|
24
|
+
css += complexClass("border-r-", "border-right-width", borderWidth, breakpoints, states);
|
|
25
|
+
css += complexClass("border-b-", "border-bottom-width", borderWidth, breakpoints, states);
|
|
26
|
+
css += complexClass("border-l-", "border-left-width", borderWidth, breakpoints, states);
|
|
27
27
|
// border-color
|
|
28
|
-
css += complexClass("border-", "border-color", extendedColors, breakpoints);
|
|
28
|
+
css += complexClass("border-", "border-color", extendedColors, breakpoints, states);
|
|
29
29
|
// border-style
|
|
30
|
-
css += complexClass("border-", "border-style", borderStyle, breakpoints);
|
|
30
|
+
css += complexClass("border-", "border-style", borderStyle, breakpoints, states);
|
|
31
31
|
// divide-color
|
|
32
32
|
for (const [key, value] of Object.entries(extendedColors)) {
|
|
33
|
-
css += customClass(`divide-${key}`, { "border-color": value }, breakpoints, " > * + *");
|
|
33
|
+
css += customClass(`divide-${key}`, { "border-color": value }, breakpoints, " > * + *", states);
|
|
34
34
|
}
|
|
35
35
|
// divide-width
|
|
36
36
|
for (const [key, value] of Object.entries(borderWidth)) {
|
|
37
|
-
css += customClass(`divide-x-${key}`, { "border-right-width": value, "border-left-width": value }, breakpoints, " > * + *");
|
|
38
|
-
css += customClass(`divide-y-${key}`, { "border-top-width": value, "border-bottom-width": value }, breakpoints, " > * + *");
|
|
37
|
+
css += customClass(`divide-x-${key}`, { "border-right-width": value, "border-left-width": value }, breakpoints, " > * + *", states);
|
|
38
|
+
css += customClass(`divide-y-${key}`, { "border-top-width": value, "border-bottom-width": value }, breakpoints, " > * + *", states);
|
|
39
39
|
}
|
|
40
|
-
css += customClass("divide-x", { "border-right-width": "0", "border-left-width": "1px" }, breakpoints, " > * + *");
|
|
41
|
-
css += customClass("divide-y", { "border-top-width": "1px", "border-bottom-width": "0" }, breakpoints, " > * + *");
|
|
40
|
+
css += customClass("divide-x", { "border-right-width": "0", "border-left-width": "1px" }, breakpoints, " > * + *", states);
|
|
41
|
+
css += customClass("divide-y", { "border-top-width": "1px", "border-bottom-width": "0" }, breakpoints, " > * + *", states);
|
|
42
42
|
// divide-style
|
|
43
43
|
for (const [key, value] of Object.entries(borderStyle)) {
|
|
44
|
-
css += customClass(`divide-${key}`, { "border-style": value }, breakpoints, " > * + *");
|
|
44
|
+
css += customClass(`divide-${key}`, { "border-style": value }, breakpoints, " > * + *", states);
|
|
45
45
|
}
|
|
46
46
|
// outline-color
|
|
47
|
-
css += complexClass("outline-", "outline-color", extendedColors, breakpoints);
|
|
47
|
+
css += complexClass("outline-", "outline-color", extendedColors, breakpoints, states);
|
|
48
48
|
// outline-width
|
|
49
|
-
css += complexClass("outline-", "outline-width", borderWidth, breakpoints);
|
|
49
|
+
css += complexClass("outline-", "outline-width", borderWidth, breakpoints, states);
|
|
50
50
|
// outline-style
|
|
51
51
|
const outlineStyle = {
|
|
52
52
|
outline: "solid",
|
|
@@ -54,9 +54,9 @@ export default function borders(config) {
|
|
|
54
54
|
"outline-dotted": "dotted",
|
|
55
55
|
"outline-double": "double",
|
|
56
56
|
};
|
|
57
|
-
css += complexClass("", "outline-style", outlineStyle, breakpoints);
|
|
58
|
-
css += customClass("outline-none", { outline: "2px solid transparent", "outline-offset": "2px" }, breakpoints);
|
|
57
|
+
css += complexClass("", "outline-style", outlineStyle, breakpoints, states);
|
|
58
|
+
css += customClass("outline-none", { outline: "2px solid transparent", "outline-offset": "2px" }, breakpoints, undefined, states);
|
|
59
59
|
// outline-offset
|
|
60
|
-
css += complexClass("outline-offset-", "outline-offset", borderWidth, breakpoints);
|
|
60
|
+
css += complexClass("outline-offset-", "outline-offset", borderWidth, breakpoints, states);
|
|
61
61
|
return css;
|
|
62
62
|
}
|
package/lib/partials/effects.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { complexClass } from "../generators.js";
|
|
2
2
|
export default function effects(config) {
|
|
3
|
-
const { breakpoints, opacity, shadows, overlayColors } = config;
|
|
3
|
+
const { breakpoints, states, opacity, shadows, overlayColors } = config;
|
|
4
4
|
let css = "";
|
|
5
5
|
// opacity
|
|
6
|
-
css += complexClass("opacity-", "opacity", opacity, breakpoints);
|
|
6
|
+
css += complexClass("opacity-", "opacity", opacity, breakpoints, states);
|
|
7
7
|
// box-shadow
|
|
8
8
|
const extendedShadows = {
|
|
9
9
|
...shadows,
|
|
10
10
|
inner: "inset 0 2px 4px 0 rgb(0 0 0 / 0.05)",
|
|
11
11
|
none: "0 0 #0000",
|
|
12
12
|
};
|
|
13
|
-
css += complexClass("shadow-", "box-shadow", extendedShadows, breakpoints);
|
|
13
|
+
css += complexClass("shadow-", "box-shadow", extendedShadows, breakpoints, states);
|
|
14
14
|
// overlay (background-color)
|
|
15
|
-
css += complexClass("overlay-", "background-color", overlayColors, breakpoints);
|
|
15
|
+
css += complexClass("overlay-", "background-color", overlayColors, breakpoints, states);
|
|
16
16
|
return css;
|
|
17
17
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { complexClass, simpleClass } from "../generators.js";
|
|
2
2
|
import { omit } from "../utils.js";
|
|
3
3
|
export default function flexAndGrid(config) {
|
|
4
|
-
const { columns, breakpoints, spacing } = config;
|
|
4
|
+
const { columns, breakpoints, states, spacing } = config;
|
|
5
5
|
let css = "";
|
|
6
6
|
// flex-direction
|
|
7
7
|
const direction = {
|
|
@@ -10,14 +10,14 @@ export default function flexAndGrid(config) {
|
|
|
10
10
|
col: "column",
|
|
11
11
|
"col-reverse": "column-reverse",
|
|
12
12
|
};
|
|
13
|
-
css += complexClass("flex-", "flex-direction", direction, breakpoints);
|
|
13
|
+
css += complexClass("flex-", "flex-direction", direction, breakpoints, states);
|
|
14
14
|
// flex-wrap
|
|
15
15
|
const wrap = {
|
|
16
16
|
wrap: "wrap",
|
|
17
17
|
"wrap-reverse": "wrap-reverse",
|
|
18
18
|
nowrap: "nowrap",
|
|
19
19
|
};
|
|
20
|
-
css += complexClass("flex-", "flex-wrap", wrap, breakpoints);
|
|
20
|
+
css += complexClass("flex-", "flex-wrap", wrap, breakpoints, states);
|
|
21
21
|
// flex (shorthand)
|
|
22
22
|
const flex = {
|
|
23
23
|
"1": "1 1 0",
|
|
@@ -25,20 +25,20 @@ export default function flexAndGrid(config) {
|
|
|
25
25
|
initial: "0 1 auto",
|
|
26
26
|
none: "none",
|
|
27
27
|
};
|
|
28
|
-
css += complexClass("flex-", "flex", flex, breakpoints);
|
|
28
|
+
css += complexClass("flex-", "flex", flex, breakpoints, states);
|
|
29
29
|
// flex-grow
|
|
30
|
-
css += simpleClass("grow", "flex-grow", "1", breakpoints);
|
|
31
|
-
css += simpleClass("grow-0", "flex-grow", "0", breakpoints);
|
|
30
|
+
css += simpleClass("grow", "flex-grow", "1", breakpoints, states);
|
|
31
|
+
css += simpleClass("grow-0", "flex-grow", "0", breakpoints, states);
|
|
32
32
|
// flex-shrink
|
|
33
|
-
css += simpleClass("shrink", "flex-shrink", "1", breakpoints);
|
|
34
|
-
css += simpleClass("shrink-0", "flex-shrink", "0", breakpoints);
|
|
33
|
+
css += simpleClass("shrink", "flex-shrink", "1", breakpoints, states);
|
|
34
|
+
css += simpleClass("shrink-0", "flex-shrink", "0", breakpoints, states);
|
|
35
35
|
// order
|
|
36
36
|
for (let i = 1; i <= columns; i++) {
|
|
37
|
-
css += simpleClass(`order-${i}`, "order", String(i), breakpoints);
|
|
37
|
+
css += simpleClass(`order-${i}`, "order", String(i), breakpoints, states);
|
|
38
38
|
}
|
|
39
|
-
css += simpleClass("order-first", "order", "-9999", breakpoints);
|
|
40
|
-
css += simpleClass("order-last", "order", "9999", breakpoints);
|
|
41
|
-
css += simpleClass("order-none", "order", "0", breakpoints);
|
|
39
|
+
css += simpleClass("order-first", "order", "-9999", breakpoints, states);
|
|
40
|
+
css += simpleClass("order-last", "order", "9999", breakpoints, states);
|
|
41
|
+
css += simpleClass("order-none", "order", "0", breakpoints, states);
|
|
42
42
|
// justify-items
|
|
43
43
|
const justifyItems = {
|
|
44
44
|
start: "start",
|
|
@@ -46,7 +46,7 @@ export default function flexAndGrid(config) {
|
|
|
46
46
|
center: "center",
|
|
47
47
|
stretch: "stretch",
|
|
48
48
|
};
|
|
49
|
-
css += complexClass("justify-items-", "justify-items", justifyItems, breakpoints);
|
|
49
|
+
css += complexClass("justify-items-", "justify-items", justifyItems, breakpoints, states);
|
|
50
50
|
// justify-content
|
|
51
51
|
const justifyContent = {
|
|
52
52
|
normal: "normal",
|
|
@@ -58,7 +58,7 @@ export default function flexAndGrid(config) {
|
|
|
58
58
|
evenly: "space-evenly",
|
|
59
59
|
stretch: "stretch",
|
|
60
60
|
};
|
|
61
|
-
css += complexClass("justify-", "justify-content", justifyContent, breakpoints);
|
|
61
|
+
css += complexClass("justify-", "justify-content", justifyContent, breakpoints, states);
|
|
62
62
|
// align-items
|
|
63
63
|
const alignItems = {
|
|
64
64
|
start: "flex-start",
|
|
@@ -67,7 +67,7 @@ export default function flexAndGrid(config) {
|
|
|
67
67
|
baseline: "baseline",
|
|
68
68
|
stretch: "stretch",
|
|
69
69
|
};
|
|
70
|
-
css += complexClass("items-", "align-items", alignItems, breakpoints);
|
|
70
|
+
css += complexClass("items-", "align-items", alignItems, breakpoints, states);
|
|
71
71
|
// align-content
|
|
72
72
|
const alignContent = {
|
|
73
73
|
normal: "normal",
|
|
@@ -80,7 +80,7 @@ export default function flexAndGrid(config) {
|
|
|
80
80
|
baseline: "baseline",
|
|
81
81
|
stretch: "stretch",
|
|
82
82
|
};
|
|
83
|
-
css += complexClass("content-", "align-content", alignContent, breakpoints);
|
|
83
|
+
css += complexClass("content-", "align-content", alignContent, breakpoints, states);
|
|
84
84
|
// align-self
|
|
85
85
|
const alignSelf = {
|
|
86
86
|
auto: "normal",
|
|
@@ -90,7 +90,7 @@ export default function flexAndGrid(config) {
|
|
|
90
90
|
baseline: "baseline",
|
|
91
91
|
stretch: "stretch",
|
|
92
92
|
};
|
|
93
|
-
css += complexClass("self-", "align-self", alignSelf, breakpoints);
|
|
93
|
+
css += complexClass("self-", "align-self", alignSelf, breakpoints, states);
|
|
94
94
|
// justify-self
|
|
95
95
|
const justifySelf = {
|
|
96
96
|
auto: "auto",
|
|
@@ -99,38 +99,38 @@ export default function flexAndGrid(config) {
|
|
|
99
99
|
center: "center",
|
|
100
100
|
stretch: "stretch",
|
|
101
101
|
};
|
|
102
|
-
css += complexClass("justify-self-", "justify-self", justifySelf, breakpoints);
|
|
102
|
+
css += complexClass("justify-self-", "justify-self", justifySelf, breakpoints, states);
|
|
103
103
|
// grid-template-columns
|
|
104
104
|
for (let i = 1; i <= columns; i++) {
|
|
105
|
-
css += simpleClass(`grid-cols-${i}`, "grid-template-columns", `repeat(${i}, minmax(0, 1fr))`, breakpoints);
|
|
105
|
+
css += simpleClass(`grid-cols-${i}`, "grid-template-columns", `repeat(${i}, minmax(0, 1fr))`, breakpoints, states);
|
|
106
106
|
}
|
|
107
|
-
css += simpleClass("grid-cols-none", "grid-template-columns", "none", breakpoints);
|
|
107
|
+
css += simpleClass("grid-cols-none", "grid-template-columns", "none", breakpoints, states);
|
|
108
108
|
// grid-column start/end
|
|
109
|
-
css += simpleClass("col-auto", "grid-column", "auto", breakpoints);
|
|
109
|
+
css += simpleClass("col-auto", "grid-column", "auto", breakpoints, states);
|
|
110
110
|
for (let i = 1; i <= columns; i++) {
|
|
111
|
-
css += simpleClass(`col-span-${i}`, "grid-column", `span ${i} / span ${i}`, breakpoints);
|
|
112
|
-
css += simpleClass(`col-start-${i}`, "grid-column-start", String(i), breakpoints);
|
|
113
|
-
css += simpleClass(`col-end-${i}`, "grid-column-end", String(i), breakpoints);
|
|
111
|
+
css += simpleClass(`col-span-${i}`, "grid-column", `span ${i} / span ${i}`, breakpoints, states);
|
|
112
|
+
css += simpleClass(`col-start-${i}`, "grid-column-start", String(i), breakpoints, states);
|
|
113
|
+
css += simpleClass(`col-end-${i}`, "grid-column-end", String(i), breakpoints, states);
|
|
114
114
|
}
|
|
115
|
-
css += simpleClass("col-end-13", "grid-column-end", "13", breakpoints);
|
|
116
|
-
css += simpleClass("col-span-full", "grid-column", "1 / -1", breakpoints);
|
|
117
|
-
css += simpleClass("col-start-auto", "grid-column-start", "auto", breakpoints);
|
|
118
|
-
css += simpleClass("col-end-auto", "grid-column-end", "auto", breakpoints);
|
|
115
|
+
css += simpleClass("col-end-13", "grid-column-end", "13", breakpoints, states);
|
|
116
|
+
css += simpleClass("col-span-full", "grid-column", "1 / -1", breakpoints, states);
|
|
117
|
+
css += simpleClass("col-start-auto", "grid-column-start", "auto", breakpoints, states);
|
|
118
|
+
css += simpleClass("col-end-auto", "grid-column-end", "auto", breakpoints, states);
|
|
119
119
|
// grid-template-rows
|
|
120
120
|
for (let i = 1; i <= columns; i++) {
|
|
121
|
-
css += simpleClass(`grid-rows-${i}`, "grid-template-rows", `repeat(${i}, minmax(0, 1fr))`, breakpoints);
|
|
121
|
+
css += simpleClass(`grid-rows-${i}`, "grid-template-rows", `repeat(${i}, minmax(0, 1fr))`, breakpoints, states);
|
|
122
122
|
}
|
|
123
|
-
css += simpleClass("grid-rows-none", "grid-template-rows", "none", breakpoints);
|
|
123
|
+
css += simpleClass("grid-rows-none", "grid-template-rows", "none", breakpoints, states);
|
|
124
124
|
// grid-row start/end
|
|
125
|
-
css += simpleClass("row-auto", "grid-row", "auto", breakpoints);
|
|
125
|
+
css += simpleClass("row-auto", "grid-row", "auto", breakpoints, states);
|
|
126
126
|
for (let i = 1; i <= columns; i++) {
|
|
127
|
-
css += simpleClass(`row-span-${i}`, "grid-row", `span ${i} / span ${i}`, breakpoints);
|
|
128
|
-
css += simpleClass(`row-start-${i}`, "grid-row-start", String(i), breakpoints);
|
|
129
|
-
css += simpleClass(`row-end-${i}`, "grid-row-end", String(i), breakpoints);
|
|
127
|
+
css += simpleClass(`row-span-${i}`, "grid-row", `span ${i} / span ${i}`, breakpoints, states);
|
|
128
|
+
css += simpleClass(`row-start-${i}`, "grid-row-start", String(i), breakpoints, states);
|
|
129
|
+
css += simpleClass(`row-end-${i}`, "grid-row-end", String(i), breakpoints, states);
|
|
130
130
|
}
|
|
131
|
-
css += simpleClass("row-span-full", "grid-row", "1 / -1", breakpoints);
|
|
132
|
-
css += simpleClass("row-start-auto", "grid-row-start", "auto", breakpoints);
|
|
133
|
-
css += simpleClass("row-end-auto", "grid-row-end", "auto", breakpoints);
|
|
131
|
+
css += simpleClass("row-span-full", "grid-row", "1 / -1", breakpoints, states);
|
|
132
|
+
css += simpleClass("row-start-auto", "grid-row-start", "auto", breakpoints, states);
|
|
133
|
+
css += simpleClass("row-end-auto", "grid-row-end", "auto", breakpoints, states);
|
|
134
134
|
// grid-auto-flow
|
|
135
135
|
const autoFlow = {
|
|
136
136
|
row: "row",
|
|
@@ -139,7 +139,7 @@ export default function flexAndGrid(config) {
|
|
|
139
139
|
"row-dense": "row dense",
|
|
140
140
|
"col-dense": "column dense",
|
|
141
141
|
};
|
|
142
|
-
css += complexClass("grid-flow-", "grid-auto-flow", autoFlow, breakpoints);
|
|
142
|
+
css += complexClass("grid-flow-", "grid-auto-flow", autoFlow, breakpoints, states);
|
|
143
143
|
// grid-auto-columns
|
|
144
144
|
const autoColumns = {
|
|
145
145
|
auto: "auto",
|
|
@@ -147,7 +147,7 @@ export default function flexAndGrid(config) {
|
|
|
147
147
|
max: "max-content",
|
|
148
148
|
fr: "minmax(0, 1fr)",
|
|
149
149
|
};
|
|
150
|
-
css += complexClass("auto-cols-", "grid-auto-columns", autoColumns, breakpoints);
|
|
150
|
+
css += complexClass("auto-cols-", "grid-auto-columns", autoColumns, breakpoints, states);
|
|
151
151
|
// grid-auto-rows
|
|
152
152
|
const autoRows = {
|
|
153
153
|
auto: "auto",
|
|
@@ -155,12 +155,12 @@ export default function flexAndGrid(config) {
|
|
|
155
155
|
max: "max-content",
|
|
156
156
|
fr: "minmax(0, 1fr)",
|
|
157
157
|
};
|
|
158
|
-
css += complexClass("auto-rows-", "grid-auto-rows", autoRows, breakpoints);
|
|
158
|
+
css += complexClass("auto-rows-", "grid-auto-rows", autoRows, breakpoints, states);
|
|
159
159
|
// gap
|
|
160
160
|
const gap = omit(spacing, "auto");
|
|
161
|
-
css += complexClass("gap-", "gap", gap, breakpoints);
|
|
162
|
-
css += complexClass("gap-x-", "column-gap", gap, breakpoints);
|
|
163
|
-
css += complexClass("gap-y-", "row-gap", gap, breakpoints);
|
|
161
|
+
css += complexClass("gap-", "gap", gap, breakpoints, states);
|
|
162
|
+
css += complexClass("gap-x-", "column-gap", gap, breakpoints, states);
|
|
163
|
+
css += complexClass("gap-y-", "row-gap", gap, breakpoints, states);
|
|
164
164
|
// place-content
|
|
165
165
|
const placeContent = {
|
|
166
166
|
center: "center",
|
|
@@ -172,7 +172,7 @@ export default function flexAndGrid(config) {
|
|
|
172
172
|
baseline: "baseline",
|
|
173
173
|
stretch: "stretch",
|
|
174
174
|
};
|
|
175
|
-
css += complexClass("place-content-", "place-content", placeContent, breakpoints);
|
|
175
|
+
css += complexClass("place-content-", "place-content", placeContent, breakpoints, states);
|
|
176
176
|
// place-items
|
|
177
177
|
const placeItems = {
|
|
178
178
|
start: "start",
|
|
@@ -181,7 +181,7 @@ export default function flexAndGrid(config) {
|
|
|
181
181
|
baseline: "baseline",
|
|
182
182
|
stretch: "stretch",
|
|
183
183
|
};
|
|
184
|
-
css += complexClass("place-items-", "place-items", placeItems, breakpoints);
|
|
184
|
+
css += complexClass("place-items-", "place-items", placeItems, breakpoints, states);
|
|
185
185
|
// place-self
|
|
186
186
|
const placeSelf = {
|
|
187
187
|
auto: "auto",
|
|
@@ -190,6 +190,6 @@ export default function flexAndGrid(config) {
|
|
|
190
190
|
center: "center",
|
|
191
191
|
stretch: "stretch",
|
|
192
192
|
};
|
|
193
|
-
css += complexClass("place-self-", "place-self", placeSelf, breakpoints);
|
|
193
|
+
css += complexClass("place-self-", "place-self", placeSelf, breakpoints, states);
|
|
194
194
|
return css;
|
|
195
195
|
}
|
package/lib/partials/icons.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { complexClass } from "../generators.js";
|
|
2
2
|
export default function icons(config) {
|
|
3
|
-
const { breakpoints, iconColors } = config;
|
|
4
|
-
return complexClass("icon-", "color", iconColors, breakpoints);
|
|
3
|
+
const { breakpoints, states, iconColors } = config;
|
|
4
|
+
return complexClass("icon-", "color", iconColors, breakpoints, states);
|
|
5
5
|
}
|
package/lib/partials/layout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { complexClass, customClass, simpleClass } from "../generators.js";
|
|
2
2
|
export default function layout(config) {
|
|
3
|
-
const { columns, breakpoints, spacing } = config;
|
|
3
|
+
const { columns, breakpoints, states, spacing } = config;
|
|
4
4
|
let css = "";
|
|
5
5
|
// display
|
|
6
6
|
const display = {
|
|
@@ -26,10 +26,10 @@ export default function layout(config) {
|
|
|
26
26
|
"list-item": "list-item",
|
|
27
27
|
hidden: "none",
|
|
28
28
|
};
|
|
29
|
-
css += complexClass("", "display", display, breakpoints);
|
|
29
|
+
css += complexClass("", "display", display, breakpoints, states);
|
|
30
30
|
// columns (numeric)
|
|
31
31
|
for (let i = 1; i <= columns; i++) {
|
|
32
|
-
css += simpleClass(`columns-${i}`, "columns", String(i), breakpoints);
|
|
32
|
+
css += simpleClass(`columns-${i}`, "columns", String(i), breakpoints, states);
|
|
33
33
|
}
|
|
34
34
|
// float
|
|
35
35
|
const float = {
|
|
@@ -37,7 +37,7 @@ export default function layout(config) {
|
|
|
37
37
|
right: "right",
|
|
38
38
|
none: "none",
|
|
39
39
|
};
|
|
40
|
-
css += complexClass("float-", "float", float, breakpoints);
|
|
40
|
+
css += complexClass("float-", "float", float, breakpoints, states);
|
|
41
41
|
// clear
|
|
42
42
|
const clear = {
|
|
43
43
|
left: "left",
|
|
@@ -45,7 +45,7 @@ export default function layout(config) {
|
|
|
45
45
|
both: "both",
|
|
46
46
|
none: "none",
|
|
47
47
|
};
|
|
48
|
-
css += complexClass("clear-", "clear", clear, breakpoints);
|
|
48
|
+
css += complexClass("clear-", "clear", clear, breakpoints, states);
|
|
49
49
|
// object-fit
|
|
50
50
|
const objectFit = {
|
|
51
51
|
contain: "contain",
|
|
@@ -54,7 +54,7 @@ export default function layout(config) {
|
|
|
54
54
|
none: "none",
|
|
55
55
|
"scale-down": "scale-down",
|
|
56
56
|
};
|
|
57
|
-
css += complexClass("object-", "object-fit", objectFit, breakpoints);
|
|
57
|
+
css += complexClass("object-", "object-fit", objectFit, breakpoints, states);
|
|
58
58
|
// object-position
|
|
59
59
|
const objectPosition = {
|
|
60
60
|
bottom: "bottom",
|
|
@@ -67,7 +67,7 @@ export default function layout(config) {
|
|
|
67
67
|
"right-top": "right top",
|
|
68
68
|
top: "top",
|
|
69
69
|
};
|
|
70
|
-
css += complexClass("object-", "object-position", objectPosition, breakpoints);
|
|
70
|
+
css += complexClass("object-", "object-position", objectPosition, breakpoints, states);
|
|
71
71
|
// overflow
|
|
72
72
|
const overflow = {
|
|
73
73
|
auto: "auto",
|
|
@@ -76,9 +76,9 @@ export default function layout(config) {
|
|
|
76
76
|
visible: "visible",
|
|
77
77
|
scroll: "scroll",
|
|
78
78
|
};
|
|
79
|
-
css += complexClass("overflow-", "overflow", overflow, breakpoints);
|
|
80
|
-
css += complexClass("overflow-x-", "overflow-x", overflow, breakpoints);
|
|
81
|
-
css += complexClass("overflow-y-", "overflow-y", overflow, breakpoints);
|
|
79
|
+
css += complexClass("overflow-", "overflow", overflow, breakpoints, states);
|
|
80
|
+
css += complexClass("overflow-x-", "overflow-x", overflow, breakpoints, states);
|
|
81
|
+
css += complexClass("overflow-y-", "overflow-y", overflow, breakpoints, states);
|
|
82
82
|
// position
|
|
83
83
|
const position = {
|
|
84
84
|
static: "static",
|
|
@@ -87,11 +87,11 @@ export default function layout(config) {
|
|
|
87
87
|
relative: "relative",
|
|
88
88
|
sticky: "sticky",
|
|
89
89
|
};
|
|
90
|
-
css += complexClass("", "position", position, breakpoints);
|
|
90
|
+
css += complexClass("", "position", position, breakpoints, states);
|
|
91
91
|
// visibility
|
|
92
|
-
css += simpleClass("visible", "visibility", "visible", breakpoints);
|
|
93
|
-
css += simpleClass("invisible", "visibility", "hidden", breakpoints);
|
|
94
|
-
css += simpleClass("collapse", "visibility", "collapse", breakpoints);
|
|
92
|
+
css += simpleClass("visible", "visibility", "visible", breakpoints, states);
|
|
93
|
+
css += simpleClass("invisible", "visibility", "hidden", breakpoints, states);
|
|
94
|
+
css += simpleClass("collapse", "visibility", "collapse", breakpoints, states);
|
|
95
95
|
// z-index
|
|
96
96
|
const zIndex = {
|
|
97
97
|
auto: "auto",
|
|
@@ -109,22 +109,22 @@ export default function layout(config) {
|
|
|
109
109
|
"40": "-40",
|
|
110
110
|
"50": "-50",
|
|
111
111
|
};
|
|
112
|
-
css += complexClass("z-", "z-index", zIndex, breakpoints);
|
|
113
|
-
css += complexClass("-z-", "z-index", zIndexNeg, breakpoints);
|
|
112
|
+
css += complexClass("z-", "z-index", zIndex, breakpoints, states);
|
|
113
|
+
css += complexClass("-z-", "z-index", zIndexNeg, breakpoints, states);
|
|
114
114
|
// top/right/bottom/left
|
|
115
|
-
css += complexClass("top-", "top", spacing, breakpoints);
|
|
116
|
-
css += complexClass("right-", "right", spacing, breakpoints);
|
|
117
|
-
css += complexClass("bottom-", "bottom", spacing, breakpoints);
|
|
118
|
-
css += complexClass("left-", "left", spacing, breakpoints);
|
|
115
|
+
css += complexClass("top-", "top", spacing, breakpoints, states);
|
|
116
|
+
css += complexClass("right-", "right", spacing, breakpoints, states);
|
|
117
|
+
css += complexClass("bottom-", "bottom", spacing, breakpoints, states);
|
|
118
|
+
css += complexClass("left-", "left", spacing, breakpoints, states);
|
|
119
119
|
// inset (top + right + bottom + left)
|
|
120
|
-
css += complexClass("inset-", "inset", spacing, breakpoints);
|
|
120
|
+
css += complexClass("inset-", "inset", spacing, breakpoints, states);
|
|
121
121
|
// inset-x (left + right)
|
|
122
122
|
for (const [key, value] of Object.entries(spacing)) {
|
|
123
|
-
css += customClass(`inset-x-${key}`, { left: value, right: value }, breakpoints);
|
|
123
|
+
css += customClass(`inset-x-${key}`, { left: value, right: value }, breakpoints, undefined, states);
|
|
124
124
|
}
|
|
125
125
|
// inset-y (top + bottom)
|
|
126
126
|
for (const [key, value] of Object.entries(spacing)) {
|
|
127
|
-
css += customClass(`inset-y-${key}`, { top: value, bottom: value }, breakpoints);
|
|
127
|
+
css += customClass(`inset-y-${key}`, { top: value, bottom: value }, breakpoints, undefined, states);
|
|
128
128
|
}
|
|
129
129
|
return css;
|
|
130
130
|
}
|