@oardi/css-utils 0.111.1 → 0.113.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oardi/css-utils",
3
- "version": "0.111.1",
3
+ "version": "0.113.0",
4
4
  "author": "Ardian Shala",
5
5
  "homepage": "https://css-utils.oardi.com",
6
6
  "description": "Powerful set of semantic css classes with support for breakpoints, directions and spacings",
@@ -23,7 +23,9 @@
23
23
  "LICENSE.md"
24
24
  ],
25
25
  "license": "MIT",
26
- "scripts": {},
26
+ "scripts": {
27
+ "prepublishOnly": "npm --prefix .. run validate"
28
+ },
27
29
  "publishConfig": {
28
30
  "access": "public"
29
31
  }
@@ -7,16 +7,20 @@
7
7
  @each $bp, $bp-value in map.get(theme.$theme, breakpoints) {
8
8
  @media (min-width: #{$bp-value}) {
9
9
  @each $key, $value in map.get(theme.$theme, spacings) {
10
- .gap-#{$bp}-#{$key} {
11
- gap: $value;
10
+ $suffix: theme.spacing-selector-suffix($key);
11
+ $token: theme.spacing-token-suffix($key);
12
+ $spacing: var(--spacer-#{$token}, #{$value});
13
+
14
+ .gap-#{$bp}-#{$suffix} {
15
+ gap: $spacing;
12
16
  }
13
17
 
14
- .row-gap-#{$bp}-#{$key} {
15
- row-gap: $value;
18
+ .row-gap-#{$bp}-#{$suffix} {
19
+ row-gap: $spacing;
16
20
  }
17
21
 
18
- .column-gap-#{$bp}-#{$key} {
19
- column-gap: $value;
22
+ .column-gap-#{$bp}-#{$suffix} {
23
+ column-gap: $spacing;
20
24
  }
21
25
  }
22
26
  }
package/scss/gap.scss CHANGED
@@ -4,16 +4,20 @@
4
4
 
5
5
  @layer utilities {
6
6
  @each $key, $value in map.get(theme.$theme, spacings) {
7
- .gap-#{$key} {
8
- gap: $value;
7
+ $suffix: theme.spacing-selector-suffix($key);
8
+ $token: theme.spacing-token-suffix($key);
9
+ $spacing: var(--spacer-#{$token}, #{$value});
10
+
11
+ .gap-#{$suffix} {
12
+ gap: $spacing;
9
13
  }
10
14
 
11
- .row-gap-#{$key} {
12
- row-gap: $value;
15
+ .row-gap-#{$suffix} {
16
+ row-gap: $spacing;
13
17
  }
14
18
 
15
- .column-gap-#{$key} {
16
- column-gap: $value;
19
+ .column-gap-#{$suffix} {
20
+ column-gap: $spacing;
17
21
  }
18
22
  }
19
23
  }
@@ -36,45 +36,71 @@
36
36
  }
37
37
 
38
38
  @each $key, $value in map.get(theme.$theme, spacings) {
39
- .m-#{$bp}-#{$key} {
40
- margin: $value;
39
+ $suffix: theme.spacing-selector-suffix($key);
40
+ $token: theme.spacing-token-suffix($key);
41
+ $spacing: var(--spacer-#{$token}, #{$value});
42
+
43
+ .m-#{$bp}-#{$suffix} {
44
+ margin: $spacing;
41
45
  }
42
46
 
43
- .p-#{$bp}-#{$key} {
44
- padding: $value;
47
+ .p-#{$bp}-#{$suffix} {
48
+ padding: $spacing;
45
49
  }
46
50
  }
47
51
 
48
52
  @each $key, $value in map.get(theme.$theme, spacings) {
49
- .mx-#{$bp}-#{$key} {
50
- margin-left: $value;
51
- margin-right: $value;
53
+ $suffix: theme.spacing-selector-suffix($key);
54
+ $token: theme.spacing-token-suffix($key);
55
+ $spacing: var(--spacer-#{$token}, #{$value});
56
+
57
+ .mx-#{$bp}-#{$suffix} {
58
+ margin-left: $spacing;
59
+ margin-right: $spacing;
60
+ }
61
+
62
+ .my-#{$bp}-#{$suffix} {
63
+ margin-top: $spacing;
64
+ margin-bottom: $spacing;
65
+ }
66
+
67
+ .px-#{$bp}-#{$suffix} {
68
+ padding-left: $spacing;
69
+ padding-right: $spacing;
52
70
  }
