@splendidlabz/styles 2.3.2 → 3.0.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.
Files changed (147) hide show
  1. package/dist/no-tw/layouts.css +1278 -0
  2. package/dist/no-tw/styles.css +2018 -0
  3. package/dist/styles.css +1254 -1442
  4. package/package.json +23 -9
  5. package/src/addons/index.css +1 -0
  6. package/src/addons/scrollbars.css +60 -0
  7. package/src/{UI/_Accordion.scss → components/accordion.css} +8 -10
  8. package/src/components/drawer.css +20 -0
  9. package/src/components/index.css +2 -0
  10. package/src/effects/elevation.css +290 -0
  11. package/src/effects/frosted-glass.css +42 -0
  12. package/src/effects/gradients.css +107 -0
  13. package/src/effects/highlight.css +13 -0
  14. package/src/effects/index.css +6 -0
  15. package/src/effects/inner-border.css +18 -0
  16. package/src/effects/shadows.css +49 -0
  17. package/src/effects/text-outline.css +27 -0
  18. package/src/form/index.css +2 -0
  19. package/src/form/text-field.css +72 -0
  20. package/src/form/textarea.css +37 -0
  21. package/src/{Base/_Accessibility.scss → generic/accessibility.css} +21 -20
  22. package/src/generic/anchors-and-buttons.css +55 -0
  23. package/src/generic/form.css +62 -0
  24. package/src/generic/index.css +4 -0
  25. package/src/generic/typography.css +48 -0
  26. package/src/layouts/index.css +6 -0
  27. package/src/layouts/macro/flex-grid.css +33 -0
  28. package/src/layouts/macro/grid.css +127 -0
  29. package/src/layouts/macro/index.css +5 -0
  30. package/src/layouts/macro/masonry.css +23 -0
  31. package/src/layouts/macro/subgrid.css +33 -0
  32. package/src/layouts/macro/wrap.css +6 -0
  33. package/src/layouts/micro/breakout.css +38 -0
  34. package/src/layouts/micro/divider.css +102 -0
  35. package/src/layouts/micro/index.css +6 -0
  36. package/src/layouts/micro/micro.css +54 -0
  37. package/src/layouts/micro/scrollable.css +70 -0
  38. package/src/layouts/micro/stack.css +29 -0
  39. package/src/layouts/micro/stacking-context.css +3 -0
  40. package/src/layouts/position/edge.css +429 -0
  41. package/src/layouts/position/fixed.css +102 -0
  42. package/src/layouts/position/index.css +5 -0
  43. package/src/layouts/position/nudge.css +74 -0
  44. package/src/layouts/position/pos.css +337 -0
  45. package/src/layouts/position/sticky.css +11 -0
  46. package/src/layouts/shell/index.css +2 -0
  47. package/src/layouts/shell/shell-grid.css +34 -0
  48. package/src/layouts/shell/shell-simple.css +15 -0
  49. package/src/primitives/backdrop.css +8 -0
  50. package/src/{utils/_mixins.scss → primitives/break-word.css} +4 -2
  51. package/src/primitives/card.css +51 -0
  52. package/src/primitives/focus-within.css +12 -0
  53. package/src/primitives/hero-heading.css +44 -0
  54. package/src/primitives/indent-list.css +77 -0
  55. package/src/primitives/index.css +11 -0
  56. package/src/{Components/_Prose.scss → primitives/prose.css} +11 -29
  57. package/src/primitives/shapes.css +16 -0
  58. package/src/primitives/simple-svg.css +7 -0
  59. package/src/primitives/table.css +197 -0
  60. package/src/primitives/text.css +4 -0
  61. package/src/primitives/writing-mode.css +51 -0
  62. package/src/reset.css +114 -0
  63. package/src/scripts/Masonry.js +8 -0
  64. package/src/scripts/Scrollable.js +14 -0
  65. package/src/scripts/Sticky.js +34 -0
  66. package/src/scripts/all.js +7 -0
  67. package/src/scripts/index.js +4 -0
  68. package/src/styles.css +14 -0
  69. package/src/tools/border.css +9 -0
  70. package/src/tools/index.css +5 -0
  71. package/src/tools/object.css +5 -0
  72. package/src/tools/outlines.css +27 -0
  73. package/src/tools/pigment.css +205 -0
  74. package/src/tools/transitions.css +14 -0
  75. package/src/type/font-position.css +18 -0
  76. package/src/type/index.css +1 -0
  77. package/src/variables/breakpoints.css +103 -0
  78. package/src/variables/font.css +88 -0
  79. package/src/variables/index.css +4 -0
  80. package/src/variables/radius.css +54 -0
  81. package/src/variables/variables.css +34 -0
  82. package/dist/UI/Codepen.css +0 -13
  83. package/dist/UI/Codepen.css.map +0 -1
  84. package/dist/UI/Tweet.css +0 -7
  85. package/dist/UI/Tweet.css.map +0 -1
  86. package/dist/UI/Youtube.css +0 -13
  87. package/dist/UI/Youtube.css.map +0 -1
  88. package/dist/styles.css.map +0 -1
  89. package/src/Base/_Base.scss +0 -57
  90. package/src/Base/_Focus.scss +0 -38
  91. package/src/Base/_Transition.scss +0 -8
  92. package/src/Base/_index.scss +0 -4
  93. package/src/Components/_Box.scss +0 -9
  94. package/src/Components/_BrowserFrame.scss +0 -89
  95. package/src/Components/_Figure.scss +0 -5
  96. package/src/Components/_List.scss +0 -19
  97. package/src/Components/_Scrollbars.scss +0 -40
  98. package/src/Components/_SimpleSVG.scss +0 -9
  99. package/src/Components/_index.scss +0 -12
  100. package/src/Effects/_Backdrop.scss +0 -4
  101. package/src/Effects/_Elevation.scss +0 -92
  102. package/src/Effects/_Glow.scss +0 -51
  103. package/src/Effects/_Gradients.scss +0 -88
  104. package/src/Effects/_Shadows.scss +0 -51
  105. package/src/Effects/_SpecialShadows.scss +0 -45
  106. package/src/Effects/_Text-Outline.scss +0 -25
  107. package/src/Effects/_index.scss +0 -12
  108. package/src/Experimental/_SimplePricingPlan.scss +0 -141
  109. package/src/Forms/_Button.scss +0 -106
  110. package/src/Forms/_Combobox.scss +0 -49
  111. package/src/Forms/_FormBase.scss +0 -43
  112. package/src/Forms/_FormControls.scss +0 -95
  113. package/src/Forms/_Range.scss +0 -101
  114. package/src/Forms/_Select.scss +0 -114
  115. package/src/Forms/_Switch.scss +0 -66
  116. package/src/Forms/_TextField.scss +0 -116
  117. package/src/Forms/_Textarea.scss +0 -41
  118. package/src/Forms/_index.scss +0 -10
  119. package/src/Typography/_WritingMode.scss +0 -33
  120. package/src/Typography/_index.scss +0 -1
  121. package/src/UI/Codepen.scss +0 -11
  122. package/src/UI/Tweet.scss +0 -5
  123. package/src/UI/Youtube.scss +0 -13
  124. package/src/UI/_Breadcrumbs.scss +0 -24
  125. package/src/UI/_CQChecker.scss +0 -16
  126. package/src/UI/_Callout.scss +0 -31
  127. package/src/UI/_Drawer.scss +0 -28
  128. package/src/UI/_Dropdown.scss +0 -14
  129. package/src/UI/_FancyList.scss +0 -30
  130. package/src/UI/_PerspectiveHover.scss +0 -9
  131. package/src/UI/_Popover.scss +0 -25
  132. package/src/UI/_Resizer.scss +0 -43
  133. package/src/UI/_Spotlight.scss +0 -42
  134. package/src/UI/_Status.scss +0 -33
  135. package/src/UI/_Tabs.scss +0 -112
  136. package/src/UI/_Textwall.scss +0 -22
  137. package/src/UI/_index.scss +0 -17
  138. package/src/Utilities/_Shapes.scss +0 -20
  139. package/src/Utilities/_index.scss +0 -1
  140. package/src/Variables/_Globals.scss +0 -33
  141. package/src/Variables/_index.scss +0 -1
  142. package/src/_Animations.scss +0 -18
  143. package/src/_Fill.scss +0 -314
  144. package/src/styles.scss +0 -12
  145. package/src/utils/_index.scss +0 -3
  146. package/src/utils/functions/_fns.scss +0 -77
  147. package/src/utils/functions/_fonts.scss +0 -114
