crayon-css 0.1.3 → 0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crayon-css",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "description": "A Sass utility CSS toolkit.",
5
5
  "sass": "src/crayon.scss",
6
6
  "files": [
@@ -0,0 +1,77 @@
1
+ @use "config";
2
+ @use "utility";
3
+ @use "sass:map";
4
+
5
+ // ─── Lookups ──────────────────────────────────────────────────────────────────
6
+
7
+ @function border-width($key: "DEFAULT") {
8
+ @return map.get(config.$border-widths, $key);
9
+ }
10
+
11
+ @function rounded($key: "DEFAULT") {
12
+ $value: map.get(config.$border-radii, $key);
13
+ @if $value == 0 or $value == 9999px { @return $value; }
14
+ @return utility.px-to-rem($value);
15
+ }
16
+
17
+ // ─── CSS Variables ────────────────────────────────────────────────────────────
18
+
19
+ :root {
20
+ @each $key, $value in config.$border-widths {
21
+ @if $key == "DEFAULT" {
22
+ --border: #{$value};
23
+ } @else {
24
+ --border-#{$key}: #{$value};
25
+ }
26
+ }
27
+
28
+ @each $key, $value in config.$border-radii {
29
+ $rem: if($value == 0 or $value == 9999px, $value, utility.px-to-rem($value));
30
+ @if $key == "DEFAULT" {
31
+ --rounded: #{$rem};
32
+ } @else {
33
+ --rounded-#{$key}: #{$rem};
34
+ }
35
+ }
36
+ }
37
+
38
+ // ─── Border Width ─────────────────────────────────────────────────────────────
39
+
40
+ @mixin _border-width-classes($suffix, $width) {
41
+ @if $suffix == "" {
42
+ .border { border-width: $width; }
43
+ .border-x { border-left-width: $width; border-right-width: $width; }
44
+ .border-y { border-top-width: $width; border-bottom-width: $width; }
45
+ .border-t { border-top-width: $width; }
46
+ .border-r { border-right-width: $width; }
47
+ .border-b { border-bottom-width: $width; }
48
+ .border-l { border-left-width: $width; }
49
+ } @else {
50
+ .border-#{$suffix} { border-width: $width; }
51
+ .border-x-#{$suffix} { border-left-width: $width; border-right-width: $width; }
52
+ .border-y-#{$suffix} { border-top-width: $width; border-bottom-width: $width; }
53
+ .border-t-#{$suffix} { border-top-width: $width; }
54
+ .border-r-#{$suffix} { border-right-width: $width; }
55
+ .border-b-#{$suffix} { border-bottom-width: $width; }
56
+ .border-l-#{$suffix} { border-left-width: $width; }
57
+ }
58
+ }
59
+
60
+ @each $key, $width in config.$border-widths {
61
+ @if $key == "DEFAULT" {
62
+ @include _border-width-classes("", $width);
63
+ } @else {
64
+ @include _border-width-classes($key, $width);
65
+ }
66
+ }
67
+
68
+ // ─── Border Radius ────────────────────────────────────────────────────────────
69
+
70
+ @each $key, $radius in config.$border-radii {
71
+ $rem: if($radius == 0 or $radius == 9999px, $radius, utility.px-to-rem($radius));
72
+ @if $key == "DEFAULT" {
73
+ .rounded { border-radius: $rem; }
74
+ } @else {
75
+ .rounded-#{$key} { border-radius: $rem; }
76
+ }
77
+ }
package/src/_config.scss CHANGED
@@ -1,22 +1,29 @@
1
1
  @use "sass:math";
2
2
 
3
- // Colour output space — used by colors.convert() and to-<space>()
4
- // Options: srgb, hsl, oklch, oklab, display-p3
5
- $convert-colorspace: true;
6
- $output-colorspace: oklch;
7
-
3
+ // Layout columns — used to generate grid-cols-* and col/row-span-* classes
4
+ $layout-columns: 12;
8
5
  // Layout divisions — used to generate fractional width/height classes like w-1/3, h-3/4 etc
9
- $layout-divisions: (
10
- 2,
11
- 3,
12
- 4,
13
- 5,
14
- 6,
15
- 12
6
+ $layout-divisions: (2, 3, 4, 5, 6, 12);
7
+
8
+ $border-widths: (
9
+ "DEFAULT": 1px,
10
+ "0": 0px,
11
+ "2": 2px,
12
+ "4": 4px,
13
+ "8": 8px,
16
14
  );
17
15
 
18
- // Layout columns — used to generate grid-cols-* and col/row-span-* classes
19
- $layout-columns: 12;
16
+ $border-radii: (
17
+ "none": 0,
18
+ "sm": 2px,
19
+ "DEFAULT": 4px,
20
+ "md": 6px,
21
+ "lg": 8px,
22
+ "xl": 12px,
23
+ "2xl": 16px,
24
+ "3xl": 24px,
25
+ "full": 9999px,
26
+ );
20
27
 
21
28
  // Breakpoints
22
29
  $breakpoints: (
@@ -32,19 +39,58 @@ $font-family: sans-serif;
32
39
  $base-font-size: 16px;
33
40
 
34
41
  $font-sizes: (
35
- "xs": ($base-font-size * 0.75, 1rem),
36
- "sm": ($base-font-size * 0.875, 1.25rem),
37
- "base": ($base-font-size * 1, 1.5rem),
38
- "lg": ($base-font-size * 1.125, 1.75rem),
39
- "xl": ($base-font-size * 1.25, 1.75rem),
40
- "2xl": ($base-font-size * 1.5, 2rem),
41
- "3xl": ($base-font-size * 1.875, 2.25rem),
42
- "4xl": ($base-font-size * 2.25, 2.5rem),
43
- "5xl": ($base-font-size * 3, 1),
44
- "6xl": ($base-font-size * 3.75, 1),
45
- "7xl": ($base-font-size * 4.5, 1),
46
- "8xl": ($base-font-size * 6, 1),
47
- "9xl": ($base-font-size * 8, 1),
42
+ "xs": (
43
+ $base-font-size * 0.75,
44
+ 1rem,
45
+ ),
46
+ "sm": (
47
+ $base-font-size * 0.875,
48
+ 1.25rem,
49
+ ),
50
+ "base": (
51
+ $base-font-size * 1,
52
+ 1.5rem,
53
+ ),
54
+ "lg": (
55
+ $base-font-size * 1.125,
56
+ 1.75rem,
57
+ ),
58
+ "xl": (
59
+ $base-font-size * 1.25,
60
+ 1.75rem,
61
+ ),
62
+ "2xl": (
63
+ $base-font-size * 1.5,
64
+ 2rem,
65
+ ),
66
+ "3xl": (
67
+ $base-font-size * 1.875,
68
+ 2.25rem,
69
+ ),
70
+ "4xl": (
71
+ $base-font-size * 2.25,
72
+ 2.5rem,
73
+ ),
74
+ "5xl": (
75
+ $base-font-size * 3,
76
+ 1,
77
+ ),
78
+ "6xl": (
79
+ $base-font-size * 3.75,
80
+ 1,
81
+ ),
82
+ "7xl": (
83
+ $base-font-size * 4.5,
84
+ 1,
85
+ ),
86
+ "8xl": (
87
+ $base-font-size * 6,
88
+ 1,
89
+ ),
90
+ "9xl": (
91
+ $base-font-size * 8,
92
+ 1,
93
+ ),
48
94
  );
49
95
 
50
96
  $font-weights: (
@@ -64,27 +110,32 @@ $highest-multiplier: 96;
64
110
 
65
111
  /* Base sizes can be whatever you want, the multiplier just fills it the rest of the way to that number, so you can go beyond 96. Bases can have any name or multiplier you want for greater granularity */
66
112
  $base-sizes: (
67
- 0.5 : math.div($base-size, 2),
68
- 1 : $base-size,
69
- 1.5 : $base-size * 1.5,
70
- 2 : $base-size * 2,
71
- 2.5 : $base-size * 2.5,
72
- 3 : $base-size * 3,
73
- 3.5 : $base-size * 3.5,
74
- 4 : $base-size * 4,
75
- 4.5 : $base-size * 4.5,
76
- 5 : $base-size * 5,
77
- 5.5 : $base-size * 5.5,
78
- 6 : $base-size * 6,
79
- 6.5 : $base-size * 6.5,
80
- 7 : $base-size * 7,
81
- 7.5 : $base-size * 7.5,
82
- 8 : $base-size * 8,
83
- 8.5 : $base-size * 8.5,
84
- 9 : $base-size * 9,
85
- 9.5 : $base-size * 9.5
113
+ 0.5: math.div($base-size, 2),
114
+ 1: $base-size,
115
+ 1.5: $base-size * 1.5,
116
+ 2: $base-size * 2,
117
+ 2.5: $base-size * 2.5,
118
+ 3: $base-size * 3,
119
+ 3.5: $base-size * 3.5,
120
+ 4: $base-size * 4,
121
+ 4.5: $base-size * 4.5,
122
+ 5: $base-size * 5,
123
+ 5.5: $base-size * 5.5,
124
+ 6: $base-size * 6,
125
+ 6.5: $base-size * 6.5,
126
+ 7: $base-size * 7,
127
+ 7.5: $base-size * 7.5,
128
+ 8: $base-size * 8,
129
+ 8.5: $base-size * 8.5,
130
+ 9: $base-size * 9,
131
+ 9.5: $base-size * 9.5,
86
132
  );
87
133
 
134
+ // Colour output space — used by colors.convert() and to-<space>()
135
+ // Options: srgb, hsl, oklch, oklab, display-p3
136
+ $convert-colorspace: true;
137
+ $output-colorspace: oklch;
138
+
88
139
  /* The base color are the same as tailwind - it's all on you to extend etc */
89
140
  $colors: (
90
141
  // Slate
@@ -375,5 +426,5 @@ $colors: (
375
426
 
376
427
  // Base
377
428
  "white": #ffffff,
378
- "black": #000000,
379
- );
429
+ "black": #000000
430
+ );
package/src/_display.scss CHANGED
@@ -2,56 +2,16 @@
2
2
  @use "config";
3
3
  @use "utility";
4
4
 
5
- // ─── Gap ──────────────────────────────────────────────────────────────────────
6
-
7
- @mixin gap-classes($size-name, $value) {
8
- $converted-value: utility.px-to-rem($value);
9
- $escaped: utility.str-replace($size-name, ".", "\\.");
10
-
11
- .gap-#{$escaped}, .gap#{$escaped} { gap: $converted-value; }
12
- .gap-x-#{$escaped}, .gapx#{$escaped} { column-gap: $converted-value; }
13
- .gap-y-#{$escaped}, .gapy#{$escaped} { row-gap: $converted-value; }
14
- }
15
-
16
- @each $size, $value in config.$base-sizes {
17
- @include gap-classes($size, $value);
18
- }
19
-
20
- $gap-size: 10;
21
- @while $gap-size <= config.$highest-multiplier {
22
- @include gap-classes($gap-size, config.$base-size * $gap-size);
23
- $gap-size: $gap-size + 1;
24
- }
25
-
26
- // ─── Display ──────────────────────────────────────────────────────────────────
27
-
28
-
29
5
  .block {
30
6
  display: block;
31
7
  }
32
8
 
33
- .inline-block {
34
- display: inline-block
35
- }
36
-
37
9
  .inline {
38
10
  display: inline;
39
11
  }
40
12
 
41
- .flex {
42
- display: flex;
43
- }
44
-
45
- .inline-flex {
46
- display: inline-flex;
47
- }
48
-
49
- .grid {
50
- display: grid;
51
- }
52
-
53
- .inline-grid {
54
- display: inline-grid;
13
+ .inline-block {
14
+ display: inline-block;
55
15
  }
56
16
 
57
17
  .hidden,
@@ -71,4 +31,4 @@ $gap-size: 10;
71
31
  max-width: $breakpoint;
72
32
  }
73
33
  }
74
- }
34
+ }
package/src/_flex.scss CHANGED
@@ -1,8 +1,20 @@
1
+ // ─── Display ──────────────────────────────────────────────────────────────────
2
+
3
+ .flex {
4
+ display: flex;
5
+ }
6
+
7
+ .inline-flex {
8
+ display: inline-flex;
9
+ }
10
+
11
+ // ─── Direction ────────────────────────────────────────────────────────────────
12
+
1
13
  $flex: (
2
- 'row': row,
3
- 'col': column,
4
- 'row-reverse': row-reverse,
5
- 'col-reverse': column-reverse
14
+ "row": row,
15
+ "col": column,
16
+ "row-reverse": row-reverse,
17
+ "col-reverse": column-reverse,
6
18
  );
7
19
 
8
20
  @each $name, $dir in $flex {
@@ -15,6 +27,8 @@ $flex: (
15
27
  }
16
28
  }
17
29
 
30
+ // ─── Grow & shrink ────────────────────────────────────────────────────────────
31
+
18
32
  .grow {
19
33
  flex-grow: 1;
20
34
  }
@@ -33,6 +47,14 @@ $flex: (
33
47
  flex-shrink: 0;
34
48
  }
35
49
 
36
- .flex-wrap { flex-wrap: wrap; }
37
- .flex-wrap-reverse { flex-wrap: wrap-reverse; }
38
- .flex-nowrap { flex-wrap: nowrap; }
50
+ // ─── Wrap ─────────────────────────────────────────────────────────────────────
51
+
52
+ .flex-wrap {
53
+ flex-wrap: wrap;
54
+ }
55
+ .flex-wrap-reverse {
56
+ flex-wrap: wrap-reverse;
57
+ }
58
+ .flex-nowrap {
59
+ flex-wrap: nowrap;
60
+ }
package/src/_grid.scss CHANGED
@@ -1,5 +1,9 @@
1
1
  @use "config";
2
2
 
3
+ .grid {
4
+ display: grid;
5
+ }
6
+
3
7
  // ─── Grid template columns ────────────────────────────────────────────────────
4
8
 
5
9
  @for $column from 1 through config.$layout-columns {
@@ -8,17 +12,27 @@
8
12
  }
9
13
  }