53
71
 
54
- .my-#{$bp}-#{$key} {
55
- margin-top: $value;
56
- margin-bottom: $value;
72
+ .py-#{$bp}-#{$suffix} {
73
+ padding-top: $spacing;
74
+ padding-bottom: $spacing;
57
75
  }
76
+ }
58
77
 
59
- .px-#{$bp}-#{$key} {
60
- padding-left: $value;
61
- padding-right: $value;
78
+ @each $key, $value in map.get(theme.$theme, spacings) {
79
+ $suffix: theme.spacing-selector-suffix($key);
80
+ $token: theme.spacing-token-suffix($key);
81
+ $spacing: var(--spacer-#{$token}, #{$value});
82
+
83
+ .space-x-#{$bp}-#{$suffix} > :where(* + *) {
84
+ margin-inline-start: $spacing;
62
85
  }
63
86
 
64
- .py-#{$bp}-#{$key} {
65
- padding-top: $value;
66
- padding-bottom: $value;
87
+ .space-y-#{$bp}-#{$suffix} > :where(* + *) {
88
+ margin-block-start: $spacing;
67
89
  }
68
90
  }
69
91
 
70
92
  @each $key, $value in map.get(theme.$theme, spacings) {
93
+ $suffix: theme.spacing-selector-suffix($key);
94
+ $token: theme.spacing-token-suffix($key);
95
+ $spacing: var(--spacer-#{$token}, #{$value});
96
+
71
97
  @each $dir, $prop in map.get(theme.$theme, directions) {
72
- .m#{$dir}-#{$bp}-#{$key} {
73
- margin-#{$prop}: $value;
98
+ .m#{$dir}-#{$bp}-#{$suffix} {
99
+ margin-#{$prop}: $spacing;
74
100
  }
75
101
 
76
- .p#{$dir}-#{$bp}-#{$key} {
77
- padding-#{$prop}: $value;
102
+ .p#{$dir}-#{$bp}-#{$suffix} {
103
+ padding-#{$prop}: $spacing;
78
104
  }
79
105
  }
80
106
  }
@@ -36,46 +36,72 @@
36
36
  // margin / padding spacings
37
37
  // i.e. .m-2, .m-5, p-1,
38
38
  @each $key, $value in map.get(theme.$theme, spacings) {
39
- .m-#{$key} {
40
- margin: $value;
39
+ $suffix: theme.spacing-selector-suffix($key);
40
+ $token: theme.spacing-token-suffix($key);
41
+ $spacing: var(--spacer-#{$token}, #{$value});
42
+
43
+ .m-#{$suffix} {
44
+ margin: $spacing;
41
45
  }
42
46
 
43
- .p-#{$key} {
44
- padding: $value;
47
+ .p-#{$suffix} {
48
+ padding: $spacing;
45
49
  }
46
50
  }
47
51
  @each $key, $value in map.get(theme.$theme, spacings) {
48
- .mx-#{$key} {
49
- margin-left: $value;
50
- margin-right: $value;
52
+ $suffix: theme.spacing-selector-suffix($key);
53
+ $token: theme.spacing-token-suffix($key);
54
+ $spacing: var(--spacer-#{$token}, #{$value});
55
+
56
+ .mx-#{$suffix} {
57
+ margin-left: $spacing;
58
+ margin-right: $spacing;
59
+ }
60
+
61
+ .my-#{$suffix} {
62
+ margin-top: $spacing;
63
+ margin-bottom: $spacing;
64
+ }
65
+
66
+ .px-#{$suffix} {
67
+ padding-left: $spacing;
68
+ padding-right: $spacing;
51
69
  }
52
70
 
