@splendidlabz/styles 3.0.0 → 4.0.0-alpha.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.
Files changed (47) hide show
  1. package/package.json +9 -8
  2. package/src/animation/animation.css +14 -0
  3. package/src/animation/fly.css +74 -0
  4. package/src/animation/index.css +2 -0
  5. package/src/astro/index.css +1 -0
  6. package/src/astro/textwall.css +26 -0
  7. package/src/components/accordion.css +21 -15
  8. package/src/components/browserframe.css +84 -0
  9. package/src/components/drawer.css +23 -17
  10. package/src/components/index.css +4 -0
  11. package/src/components/modal.css +62 -0
  12. package/src/components/popover.css +38 -0
  13. package/src/components/tabs.css +111 -0
  14. package/src/effects/fancy-box.css +259 -0
  15. package/src/effects/gradients.css +8 -9
  16. package/src/effects/index.css +3 -1
  17. package/src/effects/shadows.css +0 -9
  18. package/src/effects/stroke.css +25 -0
  19. package/src/form/checkbox-and-radio.css +137 -0
  20. package/src/form/index.css +3 -1
  21. package/src/form/{text-field.css → input.css} +5 -17
  22. package/src/form/select.css +55 -0
  23. package/src/generic/anchors-and-buttons.css +11 -6
  24. package/src/generic/form.css +1 -7
  25. package/src/layouts/macro/grid.css +36 -7
  26. package/src/layouts/micro/micro.css +0 -4
  27. package/src/layouts/position/fixed.css +80 -49
  28. package/src/primitives/hero-heading.css +2 -2
  29. package/src/primitives/index.css +0 -2
  30. package/src/primitives/prose.css +8 -8
  31. package/src/primitives/simple-svg.css +1 -1
  32. package/src/reset.css +1 -2
  33. package/src/styles.css +2 -0
  34. package/src/tools/object.css +4 -1
  35. package/src/tools/outlines.css +30 -0
  36. package/src/tools/transitions.css +13 -2
  37. package/src/transitions/index.css +1 -0
  38. package/src/transitions/starting-style.css +74 -0
  39. package/src/variables/variables.css +4 -3
  40. package/src/primitives/backdrop.css +0 -8
  41. package/src/primitives/focus-within.css +0 -12
  42. package/src/scripts/Masonry.js +0 -8
  43. package/src/scripts/Scrollable.js +0 -14
  44. package/src/scripts/Sticky.js +0 -34
  45. package/src/scripts/all.js +0 -7
  46. package/src/scripts/index.js +0 -4
  47. /package/src/effects/{text-outline.css → text.css} +0 -0
@@ -5,98 +5,129 @@
5
5
  /* top *
6
6
  *********************/
7
7
  @utility fixed-top {
8
- position: fixed;
9
- top: 0;
10
- left: 0;
11
- right: 0;
8
+ & {
9
+ position: fixed;
10
+ top: 0;
11
+ bottom: auto;
12
+ inset-inline: 0;
13
+ }
12
14
  }
13
15
 
14
16
  @utility fixed-topleft {
15
- @apply fixed-top;
16
- @apply nudge-topleft;
17
- right: auto;
17
+ & {
18
+ @apply fixed-top;
19
+ right: auto;
20
+ }
18
21
  }
19
22
 
20
23
  @utility fixed-topright {
21
- @apply fixed-top;
22
- @apply nudge-topright;
23
- left: auto;
24
+ & {
25
+ @apply fixed-top;
26
+ left: auto;
27
+ }
24
28
  }
25
29
 
26
30
  @utility fixed-topfull {
27
- @apply fixed-top;
28
- @apply nudge-topfull;
31
+ & {
32
+ @apply fixed-top;
33
+ width: 100%;
34
+ max-width: none;
35
+ margin-inline: 0;
36
+ }
29
37
  }
30
38
 
31
39
  /* bottom *
32
40
  *********************/
33
41
  @utility fixed-bottom {
34
- position: fixed;
35
- bottom: 0;
36
- left: 0;
37
- right: 0;
42
+ & {
43
+ position: fixed;
44
+ top: auto;
45
+ bottom: 0;
46
+ inset-inline: 0;
47
+ }
38
48
  }
39
49
 
40
50
  @utility fixed-bottomleft {
41
- @apply fixed-bottom;
42
- @apply nudge-bottomleft;
43
- right: auto;
51
+ & {
52
+ @apply fixed-bottom;
53
+ right: auto;
54
+ }
44
55
  }
