@n1kname/components 0.67.4 → 0.68.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": "@n1kname/components",
3
- "version": "0.67.4",
3
+ "version": "0.68.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -3,11 +3,15 @@
3
3
  * The top of a page: what it is, what it says, and how fresh that is, with the page's
4
4
  * actions beside it. Actions go in the "actions" slot.
5
5
  *
6
- * `rule` puts the house signature, a short accent bar, under the title. `mark` names the
7
- * words that answer the question, such as "6,5% lower": the first place they appear, in the
8
- * title or else the lede, gets a highlighter that sweeps in once. A page that writes its title
9
- * or lede once its data arrives wraps those words in <mark> itself; the sweep plays as they
10
- * land.
6
+ * For a page that answers a question, the question is the title (the `h1` names the page) and
7
+ * `answer` follows it, a step smaller, in the same family: "Less.", or "The living room costs the
8
+ * most". No label over the title: a heading names its own section.
9
+ *
10
+ * `rule` puts the house signature, a short accent bar, under the title (and answer). `mark`
11
+ * names the words that answer the question, such as "6,5% lower": the first place they appear,
12
+ * in the title, the answer or else the lede, gets a highlighter, already there: a page that
13
+ * answers a question is a working page, and those stay still. A page that writes its title or
14
+ * lede once its data arrives wraps those words in <mark> itself.
11
15
  *
12
16
  * `compact` is the header made small enough to float over a map (MapStage fill mode): the title
13
17
  * at the h3 size, a shorter rule, and the actions beside it in one row while there is room.
@@ -15,13 +19,14 @@
15
19
  import './highlight.css';
16
20
 
