@n1kname/components 0.32.0 → 0.33.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": "@n1kname/components",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
package/src/Button.astro CHANGED
@@ -51,7 +51,6 @@ const attrs = href ? { href } : { type, disabled, 'aria-pressed': selected === u
51
51
  --spot: rgb(255 255 255 / 0.32);
52
52
  position: relative;
53
53
  isolation: isolate;
54
- overflow: hidden;
55
54
  display: inline-flex;
56
55
  align-items: center;
57
56
  justify-content: center;
@@ -80,6 +79,8 @@ const attrs = href ? { href } : { type, disabled, 'aria-pressed': selected === u
80
79
  position: absolute;
81
80
  inset: 0;
82
81
  z-index: -1;
82
+ /* Rounded with the button instead of clipped by it: overflow: hidden would let a flex row squeeze the button below its label. */
83
+ border-radius: inherit;
83
84
  opacity: 0;
84
85
  background: radial-gradient(120px circle at var(--x) var(--y), var(--spot), transparent 60%);
85
86
  transition: opacity 200ms var(--ease-out);
package/src/Streaks.astro CHANGED
@@ -8,12 +8,18 @@
8
8
  * whisper barely there
9
9
  * subtle atmosphere that never competes with the type (default)
10
10
  * present closer to a motion background; for a dark band, not behind body text
11
+ *
12
+ * `fixed` fills the window instead and stays put while the page scrolls past, drifting up a
13
+ * little slower than the text where the browser can tie it to the scroll. It isolates the body,
14
+ * so it sits on the page colour and under everything else; it needs no positioned parent.
11
15
  */
12
16
  interface Props {
13
17
  strength?: 'whisper' | 'subtle' | 'present';
18
+ /** Fill the window behind the whole page, fixed, drifting with the scroll. */
19
+ fixed?: boolean;
14
20
  class?: string;
15
21
  }
16
- const { strength = 'subtle', class: className } = Astro.props;
22
+ const { strength = 'subtle', fixed = false, class: className } = Astro.props;
17
23
  const streaks = [
18
24
  { c: 'var(--c-accent)', top: 18, h: 3, w: 52, d: 34, delay: -4, still: 10, blur: 5 },
19
25
  { c: 'var(--c-chart-2)', top: 30, h: 8, w: 40, d: 46, delay: -20, still: 60, blur: 10 },
@@ -24,7 +30,7 @@ const streaks = [
24
30
  ];
25
31
  ---
26
32
 
27
- <div class:list={['streaks', strength, className]} aria-hidden="true">
33
+ <div class:list={['streaks', strength, { fixed }, className]} aria-hidden="true">
28
34
  <div class="field">
29
35
  {streaks.map((s) => (
30
36
  <i style={`top:${s.top}%;--c:${s.c};--h:${s.h}px;--w:${s.w}%;--d:${s.d}s;--delay:${s.delay}s;--still:${s.still}%;--blur:${s.blur}px`} />
@@ -43,6 +49,17 @@ const streaks = [
43
49
  mask-image: radial-gradient(ellipse 80% 90% at 50% 45%, #000 45%, transparent 100%);
44
50
  }
45
51
 
52
+ /* The window, not a section: fixed behind the whole page. The body becomes its own stacking
53
+ * context, so the streaks paint on its background and under everything in it. */
54
+ .fixed {
55
+ position: fixed;
56
+ mask-image: radial-gradient(ellipse 110% 100% at 50% 35%, #000 35%, transparent 100%);
57
+ }
58
+
59
+ :global(body:has(.streaks.fixed)) {
60
+ isolation: isolate;
61
+ }
62
+
46
63
  .field {
47
64
  position: absolute;
48
65
  inset: -20% -10%;
@@ -82,6 +99,27 @@ const streaks = [
82
99
  to { transform: translateX(260%); }
83
100
  }
84
101
 
102
+ /* Fixed, they drift up a little slower than the page scrolls. */
103
+ @media (prefers-reduced-motion: no-preference) {
104
+ @supports (animation-timeline: scroll()) {
105
+ .fixed .field {
106
+ animation: streaks-scroll linear both;
107
+ }
108
+
109
+ /* A rule of its own, more specific: a minifier folds the timeline into the shorthand above,
110
+ * which browsers then drop whole. */
111
+ .streaks.fixed > .field {
112
+ animation-timeline: scroll(root);
113
+ }
114
+ }
115
+ }
116
+
117
+ @keyframes streaks-scroll {
118
+ to {
119
+ transform: rotate(-22deg) translateY(-22%);
120
+ }
121
+ }
122
+
85
123
  @media (prefers-reduced-motion: reduce) {
86
124
  i {
87
125
  animation: none;