10
14
 
11
- .grid-cols-none { grid-template-columns: none; }
15
+ .grid-cols-none {
16
+ grid-template-columns: none;
17
+ }
12
18
 
13
19
  // ─── Column & row span ────────────────────────────────────────────────────────
14
20
 
15
21
  @for $columns from 1 through config.$layout-columns {
16
- .col-span-#{$columns} { grid-column: span #{$columns} / span #{$columns}; }
17
- .row-span-#{$columns} { grid-row: span #{$columns} / span #{$columns}; }
22
+ .col-span-#{$columns} {
23
+ grid-column: span #{$columns} / span #{$columns};
24
+ }
25
+ .row-span-#{$columns} {
26
+ grid-row: span #{$columns} / span #{$columns};
27
+ }
18
28
  }
19
29
 
20
- .col-span-full { grid-column: 1 / -1; }
21
- .row-span-full { grid-row: 1 / -1; }
30
+ .col-span-full {
31
+ grid-column: 1 / -1;
32
+ }
33
+ .row-span-full {
34
+ grid-row: 1 / -1;
35
+ }
22
36
 
23
37
  // ─── Grid template rows ───────────────────────────────────────────────────────
24
38
 
@@ -28,25 +42,52 @@
28
42
  }
29
43
  }
30
44
 
