emily-css 1.2.0 → 1.2.1

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.
@@ -0,0 +1,58 @@
1
+ 'use strict'
2
+
3
+ function escapeClassName(key) {
4
+ return key.replace(/\./g, '\\.');
5
+ }
6
+
7
+ function positioningUtilities(spacing) {
8
+ let css = `/* Positioning */\n`;
9
+
10
+ css += `.static { position: static; }\n`;
11
+ css += `.relative { position: relative; }\n`;
12
+ css += `.absolute { position: absolute; }\n`;
13
+ css += `.fixed { position: fixed; }\n`;
14
+ css += `.sticky { position: sticky; }\n`;
15
+
16
+ Object.entries(spacing).forEach(([key, value]) => {
17
+ const escaped = escapeClassName(key);
18
+ css += `.top-${escaped} { top: ${value}; }\n`;
19
+ css += `.right-${escaped} { right: ${value}; }\n`;
20
+ css += `.bottom-${escaped} { bottom: ${value}; }\n`;
21
+ css += `.left-${escaped} { left: ${value}; }\n`;
22
+ css += `.inset-${escaped} { inset: ${value}; }\n`;
23
+ css += `.inset-x-${escaped} { left: ${value}; right: ${value}; }\n`;
24
+ css += `.inset-y-${escaped} { top: ${value}; bottom: ${value}; }\n`;
25
+ if (value !== '0' && value !== '0px') {
26
+ css += `.-top-${escaped} { top: -${value}; }\n`;
27
+ css += `.-right-${escaped} { right: -${value}; }\n`;
28
+ css += `.-bottom-${escaped} { bottom: -${value}; }\n`;
29
+ css += `.-left-${escaped} { left: -${value}; }\n`;
30
+ css += `.-inset-${escaped} { inset: -${value}; }\n`;
31
+ css += `.-inset-x-${escaped} { left: -${value}; right: -${value}; }\n`;
32
+ css += `.-inset-y-${escaped} { top: -${value}; bottom: -${value}; }\n`;
33
+ }
34
+ });
35
+
36
+ css += `.inset-auto { inset: auto; }\n`;
37
+ css += `.inset-x-auto { left: auto; right: auto; }\n`;
38
+ css += `.inset-y-auto { top: auto; bottom: auto; }\n`;
39
+ css += `.top-auto { top: auto; }\n`;
40
+ css += `.right-auto { right: auto; }\n`;
41
+ css += `.bottom-auto { bottom: auto; }\n`;
42
+ css += `.left-auto { left: auto; }\n`;
43
+
44
+ const zIndices = {
45
+ 'auto': 'auto', '0': '0', '10': '10', '20': '20', '30': '30', '40': '40', '50': '50',
46
+ 'dropdown': '1000', 'sticky': '1020', 'fixed': '1030', 'modal': '1040', 'popover': '1060', 'tooltip': '1070'
47
+ };
48
+ Object.entries(zIndices).forEach(([name, value]) => {
49
+ css += `.z-${name} { z-index: ${value}; }\n`;
50
+ });
51
+
52
+ css += `\n`;
53
+ return css;
54
+ }
55
+
56
+ module.exports = {
57
+ positioningUtilities,
58
+ };
@@ -0,0 +1,41 @@
1
+ 'use strict'
2
+
3
+ function ringUtilities(colours) {
4
+ let css = `/* Rings & Outlines */\n`;
5
+
6
+ css += `.ring-0 { --ring-offset-width: 0px; --ring-offset-color: #fff; --ring-color: currentColor; box-shadow: 0 0 0 var(--ring-offset-width, 0px) var(--ring-offset-color, #fff), 0 0 0 var(--ring-offset-width, 0px) transparent; }\n`;
7
+ css += `.ring-1 { --ring-offset-width: 0px; --ring-offset-color: #fff; --ring-color: currentColor; box-shadow: 0 0 0 var(--ring-offset-width, 0px) var(--ring-offset-color, #fff), 0 0 0 calc(1px + var(--ring-offset-width, 0px)) var(--ring-color, currentColor); }\n`;
8
+ css += `.ring-2 { --ring-offset-width: 0px; --ring-offset-color: #fff; --ring-color: currentColor; box-shadow: 0 0 0 var(--ring-offset-width, 0px) var(--ring-offset-color, #fff), 0 0 0 calc(2px + var(--ring-offset-width, 0px)) var(--ring-color, currentColor); }\n`;
9
+
10
+ css += `.ring-offset-0 { --ring-offset-width: 0px; }\n`;
11
+ css += `.ring-offset-2 { --ring-offset-width: 2px; }\n`;
12
+ css += `.ring-offset-4 { --ring-offset-width: 4px; }\n`;
13
+ css += `.ring-offset-white { --ring-offset-color: #fff; }\n`;
14
+ css += `.ring-offset-black { --ring-offset-color: #000; }\n`;
15
+
16
+ // Ring colours
17
+ Object.entries(colours).forEach(([colourName, shades]) => {
18
+ Object.entries(shades).forEach(([shade]) => {
19
+ css += `.ring-${colourName}-${shade} { --ring-color: var(--color-${colourName}-${shade}); }\n`;
20
+ css += `.ring-offset-${colourName}-${shade} { --ring-offset-color: var(--color-${colourName}-${shade}); }\n`;
21
+ });
22
+ });
23
+
24
+ css += `.outline-none { outline: 2px solid transparent; outline-offset: 2px; }\n`;
25
+ css += `.outline { outline: 1px solid currentColor; }\n`;
26
+ css += `.outline-0 { outline-width: 0; }\n`;
27
+ css += `.outline-1 { outline-width: 1px; }\n`;
28
+ css += `.outline-2 { outline-width: 2px; }\n`;
29
+ css += `.outline-offset-0 { outline-offset: 0px; }\n`;
30
+ css += `.outline-offset-1 { outline-offset: 1px; }\n`;
31
+ css += `.outline-offset-2 { outline-offset: 2px; }\n`;
32
+ css += `.outline-offset-4 { outline-offset: 4px; }\n`;
33
+ css += `.outline-offset-8 { outline-offset: 8px; }\n`;
34
+
35
+ css += `\n`;
36
+ return css;
37
+ }
38
+
39
+ module.exports = {
40
+ ringUtilities,
41
+ };
@@ -0,0 +1,111 @@
1
+ 'use strict'
2
+
3
+ function escapeClassName(key) {
4
+ return key.replace(/\./g, '\\.');
5
+ }
6
+
7
+ function sizingUtilities(spacing) {
8
+ let css = `/* Sizing */\n`;
9
+
10
+ Object.entries(spacing).forEach(([key, value]) => {
11
+ const escaped = escapeClassName(key);
12
+ css += `.w-${escaped} { width: ${value}; }\n`;
13
+ css += `.h-${escaped} { height: ${value}; }\n`;
14
+ css += `.size-${escaped} { width: ${value}; height: ${value}; }\n`;
15
+ css += `.min-w-${escaped} { min-width: ${value}; }\n`;
16
+ css += `.min-h-${escaped} { min-height: ${value}; }\n`;
17
+ css += `.max-w-${escaped} { max-width: ${value}; }\n`;
18
+ css += `.max-h-${escaped} { max-height: ${value}; }\n`;
19
+ });
20
+
21
+ const fractions = {
22
+ '1\\/2': '50%', '1\\/3': '33.333333%', '2\\/3': '66.666667%',
23
+ '1\\/4': '25%', '2\\/4': '50%', '3\\/4': '75%',
24
+ '1\\/5': '20%', '2\\/5': '40%', '3\\/5': '60%', '4\\/5': '80%',
25
+ '1\\/6': '16.666667%', '2\\/6': '33.333333%', '3\\/6': '50%', '4\\/6': '66.666667%', '5\\/6': '83.333333%',
26
+ '1\\/12': '8.333333%', '2\\/12': '16.666667%', '3\\/12': '25%', '4\\/12': '33.333333%', '5\\/12': '41.666667%', '6\\/12': '50%', '7\\/12': '58.333333%', '8\\/12': '66.666667%', '9\\/12': '75%', '10\\/12': '83.333333%', '11\\/12': '91.666667%'
27
+ };
28
+
29
+ Object.entries(fractions).forEach(([name, value]) => {
30
+ css += `.w-${name} { width: ${value}; }\n`;
31
+ css += `.h-${name} { height: ${value}; }\n`;
32
+ css += `.size-${name} { width: ${value}; height: ${value}; }\n`;
33
+ });
34
+
35
+ css += `.w-auto { width: auto; }\n`;
36
+ css += `.h-auto { height: auto; }\n`;
37
+ css += `.size-auto { width: auto; height: auto; }\n`;
38
+ css += `.w-full { width: 100%; }\n`;
39
+ css += `.h-full { height: 100%; }\n`;
40
+ css += `.size-full { width: 100%; height: 100%; }\n`;
41
+ css += `.w-screen { width: 100vw; }\n`;
42
+ css += `.h-screen { height: 100vh; }\n`;
43
+ css += `.w-svw { width: 100svw; }\n`;
44
+ css += `.h-svh { height: 100svh; }\n`;
45
+ css += `.w-lvw { width: 100lvw; }\n`;
46
+ css += `.h-lvh { height: 100lvh; }\n`;
47
+ css += `.w-dvw { width: 100dvw; }\n`;
48
+ css += `.h-dvh { height: 100dvh; }\n`;
49
+ css += `.w-min { width: min-content; }\n`;
50
+ css += `.w-max { width: max-content; }\n`;
51
+ css += `.w-fit { width: fit-content; }\n`;
52
+ css += `.h-min { height: min-content; }\n`;
53
+ css += `.h-max { height: max-content; }\n`;
54
+ css += `.h-fit { height: fit-content; }\n`;
55
+
56
+ css += `.min-w-0 { min-width: 0; }\n`;
57
+ css += `.min-w-full { min-width: 100%; }\n`;
58
+ css += `.min-w-min { min-width: min-content; }\n`;
59
+ css += `.min-w-max { min-width: max-content; }\n`;
60
+ css += `.min-w-fit { min-width: fit-content; }\n`;
61
+ css += `.min-h-0 { min-height: 0; }\n`;
62
+ css += `.min-h-full { min-height: 100%; }\n`;
63
+ css += `.min-h-screen { min-height: 100vh; }\n`;
64
+ css += `.min-h-svh { min-height: 100svh; }\n`;
65
+ css += `.min-h-lvh { min-height: 100lvh; }\n`;
66
+ css += `.min-h-dvh { min-height: 100dvh; }\n`;
67
+ css += `.min-h-min { min-height: min-content; }\n`;
68
+ css += `.min-h-max { min-height: max-content; }\n`;
69
+ css += `.min-h-fit { min-height: fit-content; }\n`;
70
+
71
+ css += `.max-w-0 { max-width: 0; }\n`;
72
+ css += `.max-w-none { max-width: none; }\n`;
73
+ css += `.max-w-full { max-width: 100%; }\n`;
74
+ css += `.max-w-min { max-width: min-content; }\n`;
75
+ css += `.max-w-max { max-width: max-content; }\n`;
76
+ css += `.max-w-fit { max-width: fit-content; }\n`;
77
+ css += `.max-h-0 { max-height: 0; }\n`;
78
+ css += `.max-h-full { max-height: 100%; }\n`;
79
+ css += `.max-h-screen { max-height: 100vh; }\n`;
80
+ css += `.max-h-svh { max-height: 100svh; }\n`;
81
+ css += `.max-h-lvh { max-height: 100lvh; }\n`;
82
+ css += `.max-h-dvh { max-height: 100dvh; }\n`;
83
+ css += `.max-h-min { max-height: min-content; }\n`;
84
+ css += `.max-h-max { max-height: max-content; }\n`;
85
+ css += `.max-h-fit { max-height: fit-content; }\n`;
86
+
87
+ const maxWidths = {
88
+ xs: '20rem', sm: '24rem', md: '28rem', lg: '32rem', xl: '36rem',
89
+ '2xl': '42rem', '3xl': '48rem', '4xl': '56rem', '5xl': '64rem',
90
+ '6xl': '72rem', '7xl': '80rem', prose: '65ch', screen: '100vw',
91
+ 'screen-sm': '640px', 'screen-md': '768px', 'screen-lg': '1024px',
92
+ 'screen-xl': '1280px', 'screen-2xl': '1536px'
93
+ };
94
+ Object.entries(maxWidths).forEach(([name, value]) => {
95
+ css += `.max-w-${name} { max-width: ${value}; }\n`;
96
+ });
97
+
98
+ css += `.aspect-auto { aspect-ratio: auto; }\n`;
99
+ css += `.aspect-square { aspect-ratio: 1; }\n`;
100
+ css += `.aspect-video { aspect-ratio: 16 / 9; }\n`;
101
+ css += `.aspect-3\\/2 { aspect-ratio: 3 / 2; }\n`;
102
+ css += `.aspect-4\\/3 { aspect-ratio: 4 / 3; }\n`;
103
+ css += `.aspect-16\\/9 { aspect-ratio: 16 / 9; }\n`;
104
+
105
+ css += `\n`;
106
+ return css;
107
+ }
108
+
109
+ module.exports = {
110
+ sizingUtilities,
111
+ };
@@ -0,0 +1,38 @@
1
+ 'use strict'
2
+
3
+ function svgUtilities(colours) {
4
+ let css = `/* SVG */\n`;
5
+
6
+ css += `.fill-current { fill: currentColor; }\n`;
7
+ css += `.stroke-current { stroke: currentColor; }\n`;
8
+ css += `.fill-white { fill: #FAFAFA; }\n`;
9
+ css += `.fill-black { fill: #111110; }\n`;
10
+ css += `.fill-transparent { fill: transparent; }\n`;
11
+ css += `.stroke-white { stroke: #FAFAFA; }\n`;
12
+ css += `.stroke-black { stroke: #111110; }\n`;
13
+ css += `.stroke-transparent { stroke: transparent; }\n`;
14
+ css += `.stroke-0 { stroke-width: 0; }\n`;
15
+ css += `.stroke-1 { stroke-width: 1; }\n`;
16
+ css += `.stroke-2 { stroke-width: 2; }\n`;
17
+
18
+ // Fill colours
19
+ Object.entries(colours).forEach(([colourName, shades]) => {
20
+ Object.entries(shades).forEach(([shade]) => {
21
+ css += `.fill-${colourName}-${shade} { fill: var(--color-${colourName}-${shade}); }\n`;
22
+ });
23
+ });
24
+
25
+ // Stroke colours
26
+ Object.entries(colours).forEach(([colourName, shades]) => {
27
+ Object.entries(shades).forEach(([shade]) => {
28
+ css += `.stroke-${colourName}-${shade} { stroke: var(--color-${colourName}-${shade}); }\n`;
29
+ });
30
+ });
31
+
32
+ css += `\n`;
33
+ return css;
34
+ }
35
+
36
+ module.exports = {
37
+ svgUtilities,
38
+ };
@@ -0,0 +1,61 @@
1
+ 'use strict'
2
+
3
+ function escapeClassName(key) {
4
+ return key.replace(/\./g, '\\.');
5
+ }
6
+
7
+ function transformUtilities(spacing) {
8
+ let css = `/* Transforms */\n`;
9
+ const composedTransform = 'translate(var(--translate-x, 0), var(--translate-y, 0)) rotate(var(--rotate, 0)) skewX(var(--skew-x, 0)) skewY(var(--skew-y, 0)) scaleX(var(--scale-x, 1)) scaleY(var(--scale-y, 1))';
10
+
11
+ css += `.transform { transform: translateZ(0); }\n`;
12
+ css += `.transform-gpu { transform: translate3d(0, 0, 0); }\n`;
13
+ css += `.transform-none { transform: none; }\n`;
14
+
15
+ // Translate
16
+ Object.entries(spacing).forEach(([key, value]) => {
17
+ const escaped = escapeClassName(key);
18
+ css += `.translate-x-${escaped} { --translate-x: ${value}; transform: ${composedTransform}; }\n`;
19
+ css += `.translate-y-${escaped} { --translate-y: ${value}; transform: ${composedTransform}; }\n`;
20
+ css += `.-translate-x-${escaped} { --translate-x: -${value}; transform: ${composedTransform}; }\n`;
21
+ css += `.-translate-y-${escaped} { --translate-y: -${value}; transform: ${composedTransform}; }\n`;
22
+ });
23
+
24
+ // Rotate
25
+ const rotations = [0, 1, 2, 3, 6, 12, 45, 90, 180];
26
+ rotations.forEach(deg => {
27
+ css += `.rotate-${deg} { --rotate: ${deg}deg; transform: ${composedTransform}; }\n`;
28
+ if (deg > 0) css += `.-rotate-${deg} { --rotate: -${deg}deg; transform: ${composedTransform}; }\n`;
29
+ });
30
+
31
+ // Scale
32
+ const scales = [0, 50, 75, 90, 95, 100, 110, 125, 150];
33
+ scales.forEach(scale => {
34
+ css += `.scale-${scale} { --scale-x: ${scale / 100}; --scale-y: ${scale / 100}; transform: ${composedTransform}; }\n`;
35
+ });
36
+
37
+ // Skew
38
+ const skews = [0, 1, 2, 3];
39
+ skews.forEach(sk => {
40
+ css += `.skew-x-${sk} { --skew-x: ${sk}deg; transform: ${composedTransform}; }\n`;
41
+ css += `.skew-y-${sk} { --skew-y: ${sk}deg; transform: ${composedTransform}; }\n`;
42
+ });
43
+
44
+ // Transform origin
45
+ css += `.origin-center { transform-origin: center; }\n`;
46
+ css += `.origin-top { transform-origin: top; }\n`;
47
+ css += `.origin-top-right { transform-origin: top right; }\n`;
48
+ css += `.origin-right { transform-origin: right; }\n`;
49
+ css += `.origin-bottom-right { transform-origin: bottom right; }\n`;
50
+ css += `.origin-bottom { transform-origin: bottom; }\n`;
51
+ css += `.origin-bottom-left { transform-origin: bottom left; }\n`;
52
+ css += `.origin-left { transform-origin: left; }\n`;
53
+ css += `.origin-top-left { transform-origin: top left; }\n`;
54
+
55
+ css += `\n`;
56
+ return css;
57
+ }
58
+
59
+ module.exports = {
60
+ transformUtilities,
61
+ };