53
- .my-#{$key} {
54
- margin-top: $value;
55
- margin-bottom: $value;
71
+ .py-#{$suffix} {
72
+ padding-top: $spacing;
73
+ padding-bottom: $spacing;
56
74
  }
75
+ }
57
76
 
58
- .px-#{$key} {
59
- padding-left: $value;
60
- padding-right: $value;
77
+ @each $key, $value in map.get(theme.$theme, spacings) {
78
+ $suffix: theme.spacing-selector-suffix($key);
79
+ $token: theme.spacing-token-suffix($key);
80
+ $spacing: var(--spacer-#{$token}, #{$value});
81
+
82
+ .space-x-#{$suffix} > :where(* + *) {
83
+ margin-inline-start: $spacing;
61
84
  }
62
85
 
63
- .py-#{$key} {
64
- padding-top: $value;
65
- padding-bottom: $value;
86
+ .space-y-#{$suffix} > :where(* + *) {
87
+ margin-block-start: $spacing;
66
88
  }
67
89
  }
68
90
 
69
91
  // margin / padding with directions
70
92
  // i.e. mt-2, mb-5, pt-1, ...
71
93
  @each $key, $value in map.get(theme.$theme, spacings) {
94
+ $suffix: theme.spacing-selector-suffix($key);
95
+ $token: theme.spacing-token-suffix($key);
96
+ $spacing: var(--spacer-#{$token}, #{$value});
97
+
72
98
  @each $dir, $prop in map.get(theme.$theme, directions) {
73
- .m#{$dir}-#{$key} {
74
- margin-#{$prop}: $value;
99
+ .m#{$dir}-#{$suffix} {
100
+ margin-#{$prop}: $spacing;
75
101
  }
76
102
 
77
- .p#{$dir}-#{$key} {
78
- padding-#{$prop}: $value;
103
+ .p#{$dir}-#{$suffix} {
104
+ padding-#{$prop}: $spacing;
79
105
  }
80
106
  }
81
107
  }
package/scss/theme.scss CHANGED
@@ -1,4 +1,5 @@
1
1
  @use 'sass:map';
2
+ @use 'sass:string';
2
3
 
3
4
  $-spacer: 1rem;
4
5
 
@@ -101,13 +102,37 @@ $-directions: (
101
102
 
102
103
  $-spacings: (
103
104
  0: 0,
105
+ 0.5: $-spacer * 0.125,
104
106
  1: $-spacer * 0.25,
107
+ 1.5: $-spacer * 0.375,
105
108
  2: $-spacer * 0.5,
109
+ 2.5: $-spacer * 0.75,
106
110
  3: $-spacer,
111
+ 3.5: $-spacer * 1.25,
107
112
  4: $-spacer * 1.5,
113
+ 4.5: $-spacer * 2.25,
108
114
  5: $-spacer * 3, // add auto
109
115
  );
110
116
 
117
+ @function -replace($value, $search, $replacement) {
118
+ $index: string.index($value, $search);
119
+
120
+ @if $index {
121
+ @return string.slice($value, 1, $index - 1) + $replacement +
122
+ -replace(string.slice($value, $index + string.length($search)), $search, $replacement);
123
+ }
124
+
125
+ @return $value;
126
+ }
127
+
128
+ @function spacing-token-suffix($key) {
129
+ @return -replace('#{$key}', '.', '-');
130
+ }
131
+
132
+ @function spacing-selector-suffix($key) {
133
+ @return string.unquote(-replace('#{$key}', '.', '\\.'));
134
+ }
135
+
111
136
  $-positions: (relative, absolute, fixed, static, sticky, inherit, initial, unset);
112
137
 
113
138
  $-z-index-levels: (
@@ -28,7 +28,7 @@
28
28
  }
29
29
 
30
30
  @each $name, $value in map.get(theme.$theme, spacings) {
31
- --spacer-#{$name}: #{$value};
31
+ --spacer-#{theme.spacing-token-suffix($name)}: #{$value};
32
32
  }
33
33
 
34
34
  --line-height: 1.8;