31
- .grid-rows-none { grid-template-rows: none; }
45
+ .grid-rows-none {
46
+ grid-template-rows: none;
47
+ }
32
48
 
33
49
  // ─── Auto columns & rows ──────────────────────────────────────────────────────
34
50
 
35
- .auto-cols-auto { grid-auto-columns: auto; }
36
- .auto-cols-min { grid-auto-columns: min-content; }
37
- .auto-cols-max { grid-auto-columns: max-content; }
38
- .auto-cols-fr { grid-auto-columns: minmax(0, 1fr); }
51
+ .auto-cols-auto {
52
+ grid-auto-columns: auto;
53
+ }
54
+ .auto-cols-min {
55
+ grid-auto-columns: min-content;
56
+ }
57
+ .auto-cols-max {
58
+ grid-auto-columns: max-content;
59
+ }
60
+ .auto-cols-fr {
61
+ grid-auto-columns: minmax(0, 1fr);
62
+ }
39
63
 
40
- .auto-rows-auto { grid-auto-rows: auto; }
41
- .auto-rows-min { grid-auto-rows: min-content; }
42
- .auto-rows-max { grid-auto-rows: max-content; }
43
- .auto-rows-fr { grid-auto-rows: minmax(0, 1fr); }
64
+ .auto-rows-auto {
65
+ grid-auto-rows: auto;
66
+ }
67
+ .auto-rows-min {
68
+ grid-auto-rows: min-content;
69
+ }
70
+ .auto-rows-max {
71
+ grid-auto-rows: max-content;
72
+ }
73
+ .auto-rows-fr {
74
+ grid-auto-rows: minmax(0, 1fr);
75
+ }
44
76
 