45
56
 
46
57
  @utility fixed-bottomright {
47
- @apply fixed-bottom;
48
- @apply nudge-bottomright;
49
- left: auto;
58
+ & {
59
+ @apply fixed-bottom;
60
+ left: auto;
61
+ }
50
62
  }
51
63
 
52
64
  @utility fixed-bottomfull {
53
- @apply fixed-bottom;
54
- @apply nudge-bottomfull;
65
+ & {
66
+ @apply fixed-bottom;
67
+ width: 100%;
68
+ max-width: none;
69
+ margin-inline: 0;
70
+ }
55
71
  }
56
72
 
57
73
  /* left *
58
- *********************/
74
+ *********************/
59
75
  @utility fixed-left {
60
- position: fixed;
61
- top: 0;
62
- bottom: 0;
63
- left: 0;
76
+ & {
77
+ position: fixed;
78
+ inset-block: 0;
79
+ left: 0;
80
+ right: auto;
81
+ }
64
82
  }
65
83
 
66
84
  @utility fixed-leftfull {
67
- @apply fixed-left;
68
- @apply nudge-leftfull;
85
+ & {
86
+ @apply fixed-left;
87
+ height: auto;
88
+ max-height: none;
89
+ margin-block: 0;
90
+ }
69
91
  }
70
92
 
71
93
  /* right *
72
- *********************/
94
+ *********************/
73
95
  @utility fixed-right {
74
- position: fixed;
75
- top: 0;
76
- bottom: 0;
77
- right: 0;
96
+ & {
97
+ position: fixed;
98
+ inset-block: 0;
99
+ left: auto;
100
+ right: 0;
101
+ }
78
102
  }
79
103
 
80
104
  @utility fixed-rightfull {
81
- @apply fixed-right;
82
- @apply nudge-rightfull;
105
+ & {
106
+ @apply fixed-right;
107
+ height: auto;
108
+ max-height: none;
109
+ margin-block: 0;
110
+ }
83
111
  }
84
112
 
85
113
  /* center *
86
- *********************/
114
+ *********************/
87
115
  @utility fixed-center {
88
- position: fixed;
89
- top: 50%;
90
- left: 50%;
91
- transform: translate(-50%, -50%);
116
+ & {
117
+ position: fixed;
118
+ width: fit-content;
119
+ height: fit-content;
120
+ margin: auto;
121
+ }
92
122
  }
93
123
 
94
124
  /* overlay *
95
- *********************/
125
+ *********************/
96
126
  @utility fixed-overlay {
97
- pointer-events: none;
98
- position: fixed;
99
- inset-block: var(--nudge-y, var(--nudge, 0));
100
- inset-inline: var(--nudge-x, var(--nudge, 0));
101
- display: grid;
127
+ & {
128
+ position: fixed;
129
+ inset-block: var(--nudge-y, var(--nudge, 0));
130
+ inset-inline: var(--nudge-x, var(--nudge, 0));
131
+ display: grid;
132
+ }
102
133
  }