17
21
  interface Props {
18
- eyebrow?: string;
19
22
  title: string;
23
+ /** The answer to the question in the title, under it, a step smaller. */
24
+ answer?: string;
20
25
  lede?: string;
21
26
  /** How fresh the data is. Say it plainly, such as "Through 31 Oct". */
22
27
  meta?: string;
23
28
  /** Ids, for a page that fills these in once its data arrives. */
24
- ids?: { eyebrow?: string; title?: string; lede?: string; meta?: string };
29
+ ids?: { title?: string; answer?: string; lede?: string; meta?: string };
25
30
  /** The short accent bar under the title. */
26
31
  rule?: boolean;
27
32
  /** Words in the title or lede to highlight. */
@@ -29,7 +34,7 @@ interface Props {
29
34
  /** Small enough to float over a map. */
30
35
  compact?: boolean;
31
36
  }
32
- const { eyebrow, title, lede, meta, ids = {}, rule = false, mark, compact = false } = Astro.props;
37
+ const { title, answer, lede, meta, ids = {}, rule = false, mark, compact = false } = Astro.props;
33
38
 
34
39
  // The text around the marked words, or the text alone when they aren't in it.
35
40
  const split = (text?: string) => {
@@ -37,13 +42,14 @@ const split = (text?: string) => {
37
42
  return at < 0 ? null : [text!.slice(0, at), mark, text!.slice(at + mark!.length)];
38
43
  };
39
44
  const inTitle = split(title);
40
- const inLede = inTitle ? null : split(lede);
45
+ const inAnswer = inTitle ? null : split(answer);
46
+ const inLede = inTitle || inAnswer ? null : split(lede);
41
47
  ---
42
48
 
43
49
  <header class:list={['page-header', { compact }]}>
44
50
  <div class="text">
45
- {(eyebrow || ids.eyebrow) && <p class="eyebrow" id={ids.eyebrow}>{eyebrow}</p>}
46
51
  <h1 id={ids.title}>{inTitle ? <>{inTitle[0]}<mark>{inTitle[1]}</mark>{inTitle[2]}</> : title}</h1>
52
+ {(answer || ids.answer) && <p class="answer" id={ids.answer}>{inAnswer ? <>{inAnswer[0]}<mark>{inAnswer[1]}</mark>{inAnswer[2]}</> : answer}</p>}
47
53
  {rule && <span class="rule" aria-hidden="true" />}
48
54
  {(lede || ids.lede) && <p class="lede" id={ids.lede}>{inLede ? <>{inLede[0]}<mark>{inLede[1]}</mark>{inLede[2]}</> : lede}</p>}
49
55
  {(meta || ids.meta) && <p class="meta t-meta" id={ids.meta}>{meta}</p>}
@@ -65,14 +71,6 @@ const inLede = inTitle ? null : split(lede);
65
71
  min-width: 0;
66
72
  }
67
73
 
68
- .eyebrow {
69
- margin: 0 0 var(--sp-1);
70
- font-size: var(--text-label);
71
- font-weight: 600;
72
- color: var(--c-text-accent);
73
- min-height: 1lh;
74
- }
75
-
76
74
  h1 {
77
75
  margin: 0;
78
76
  max-width: 32ch;
@@ -86,6 +84,20 @@ const inLede = inTitle ? null : split(lede);
86
84
  min-height: 1lh;
87
85
  }
88
86
 
87
+ /* The answer: the headline family a step down, in the text colour. */
88
+ .answer {
89
+ margin: var(--sp-2) 0 0;
90
+ max-width: 36ch;
91
+ font-family: var(--font-display);
92
+ font-weight: 600;
93
+ font-size: var(--text-h3);
94
+ line-height: var(--leading-h3);
95
+ letter-spacing: var(--tracking-h3);
96
+ color: var(--c-text);
97
+ text-wrap: balance;
98
+ min-height: 1lh;
99
+ }
100
+
89
101
  .lede {
90
102
  margin: var(--sp-2) 0 0;
91
103
  max-width: 62ch;
@@ -147,6 +159,12 @@ const inLede = inTitle ? null : split(lede);
147
159
  letter-spacing: var(--tracking-h3);
148
160
  }
149
161
 
162
+ .compact .answer {
163
+ font-size: var(--text-sub);
164
+ line-height: var(--leading-sub);
165
+ letter-spacing: normal;
166
+ }
167
+
150
168
  .compact .rule {
151
169
  width: var(--sp-6);
152
170
  height: 4px;
package/src/highlight.css CHANGED
@@ -2,6 +2,8 @@
2
2
  * The highlighter: a band behind the words a page is about. It sits low, like a pen, wraps line
3
3
  * by line, and is mixed into the page colour rather than see-through, so it holds up in dark. It
4
4
  * sweeps in once, a moment after the words land; several marks go one after the other, by --n.
5
+ * In a page header it is simply there: a page that answers a question is a working page, and
6
+ * those stay still.
5
7
  *
6
8
  * `mark.highlight.glow` is the quiet look: a soft blue light behind the words that fades in once
7
9
  * and then holds still. It reaches past the line, so it never stops in a hard edge.
@@ -9,8 +11,9 @@
9
11
  * `mark.highlight.spotlight` passes a slanted band of blue light through the letters once, then
10
12
  * rests as plain text. It needs `--chars` (Highlight sets it) to keep one speed.
11
13
  *
12
- * Used by Highlight and PageHeader. A page that writes its words once its data arrives can wrap
13
- * them in <mark class="highlight"> itself, and the sweep plays as they land.
14
+ * Used by Highlight, Facts and PageHeader. A page that writes its words once its data arrives can
15
+ * wrap them in <mark class="highlight"> itself, and the sweep plays as they land; in a page
16
+ * header, a plain <mark> takes the band without the sweep.
14
17
  *
15
18
  * --highlight the band colour
16
19
  * --highlight-band its height
@@ -29,7 +32,7 @@
29
32
  }
30
33
 
31
34
  @media (prefers-reduced-motion: no-preference) {
32
- :where(mark.highlight, .page-header .text mark) {
35
+ :where(mark.highlight:not(.page-header .text mark)) {
33
36
  animation: highlight calc(var(--motion-draw, 1000ms) * 0.7) var(--ease-out)
34
37
  calc(var(--highlight-delay, 300ms) + var(--n, 0) * var(--highlight-step, 450ms)) both;
35
38
  }