45
77
  // ─── Grid auto flow ───────────────────────────────────────────────────────────
46
78
 
47
- .grid-flow-row { grid-auto-flow: row; }
48
- .grid-flow-col { grid-auto-flow: column; }
49
- .grid-flow-dense { grid-auto-flow: dense; }
50
- .grid-flow-row-dense { grid-auto-flow: row dense; }
51
- .grid-flow-col-dense { grid-auto-flow: column dense; }
52
-
79
+ .grid-flow-row {
80
+ grid-auto-flow: row;
81
+ }
82
+ .grid-flow-col {
83
+ grid-auto-flow: column;
84
+ }
85
+ .grid-flow-dense {
86
+ grid-auto-flow: dense;
87
+ }
88
+ .grid-flow-row-dense {
89
+ grid-auto-flow: row dense;
90
+ }
91
+ .grid-flow-col-dense {
92
+ grid-auto-flow: column dense;
93
+ }
package/src/_reset.scss CHANGED
@@ -27,8 +27,6 @@ blockquote,
27
27
  dl,
28
28
  dd {
29
29
  margin-block-end: 0;
30
- font-size: config.$base-font-size;
31
- font-weight: typography.font-weight("normal");
32
30
  }
33
31
 
34
32
  /* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */
@@ -42,6 +40,8 @@ body {
42
40
  min-height: 100vh;
43
41
  line-height: 1.5;
44
42
  margin: 0;
43
+ font-size: config.$base-font-size;
44
+ font-weight: typography.font-weight("normal");
45
45
  }