@@ -0,0 +1,77 @@
1
+ @utility indent-list-scaffold {
2
+ --indent-list-depth: 0;
3
+
4
+ li li {
5
+ margin-inline-start: var(--indent, 1em);
6
+ }
7
+
8
+ /* prettier-ignore */
9
+ li {
10
+ --depth: 1;
11
+ a { --depth: 1; }
12
+
13
+ li,
14
+ li a { --depth: 2; }
15
+
16
+ li li,
17
+ li li a { --depth: 3; }
18
+
19
+ li li li,
20
+ li li li a { --depth: 4; }
21
+
22
+ li li li li,
23
+ li li li li a { --depth: 5; }
24
+ }
25
+
26
+ /* Resets left padding */
27
+ :where(ul, ol, li) {
28
+ padding-inline-start: 0;
29
+ }
30
+
31
+ /* Use Fill to update colors. */
32
+ a {
33
+ display: block;
34
+ padding-block: 0.125em;
35
+ }
36
+ }
37
+
38
+ @utility indent-list {
39
+ @apply indent-list-scaffold;
40
+
41
+ li {
42
+ list-style-type: disc;
43
+ }
44
+ }
45
+
46
+ @utility indent-list-guides {
47
+ & {
48
+ @apply indent-list-scaffold;
49
+
50
+ li li {
51
+ position: relative;
52
+ margin-inline-start: 0;
53
+ padding-inline-start: var(--indent, 1em);
54
+
55
+ a {
56
+ position: relative;
57
+ margin-left: calc(var(--indent, 1em) * -1);
58
+ padding-left: var(--indent, 1em);
59
+ }
60
+
61
+ &::before,
62
+ a::before {
63
+ content: '';
64
+ position: absolute;
65
+ top: 0;
66
+ bottom: 0;
67
+ left: 0;
68
+ width: 1px;
69
+ background-color: var(--border-color);
70
+ }
71
+
72
+ a:hover::before {
73
+ background-color: var(--border-hover-color);
74
+ }
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,11 @@
1
+ @import './backdrop.css';
2
+ @import './break-word.css';
3
+ @import './card.css';
4
+ @import './focus-within.css';
5
+ @import './hero-heading.css';
6
+ @import './indent-list.css';
7
+ @import './prose.css';
8
+ @import './shapes.css';
9
+ @import './simple-svg.css';
10
+ @import './table.css';
11
+ @import './writing-mode.css';
@@ -1,29 +1,30 @@
1
- @layer components {
2
- // Updating Prose to use Flex too, but this is incomplete
3
- .Prose {
1
+ @utility prose {
2
+ & {
4
3
  display: flex;
5
4
  flex-flow: column;
6
5
  gap: 1em;
7
6
  max-width: 100%;
8
7
 
9
- // Using padding instead of margin, so #targets will leave some whitespace above when scolling to the component. (We can also use scroll-margin-top + margin-top... but this is simpler).
8
+ /* Using padding instead of margin, so #targets will leave some whitespace above when scrolling to the component. (We can also use scroll-margin-top + margin-top... but this is simpler). */
10
9
  * + :where(h2, h3),
11
10
  * + :where(astro-island, astro-slot) > :where(:where(h2, h3):first-child) {
12
- padding-top: 2em;
11
+ margin-top: 2em;
12
+ scroll-margin-top: 2em;
13
13
  }
14
14
 
15
15
  * + :where(h4, h5, h6),
16
16
  *
17
17
  + :where(astro-island, astro-slot)
18
18
  > :where(:where(h4, h5, h6):first-child) {
19
- padding-top: 1em;
19
+ margin-top: 1em;
20
+ scroll-margin-top: 2em;
20
21
  }
21
22
 
22
23
  :where(ul, ol) {
23
- list-style-type: revert-layer;
24
+ list-style-type: initial;
24
25
  }
25
26
 
26
- // Basic list styles
27
+ /* Basic list styles */
27
28
  > :where(ul, ol),
28
29
  > :where(astro-island, astro-slot) > :where(ul, ol) {
29
30
  list-style-position: outside;
@@ -50,31 +51,12 @@
50
51
  }
51
52
  }
52
53
 
53
- code {
54
- font-size: 0.8em;
55
- }
56
-
57
- :not(pre) > code {
58
- display: inline;
59
- padding: 0.2em 0.25em;
60
- border-radius: var(--radius);
61
- }
62
-
63
- // Code Styles
64
- pre {
65
- padding: 1em;
66
- border-radius: var(--radius);
67
-
68
- code {
69
- background-color: transparent;
70
- }
71
- }
72
-
73
54
  :where(a) {
74
55
  text-decoration: underline;
75
56
  }
76
57
 
77
- > img {
58
+ > img,
59
+ figure img {
78
60
  border: 1px solid oklch(90% 0 0deg);
79
61
  border-radius: var(--radius);
80
62
  }
@@ -0,0 +1,16 @@
1
+ @utility square {
2
+ aspect-ratio: 1;
3
+ }
4
+
5
+ @utility circle {
6
+ aspect-ratio: 1;
7
+ border-radius: 50%;
8
+ }
9
+
10
+ @utility roundrect {
11
+ border-radius: var(--radius, 8px);
12
+ }
13
+
14
+ @utility pill {
15
+ border-radius: 100em;
16
+ }
@@ -0,0 +1,7 @@
1
+ @utility simple-svg {
2
+ :where(path) {
3
+ fill: var(--fill-color);
4
+ stroke: var(--stroke-color); /* Fallback to text color */
5
+ stroke-width: var(--stroke-width);
6
+ }
7
+ }
@@ -0,0 +1,197 @@
1
+ /*********************
2
+ * Table scaffold utilities *
3
+ *********************/
4
+ @utility table-scaffold {
5
+ & {
6
+ width: 100%;
7
+
8
+ /* font: inherit; Not sure if needed? */
9
+ font-variant-numeric: lining-nums tabular-nums slashed-zero
10
+ diagonal-fractions;
11
+ }
12
+ }
13
+
14
+ /* These overwrite Tailwind's default table-auto and table-fixed utilities */
15
+ @utility table-auto {
16
+ :where(table) & {
17
+ table-layout: auto;
18
+ }
19
+
20
+ :where(.table-grid) & {
21
+ @apply grid-repeat-auto;
22
+ }
23
+ }
24
+
25
+ @utility table-fixed {
26
+ :where(table) & {
27
+ table-layout: fixed;
28
+ }
29
+
30
+ :where(.table-grid) & {
31
+ @apply grid-simple;
32
+ }
33
+ }
34
+
35
+ /* Helpful utilities for code reuse *
36
+ *********************/
37
+ @utility table-header-row {
38
+ & {
39
+ border-top: var(--header-row-border-top);
40
+ border-bottom: var(--header-row-border-bottom);
41
+ font-weight: bold;
42
+ }
43
+ }
44
+
45
+ @utility table-header-column {
46
+ font-weight: bold;
47
+ }
48
+
49
+ @utility table-cell {
50
+ text-align: left;
51
+ padding: var(--padding, var(--padding-x, 0.375rem))
52
+ var(--padding, var(--padding-y, 0.5rem));
53
+ }
54
+
55
+ @utility table-center {
56
+ :is(td, th) {
57
+ text-align: center;
58
+ }
59
+ }
60
+
61
+ @utility table-radius {
62
+ th:first-child {
63
+ border-start-start-radius: var(--radius);
64
+ }
65
+
66
+ th:last-child {
67
+ border-start-end-radius: var(--radius);
68
+ }
69
+
70
+ :where(:not(thead)) {
71
+ td:first-child {
72
+ border-start-start-radius: var(--radius);
73
+ }
74
+
75
+ td:last-child {
76
+ border-start-end-radius: var(--radius);
77
+ }
78
+ }
79
+
80
+ tr:last-child {
81
+ td:first-child {
82
+ border-end-start-radius: var(--radius);
83
+ }
84
+
85
+ td:last-child {
86
+ border-end-end-radius: var(--radius);
87
+ }
88
+ }
89
+ }
90
+
91
+ /* WIP. Not ready for external usage */
92
+
93
+ /* Basic table styles */
94
+ table {
95
+ @apply table-scaffold;
96
+ border-collapse: collapse;
97
+
98
+ /* Alternate background on tr
99
+ For consistency with others below, we're using 2n + 3
100
+ Skips the first row because usually first row is th values.
101
+ If you use thead then you have to adjust this accordingly
102
+ Note that tbody is automatically created by the browser */
103
+ &:has(thead) tr:nth-child(2n + 2) {
104
+ background-color: var(--alt-row-color);
105
+ }
106
+
107
+ &:not(:has(thead)) tr {
108
+ tr:nth-child(2n + 3) {
109
+ background-color: var(--alt-row-color);
110
+ }
111
+ }
112
+
113
+ /* Column headers */
114
+ th:where([scope='colgroup'], [scope='col'], :not([scope])) {
115
+ @apply table-header-row;
116
+ }
117
+
118
+ /* Row Headers */
119
+
120
+ /* Not adding border-right because it's a bit too much if table-layout is auto */
121
+ th:where([scope='group'], [scope='row']) {
122
+ @apply table-header-column;
123
+ }
124
+
125
+ /* All Cells */
126
+ :is(th, td) {
127
+ @apply table-cell;
128
+ }
129
+ }
130
+
131
+ /*********************
132
+ * Table with CSS Grid and Subgrid *
133
+ *********************/
134
+
135
+ /* Table */
136
+
137
+ /* Use grid-repeat-auto by default. Provide --cols to adjust number of columns. */
138
+ .table-grid:where(table, [role='table'], [role='grid']) {
139
+ @apply table-scaffold;
140
+ @apply table-auto;
141
+ max-width: 100%;
142
+ }
143
+
144
+ /* Thead, Tbody, Tfoot equivalents */
145
+
146
+ /* These need to be display:contents for subgrid to work */
147
+ .table-grid :where(thead, tbody, tfoot, [role='rowgroup']) {
148
+ display: contents;
149
+ }
150
+
151
+ /* Tr / row */
152
+ .table-grid :where(tr, [role='row']) {
153
+ grid-column: 1/-1;
154
+ display: grid;
155
+ grid-template-columns: subgrid;
156
+ grid-template-rows: subgrid;
157
+
158
+ /* Alternating row colours */
159
+ &:nth-child(2n + 3) {
160
+ background-color: var(--alt-row-color);
161
+ }
162
+ }
163
+
164
+ /* Column Headers */
165
+
166
+ /* Same styles as above */
167
+ .table-grid
168
+ :where(
169
+ th[scope='colgroup'],
170
+ th[scope='col'],
171
+ th:not([scope]),
172
+ [role='columnheader']
173
+ ) {
174
+ @apply table-header-row;
175
+ }
176
+
177
+ /* Row Headers */
178
+
179
+ /* Same style as row headers above */
180
+ .table-grid :where(th[scope='rowgroup'], th[scope='row'], [role='rowheader']) {
181
+ @apply table-header-column;
182
+ }
183
+
184
+ /* All Cells */
185
+ .table-grid
186
+ :where(
187
+ [role='columnheader'],
188
+ [role='rowheader'],
189
+ [role='cell'],
190
+ [role='gridcell'],
191
+ th,
192
+ td
193
+ ) {
194
+ @apply table-cell;
195
+ display: grid; /* For easier content positioning */
196
+ align-items: center;
197
+ }
@@ -0,0 +1,4 @@
1
+ @utility text-upper {
2
+ text-transform: uppercase;
3
+ letter-spacing: 0.075em;
4
+ }
@@ -0,0 +1,51 @@
1
+ @utility writing-scaffold {
2
+ /* Prevents text from transitioning. Enable manually if you want transition */
3
+ transition: none;
4
+ }
5
+
6
+ @utility writing-normal {
7
+ @apply writing-scaffold;
8
+ writing-mode: horizontal-tb;
9
+ }
10
+
11
+ @utility writing-rotated-left {
12
+ & {
13
+ @apply writing-scaffold;
14
+ writing-mode: vertical-rl;
15
+ text-orientation: sideways;
16
+ transform: rotate(180deg);
17
+
18
+ /* // transform: scale( -1, -1 ); // This is the alternative if we don't want to use rotate */
19
+ }
20
+ }
21
+
22
+ @utility writing-rotated-right {
23
+ & {
24
+ @apply writing-scaffold;
25
+ writing-mode: vertical-rl;
26
+ text-orientation: sideways;
27
+ }
28
+ }
29
+
30
+ @utility writing-downwards {
31
+ & {
32
+ @apply writing-scaffold;
33
+ writing-mode: vertical-lr;
34
+ text-orientation: upright;
35
+ }
36
+ }
37
+
38
+ /* Alias for writing-downwards */
39
+ @utility writing-downards-lr {
40
+ & {
41
+ @apply writing-downwards;
42
+ }
43
+ }
44
+
45
+ @utility writing-downwards-rl {
46
+ & {
47
+ @apply writing-scaffold;
48
+ writing-mode: vertical-rl;
49
+ text-orientation: upright;
50
+ }
51
+ }
package/src/reset.css ADDED
@@ -0,0 +1,114 @@
1
+ /*************
2
+ * Box Sizing *
3
+ **************/
4
+ html {
5
+ box-sizing: border-box;
6
+ }
7
+
8
+ *,
9
+ *::before,
10
+ *::after {
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ html,
15
+ body {
16
+ height: 100%;
17
+ }
18
+
19
+ /*********************
20
+ * Fills the viewport, fallbacks to vh *
21
+ *********************/
22
+ body {
23
+ min-height: 100vh;
24
+ min-height: 100svh;
25
+ }
26
+
27
+ /*********************
28
+ * Remove default margin and paddings *
29
+ *********************/
30
+ * {
31
+ margin: 0;
32
+ padding: 0;
33
+ border-width: 0;
34
+ border-style: solid;
35
+ }
36
+
37
+ /*********************
38
+ * Avoid text overflows *
39
+ *********************/
40
+ p,
41
+ h1,
42
+ h2,
43
+ h3,
44
+ h4,
45
+ h5,
46
+ h6 {
47
+ overflow-wrap: break-word;
48
+ scroll-margin: 2em;
49
+ }
50
+
51
+ /*********************
52
+ * Lists *
53
+ *********************/
54
+ ul {
55
+ list-style: none;
56
+ }
57
+
58
+ /*********************
59
+ * Better defaults for media elements *
60
+ *********************/
61
+ img,
62
+ video,
63
+ object,
64
+ embed,
65
+ svg {
66
+ display: block;
67
+ width: 100%;
68
+ max-width: 100%;
69
+ height: auto;
70
+ }
71
+
72
+ picture {
73
+ display: flex;
74
+ justify-content: center;
75
+ }
76
+
77
+ /* These elements should not have height:auto */
78
+ iframe,
79
+ canvas {
80
+ display: block;
81
+ max-width: 100%;
82
+ }
83
+
84
+ svg {
85
+ pointer-events: none; /* Because SVGs should not intercept events */
86
+ flex-shrink: 0; /* Prevents SVG from being squished when used as flexbox descendant */
87
+ box-sizing: content-box; /* Prevents SVG from being squished when adding padding values */
88
+
89
+ /* Default SVG dimensions. Override as necessary */
90
+ width: var(--svg-width, auto);
91
+ height: var(--svg-height, 1em);
92
+ }
93
+
94
+ hr {
95
+ height: 1px;
96
+ background-color: var(--border-color, black);
97
+ }
98
+
99
+ /*********************
100
+ * The hidden attribute *
101
+ *********************/
102
+ [hidden] {
103
+ display: none;
104
+ opacity: 0;
105
+ visibility: hidden;
106
+ }
107
+
108
+ /*********************
109
+ * Noscript *
110
+ *********************/
111
+ noscript {
112
+ display: block;
113
+ margin-block: 1em;
114
+ }
@@ -0,0 +1,8 @@
1
+ import { getElement } from '@splendidlabz/utils/dom'
2
+ import { masonry } from '@splendidlabz/utils/actions'
3
+
4
+ export function Masonry(selector) {
5
+ const container = getElement(selector) || document
6
+ const elements = Array.from(container.querySelectorAll("[class*='masonry']"))
7
+ elements.forEach(masonry)
8
+ }
@@ -0,0 +1,14 @@
1
+ import { getElement } from '@splendidlabz/utils/dom'
2
+ import { preferHorizontalScroll } from '@splendidlabz/utils/actions'
3
+
4
+ export function ScrollableHorizontal(selector) {
5
+ const container = getElement(selector) || document
6
+ const elements = Array.from(
7
+ container.querySelectorAll('.scrollable-prefer-horizontal'),
8
+ )
9
+
10
+ if (container.classList?.contains('scrollable-prefer-horizontal'))
11
+ elements.push(container)
12
+
13
+ elements.forEach(preferHorizontalScroll)
14
+ }
@@ -0,0 +1,34 @@
1
+ import { mutationObserver, sticky } from '@splendidlabz/utils/actions'
2
+
3
+ import { getElement } from '@splendidlabz/utils/dom'
4
+
5
+ /**
6
+ * Initializes sticky behavior for elements within a container.
7
+ * @param {string|HTMLElement} selector - The selector or element to initialize sticky behavior within.
8
+ * @param {Object} [options] - Optional settings.
9
+ * @param {number} [options.observeTimeout=0] - The timeout in milliseconds to observe DOM mutations.
10
+ */
11
+ export function Sticky(selector, { observerTimeout = 1000 } = {}) {
12
+ const container = getElement(selector) || document.body
13
+ const elements = Array.from(container.querySelectorAll('.sticky-check'))
14
+
15
+ if (container.classList.contains('sticky-check')) elements.push(container)
16
+
17
+ elements.forEach(sticky)
18
+
19
+ if (observerTimeout) {
20
+ const obs = mutationObserver(container, {
21
+ childList: true,
22
+ subtree: true,
23
+ callback: function ({ entry, observer }) {
24
+ // Nodes seem to be added one by one, so getting the first one is enough
25
+ const node = entry.addedNodes[0]
26
+ const klass = node?.className
27
+ if (!klass || typeof klass !== 'string') return
28
+ if (!klass.includes('sticky-check')) return
29
+ sticky(node)
30
+ },
31
+ })
32
+ if (observerTimeout) setTimeout(_ => obs.disconnect(), observerTimeout)
33
+ }
34
+ }
@@ -0,0 +1,7 @@
1
+ import { Masonry, ScrollableHorizontal, Sticky } from './index.js'
2
+
3
+ export default function LayoutScripts(element = null) {
4
+ Masonry(element)
5
+ Sticky(element)
6
+ ScrollableHorizontal(element)
7
+ }
@@ -0,0 +1,4 @@
1
+ export * from './all.js'
2
+ export * from './Masonry.js'
3
+ export * from './Scrollable.js'
4
+ export * from './Sticky.js'
package/src/styles.css ADDED
@@ -0,0 +1,14 @@
1
+ /* Splendid Styles */
2
+ @import './reset.css' layer(reset);
3
+ @import './variables/index.css';
4
+ @import './tools/index.css';
5
+ @import './generic/index.css';
6
+ @import './form/index.css';
7
+ @import './primitives/index.css';
8
+ @import './layouts/index.css';
9
+ @import './type/index.css';
10
+ @import './effects/index.css';
11
+
12
+ /* Addons */
13
+ /* @import './components/index.css'; */
14
+ /* @import './addons/index.css' */
@@ -0,0 +1,9 @@
1
+ @utility border-scaffold {
2
+ border: var(--border-width) var(--border-style) var(--border-color);
3
+ border-radius: var(--radius);
4
+ }
5
+
6
+ @utility padding-scaffold {
7
+ padding-block: var(--padding-block, var(--padding, 0));
8
+ padding-inline: var(--padding-inline, var(--padding, 0));
9
+ }
@@ -0,0 +1,5 @@
1
+ @import './pigment.css';
2
+ @import './outlines.css';
3
+ @import './border.css';
4
+ @import './object.css';
5
+ @import './transitions.css';
@@ -0,0 +1,5 @@
1
+ @utility object-background {
2
+ object-fit: cover;
3
+ width: 100%;
4
+ height: 100%;
5
+ }
@@ -0,0 +1,27 @@
1
+ /*********************
2
+ * Setup outlines *
3
+ * Useful for all outline transitions and animations
4
+ *********************/
5
+ @layer base {
6
+ * {
7
+ outline: var(--outline-width) var(--outline-style) transparent;
8
+ outline-offset: var(--outline-offset);
9
+ }
10
+ }
11
+
12
+ /* Utility to make outline visible. typically used in focus or focus-visible */
13
+ @utility outline-visible {
14
+ outline-color: var(--outline-color);
15
+ }
16
+
17
+ /* These preserve outlines on scrollable elements that use a flex display *
18
+ * Notes:
19
+ - content-box is necessary, if not present, box will be cut on the right side
20
+ *********************/
21
+ @utility preserve-outlines {
22
+ & {
23
+ box-sizing: content-box;
24
+ margin: calc(var(--outline-width) * -1);
25
+ padding: calc(var(--outline-width));
26
+ }
27
+ }