@@ -4,10 +4,10 @@
4
4
  @utility hero-heading {
5
5
  display: flex;
6
6
  flex-direction: column;
7
- gap: var(--gap, 0.25em);
7
+ gap: 0.25rem;
8
8
  max-width: 100%;
9
9
 
10
- > :where(.hero-eyebrow) {
10
+ > .eyebrow {
11
11
  font-size: var(--eyebrow-size, 0.6em);
12
12
  }
13
13
 
@@ -1,7 +1,5 @@
1
- @import './backdrop.css';
2
1
  @import './break-word.css';
3
2
  @import './card.css';
4
- @import './focus-within.css';
5
3
  @import './hero-heading.css';
6
4
  @import './indent-list.css';
7
5
  @import './prose.css';
@@ -2,22 +2,22 @@
2
2
  & {
3
3
  display: flex;
4
4
  flex-flow: column;
5
- gap: 1em;
5
+ gap: 1lh;
6
6
  max-width: 100%;
7
7
 
8
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). */
9
9
  * + :where(h2, h3),
10
10
  * + :where(astro-island, astro-slot) > :where(:where(h2, h3):first-child) {
11
- margin-top: 2em;
12
- scroll-margin-top: 2em;
11
+ margin-top: 2lh;
12
+ scroll-margin-top: 2lh;
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
- margin-top: 1em;
20
- scroll-margin-top: 2em;
19
+ margin-top: 1lh;
20
+ scroll-margin-top: 2lh;
21
21
  }
22
22
 
23
23
  :where(ul, ol) {
@@ -39,15 +39,15 @@
39
39
  }
40
40
 
41
41
  li + li {
42
- margin-top: 0.25em;
42
+ margin-top: 0.25lh;
43
43
  }
44
44
 
45
45
  li:has(li) + li {
46
- margin-top: 0.5em;
46
+ margin-top: 0.5lh;
47
47
  }
48
48
 
49
49
  li > :where(ul, ol) {
50
- margin-top: 0.25em;
50
+ margin-top: 0.25lh;
51
51
  }
52
52
  }
53
53
 
@@ -1,5 +1,5 @@
1
1
  @utility simple-svg {
2
- :where(path) {
2
+ * {
3
3
  fill: var(--fill-color);
4
4
  stroke: var(--stroke-color); /* Fallback to text color */
5
5
  stroke-width: var(--stroke-width);
package/src/reset.css CHANGED
@@ -82,13 +82,12 @@ canvas {
82
82
  }
83
83
 
84
84
  svg {
85
- pointer-events: none; /* Because SVGs should not intercept events */
86
85
  flex-shrink: 0; /* Prevents SVG from being squished when used as flexbox descendant */
87
86
  box-sizing: content-box; /* Prevents SVG from being squished when adding padding values */
88
87
 
89
88
  /* Default SVG dimensions. Override as necessary */
90
89
  width: var(--svg-width, auto);
91
- height: var(--svg-height, 1em);
90
+ height: var(--svg-height, auto);
92
91
  }
93
92
 
94
93
  hr {
package/src/styles.css CHANGED
@@ -8,6 +8,8 @@
8
8
  @import './layouts/index.css';
9
9
  @import './type/index.css';
10
10
  @import './effects/index.css';
11
+ @import './transitions/index.css';
12
+ @import './animation/index.css';
11
13
 
12
14
  /* Addons */
13
15
  /* @import './components/index.css'; */
@@ -1,5 +1,8 @@
1
1
  @utility object-background {
2
- object-fit: cover;
2
+ position: absolute;
3
+ inset: 0;
4
+ z-index: -1;
3
5
  width: 100%;
4
6
  height: 100%;
7
+ object-fit: cover;
5
8
  }
@@ -2,6 +2,8 @@
2
2
  * Setup outlines *
3
3
  * Useful for all outline transitions and animations
4
4
  *********************/
5
+
6
+ /* Can improve this... */
5
7
  @layer base {
6
8
  * {
7
9
  outline: var(--outline-width) var(--outline-style) transparent;
@@ -9,11 +11,39 @@
9
11
  }
10
12
  }
11
13
 
14
+ @utility outline-scaffold {
15
+ & {
16
+ outline: var(--outline-width) var(--outline-style) transparent;
17
+ outline-offset: var(--outline-offset);
18
+
19
+ &:focus {
20
+ @apply outline-visible;
21
+ }
22
+ }
23
+ }
24
+
12
25
  /* Utility to make outline visible. typically used in focus or focus-visible */
13
26
  @utility outline-visible {
14
27
  outline-color: var(--outline-color);
15
28
  }
16
29
 
30
+ @utility focus-outline-visible {
31
+ &:focus {
32
+ @apply outline-visible;
33
+ }
34
+ }
35
+
36
+ @utility focus-within {
37
+ & {
38
+ outline: var(--outline-width) var(--outline-style) transparent;
39
+ outline-offset: var(--outline-offset);
40
+ }
41
+
42
+ &:focus-within {
43
+ outline-color: var(--outline-color);
44
+ }
45
+ }
46
+
17
47
  /* These preserve outlines on scrollable elements that use a flex display *
18
48
  * Notes:
19
49
  - content-box is necessary, if not present, box will be cut on the right side
@@ -6,8 +6,19 @@
6
6
  --transition-values: var(--transition-duration) var(--transition-delay)
7
7
  var(--transition-easing);
8
8
  --transition-props:
9
- backdrop-filter, background, border, color, fill, filter, gap, opacity,
10
- opacity, outline, stroke, transform;
9
+ backdrop-filter, background, border, color, display, fill, filter, gap,
10
+ opacity, outline, overlay, stroke, transform;
11
+ transition: var(--transition-values);
12
+ transition-property: var(--transition-props);
13
+ transition-behavior: allow-discrete;
14
+ }
15
+ }
16
+
17
+ @utility transition-svg {
18
+ & {
19
+ --transition-values: var(--transition-duration) var(--transition-delay)
20
+ var(--transition-easing);
21
+ --transition-props: opacity, fill, stroke;
11
22
  transition: var(--transition-values);
12
23
  transition-property: var(--transition-props);
13
24
  }
@@ -0,0 +1 @@
1
+ @import './starting-style.css';
@@ -0,0 +1,74 @@
1
+ /*********************
2
+ * Fade *
3
+ *********************/
4
+ @utility fade {
5
+ & {
6
+ --opacity: var(--closed-opacity, 0);
7
+ opacity: var(--opacity, 0);
8
+ }
9
+
10
+ &:where([open], :popover-open, .open, .show) {
11
+ --opacity: var(--opened-opacity, 1);
12
+
13
+ @starting-style {
14
+ --opacity: var(--opening-opacity, 0);
15
+ }
16
+ }
17
+ }
18
+
19
+ /*********************
20
+ * Fly *
21
+ *********************/
22
+ @utility fly {
23
+ & {
24
+ --tx: var(--closed-tx, 0);
25
+ --ty: var(--closed-ty, 0);
26
+ transform: translateX(var(--tx)) translateY(var(--ty));
27
+ }
28
+
29
+ &:where([open], :popover-open, .open, .show) {
30
+ --tx: var(--opened-tx, 0);
31
+ --ty: var(--opened-ty, 0);
32
+
33
+ @starting-style {
34
+ --tx: var(--opening-tx, 0);
35
+ --ty: var(--opening-ty, 0);
36
+ }
37
+ }
38
+ }
39
+
40
+ @utility fly-from-top {
41
+ & {
42
+ @apply fly;
43
+ --closed-ty: -100%;
44
+ --opened-ty: 0;
45
+ --opening-ty: -100%;
46
+ }
47
+ }
48
+
49
+ @utility fly-from-bottom {
50
+ & {
51
+ @apply fly;
52
+ --closed-ty: 100%;
53
+ --opened-ty: 0;
54
+ --opening-ty: 100%;
55
+ }
56
+ }
57
+
58
+ @utility fly-from-left {
59
+ & {
60
+ @apply fly;
61
+ --closed-tx: -100%;
62
+ --opened-tx: 0;
63
+ --opening-tx: -100%;
64
+ }
65
+ }
66
+
67
+ @utility fly-from-right {
68
+ & {
69
+ @apply fly;
70
+ --closed-tx: 100%;
71
+ --opened-tx: 0;
72
+ --opening-tx: 100%;
73
+ }
74
+ }
@@ -1,8 +1,9 @@
1
1
  @theme {
2
2
  /* Typography */
3
- --bg-color: white;
4
- --text-color: black;
3
+ --bg-color: var(--color-cdarkblue-900);
4
+ --text-color: var(--color-cneutral-100);
5
5
  --leading: 1.5;
6
+ --gap: 1lh;
6
7
 
7
8
  /* Padding */
8
9
  --padding: 1rem;
@@ -14,7 +15,7 @@
14
15
  --radius: 0.5rem;
15
16
 
16
17
  /* Outline */
17
- --outline-width: 3px;
18
+ --outline-width: 2px;
18
19
  --outline-style: solid;
19
20
  --outline-color: oklch(61.52% 0.178 257.59deg);
20
21
  --outline-offset: 0px;
@@ -1,8 +0,0 @@
1
- @layer components {
2
- .backdrop:where([data-state='blur']),
3
- .backdrop-blur {
4
- @apply transition-scaffold;
5
- transition-property: backdrop-filter;
6
- backdrop-filter: blur(var(--blur, 8px));
7
- }
8
- }
@@ -1,12 +0,0 @@
1
- /* Transfers outlines from the focusable element within to the container */
2
- @utility has-focus-within {
3
- &:focus-within {
4
- outline: var(--outline-width) var(--outline-style) transparent;
5
- outline-offset: var(--outline-offset);
6
- }
7
-
8
- *:focus,
9
- *:focus-visible {
10
- outline-color: transparent;
11
- }
12
- }
@@ -1,8 +0,0 @@
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
- }
@@ -1,14 +0,0 @@
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
- }
@@ -1,34 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- export * from './all.js'
2
- export * from './Masonry.js'
3
- export * from './Scrollable.js'
4
- export * from './Sticky.js'
File without changes