46
46
 
47
47
  /* Set shorter line heights on headings and interactive elements */
package/src/_sizes.scss CHANGED
@@ -434,4 +434,35 @@ $size: 10;
434
434
  .size-auto {
435
435
  width: auto;
436
436
  height: auto;
437
- }
437
+ }
438
+
439
+ @mixin gap-classes($size-name, $value) {
440
+ $converted-value: utility.px-to-rem($value);
441
+ $escaped: utility.str-replace($size-name, ".", "\\.");
442
+
443
+ .gap-#{$escaped},
444
+ .gap#{$escaped} {
445
+ gap: $converted-value;
446
+ }
447
+
448
+ .gap-x-#{$escaped},
449
+ .gapx#{$escaped} {
450
+ column-gap: $converted-value;
451
+ }
452
+
453
+ .gap-y-#{$escaped},
454
+ .gapy#{$escaped} {
455
+ row-gap: $converted-value;
456
+ }
457
+ }
458
+
459
+ @each $size, $value in config.$base-sizes {
460
+ @include gap-classes($size, $value);
461
+ }
462
+
463
+ $gap-size: 10;
464
+
465
+ @while $gap-size <=config.$highest-multiplier {
466
+ @include gap-classes($gap-size, config.$base-size * $gap-size);
467
+ $gap-size: $gap-size + 1;
468
+ }
@@ -48,7 +48,6 @@ figcaption,
48
48
  caption,
49
49
  small,
50
50
  code {
51
-
52
51
  //weights
53
52
  @each $name, $value in config.$font-weights {
54
53
  $escaped: utility.str-replace($name, ".", "\\.");
@@ -69,10 +68,10 @@ code {
69
68
  }
70
69
 
71
70
  // Font sizes
72
- @each $name, $values in config.$font-sizes {
73
- .text-#{$name} {
74
- font-size: utility.px-to-rem(list.nth($values, 1));
75
- line-height: list.nth($values, 2);
71
+ @each $size, $value in config.$font-sizes {
72
+ .text-#{$size} {
73
+ font-size: utility.px-to-rem(list.nth($value, 1));
74
+ line-height: list.nth($value, 2);
76
75
  }
77
76
  }
78
77
 
@@ -81,4 +80,4 @@ code {
81
80
  .font-#{$name} {
82
81
  font-weight: $value;
83
82
  }
84
- }
83
+ }
package/src/crayon.scss CHANGED
@@ -1,4 +1,6 @@
1
1
  @forward "reset";
2
+ @forward "utility";
3
+ @forward "config";
2
4
  @forward "accessibility";
3
5
  @forward "display";
4
6
  @forward "flex";
@@ -6,6 +8,5 @@
6
8
  @forward "sizes";
7
9
  @forward "colors";
8
10
  @forward "typography";
11
+ @forward "borders";
9
12
  @forward "mixins";
10
- @forward "utility";
11
- @forward "config";