@n1kname/components 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/THIRD_PARTY.md +13 -0
- package/package.json +28 -3
- package/src/Button.astro +121 -0
- package/src/Cluster.astro +23 -0
- package/src/Columns.astro +42 -0
- package/src/DataTable.astro +187 -0
- package/src/Donut.astro +126 -0
- package/src/EmptyState.astro +55 -0
- package/src/Figure.astro +97 -0
- package/src/Grid.astro +31 -0
- package/src/Icon.astro +27 -0
- package/src/OutcomeTable.astro +136 -0
- package/src/PageHeader.astro +82 -0
- package/src/Quote.astro +87 -0
- package/src/RankedBars.astro +128 -0
- package/src/SidePanel.astro +140 -0
- package/src/Split.astro +43 -0
- package/src/Stack.astro +20 -0
- package/src/Stat.astro +58 -0
- package/src/StatStrip.astro +20 -0
- package/src/Tag.astro +86 -0
- package/src/Timeline.astro +134 -0
- package/src/datatable.js +43 -0
- package/src/icons.ts +69 -0
- package/src/type.css +29 -0
- package/README.md +0 -3
package/src/Figure.astro
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A chart or table with its title, actions and caption. `plate` sets it on a sunken
|
|
4
|
+
* field, for long reads; `card` sets it on a surface, for dashboards.
|
|
5
|
+
*/
|
|
6
|
+
interface Props {
|
|
7
|
+
title?: string;
|
|
8
|
+
sub?: string;
|
|
9
|
+
caption?: string;
|
|
10
|
+
variant?: 'plate' | 'card';
|
|
11
|
+
id?: string;
|
|
12
|
+
}
|
|
13
|
+
const { title, sub, caption, variant = 'plate', id } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<figure class="figure" id={id}>
|
|
17
|
+
<div class:list={['field', variant]}>
|
|
18
|
+
{
|
|
19
|
+
(title || Astro.slots.has('actions')) && (
|
|
20
|
+
<div class="head">
|
|
21
|
+
<div class="titles">
|
|
22
|
+
{title && <p class="title">{title}</p>}
|
|
23
|
+
{sub && <p class="sub">{sub}</p>}
|
|
24
|
+
</div>
|
|
25
|
+
<slot name="actions" />
|
|
26
|
+
</div>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
<slot />
|
|
30
|
+
</div>
|
|
31
|
+
{caption && <figcaption>{caption}</figcaption>}
|
|
32
|
+
</figure>
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.figure {
|
|
36
|
+
margin: 0;
|
|
37
|
+
min-width: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.field {
|
|
41
|
+
border: 1px solid var(--c-border);
|
|
42
|
+
border-radius: var(--radius-lg);
|
|
43
|
+
container-type: inline-size;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.plate {
|
|
47
|
+
background: var(--c-surface-sunken);
|
|
48
|
+
padding: var(--sp-6);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.card {
|
|
52
|
+
background: var(--c-surface);
|
|
53
|
+
padding: var(--sp-5);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@media (max-width: 560px) {
|
|
57
|
+
.plate {
|
|
58
|
+
padding: var(--sp-5);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.card {
|
|
62
|
+
padding: var(--sp-4);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.head {
|
|
67
|
+
display: flex;
|
|
68
|
+
justify-content: space-between;
|
|
69
|
+
align-items: flex-start;
|
|
70
|
+
gap: var(--sp-3);
|
|
71
|
+
margin-bottom: var(--sp-4);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.title {
|
|
75
|
+
margin: 0;
|
|
76
|
+
font-family: var(--font-display);
|
|
77
|
+
font-weight: 600;
|
|
78
|
+
font-size: var(--text-sub);
|
|
79
|
+
line-height: var(--leading-sub);
|
|
80
|
+
color: var(--c-text);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.sub {
|
|
84
|
+
margin: var(--sp-1) 0 0;
|
|
85
|
+
max-width: 68ch;
|
|
86
|
+
font-size: var(--text-caption);
|
|
87
|
+
line-height: var(--leading-caption);
|
|
88
|
+
color: var(--c-text-muted);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
figcaption {
|
|
92
|
+
margin-top: var(--sp-4);
|
|
93
|
+
font-size: var(--text-body-sm);
|
|
94
|
+
color: var(--c-text-muted);
|
|
95
|
+
max-width: var(--layout-measure);
|
|
96
|
+
}
|
|
97
|
+
</style>
|
package/src/Grid.astro
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Equal columns that wrap by the room they have, with no breakpoints. A child with
|
|
4
|
+
* class="span-all" takes the whole row, for the one thing that matters most.
|
|
5
|
+
*/
|
|
6
|
+
interface Props {
|
|
7
|
+
/** The narrowest a column can be, in px, before it wraps. */
|
|
8
|
+
min?: number;
|
|
9
|
+
gap?: number;
|
|
10
|
+
as?: string;
|
|
11
|
+
}
|
|
12
|
+
const { min = 280, gap = 4, as: Tag = 'div', class: className, ...rest } = Astro.props;
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<Tag class:list={['grid', className]} style={`--min: ${min}px; --gap: var(--sp-${gap})`} {...rest}><slot /></Tag>
|
|
16
|
+
|
|
17
|
+
<style>
|
|
18
|
+
.grid {
|
|
19
|
+
display: grid;
|
|
20
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--min)), 1fr));
|
|
21
|
+
gap: var(--gap);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.grid > :global(*) {
|
|
25
|
+
min-width: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.grid > :global(.span-all) {
|
|
29
|
+
grid-column: 1 / -1;
|
|
30
|
+
}
|
|
31
|
+
</style>
|
package/src/Icon.astro
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { ICONS, type IconName } from './icons';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
name: IconName;
|
|
6
|
+
size?: number;
|
|
7
|
+
stroke?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { name, size = 18, stroke } = Astro.props;
|
|
11
|
+
// Lucide is drawn at 24px with stroke 2. Below ~20px that reads heavy.
|
|
12
|
+
const strokeWidth = stroke ?? (size < 20 ? 1.75 : 2);
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<svg
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
width={size}
|
|
18
|
+
height={size}
|
|
19
|
+
viewBox="0 0 24 24"
|
|
20
|
+
fill="none"
|
|
21
|
+
stroke="currentColor"
|
|
22
|
+
stroke-width={strokeWidth}
|
|
23
|
+
stroke-linecap="round"
|
|
24
|
+
stroke-linejoin="round"
|
|
25
|
+
aria-hidden="true"
|
|
26
|
+
set:html={ICONS[name]}
|
|
27
|
+
/>
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Outcome table: dimension rows with an icon chip, outcome text, and an optional
|
|
4
|
+
* closing statement. Needs type.css for its t-label and t-sub classes.
|
|
5
|
+
*/
|
|
6
|
+
import Icon from './Icon.astro';
|
|
7
|
+
import type { IconName } from './icons';
|
|
8
|
+
|
|
9
|
+
interface Item {
|
|
10
|
+
icon: IconName;
|
|
11
|
+
dimension: string;
|
|
12
|
+
outcome: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
items: Item[];
|
|
17
|
+
closing?: string;
|
|
18
|
+
/** Column headings. */
|
|
19
|
+
headings?: [string, string];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { items, closing, headings = ['Dimension', 'The outcome'] } = Astro.props;
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
<div class="outcome">
|
|
26
|
+
<div class="head" aria-hidden="true">
|
|
27
|
+
<span class="t-label">{headings[0]}</span>
|
|
28
|
+
<span class="t-label">{headings[1]}</span>
|
|
29
|
+
</div>
|
|
30
|
+
<dl>
|
|
31
|
+
{
|
|
32
|
+
items.map((item) => (
|
|
33
|
+
<div class="row">
|
|
34
|
+
<dt class="t-sub">
|
|
35
|
+
<span class="chip">
|
|
36
|
+
<Icon name={item.icon} size={17} />
|
|
37
|
+
</span>
|
|
38
|
+
{item.dimension}
|
|
39
|
+
</dt>
|
|
40
|
+
<dd>{item.outcome}</dd>
|
|
41
|
+
</div>
|
|
42
|
+
))
|
|
43
|
+
}
|
|
44
|
+
</dl>
|
|
45
|
+
{closing && <p class="closing">{closing}</p>}
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
.outcome {
|
|
50
|
+
background: var(--c-surface);
|
|
51
|
+
border: 1px solid var(--c-border);
|
|
52
|
+
border-radius: var(--radius-lg);
|
|
53
|
+
padding: var(--sp-5) var(--sp-6);
|
|
54
|
+
margin-block: var(--sp-5) var(--sp-7);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.head,
|
|
58
|
+
.row {
|
|
59
|
+
display: grid;
|
|
60
|
+
grid-template-columns: 220px minmax(0, 1fr);
|
|
61
|
+
gap: var(--sp-6);
|
|
62
|
+
align-items: start;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.head {
|
|
66
|
+
padding-block: var(--sp-2) var(--sp-3);
|
|
67
|
+
border-bottom: 1px solid var(--c-border);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
dl {
|
|
71
|
+
margin: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.row {
|
|
75
|
+
padding-block: var(--sp-4);
|
|
76
|
+
border-bottom: 1px solid var(--c-border);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.row:last-child {
|
|
80
|
+
border-bottom: none;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
dt {
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
gap: var(--sp-3);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.chip {
|
|
90
|
+
display: grid;
|
|
91
|
+
place-items: center;
|
|
92
|
+
width: 34px;
|
|
93
|
+
height: 34px;
|
|
94
|
+
flex: none;
|
|
95
|
+
border-radius: var(--radius-full);
|
|
96
|
+
background: var(--c-surface-tint);
|
|
97
|
+
color: var(--c-text-accent);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
dd {
|
|
101
|
+
margin: 0;
|
|
102
|
+
max-width: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* A closing statement, not a call to action. A solid accent fill read as a
|
|
106
|
+
* button; the tint plus display type reads as a conclusion. Its contrast is
|
|
107
|
+
* asserted in check.mjs as "closing statement on tinted panel". */
|
|
108
|
+
.closing {
|
|
109
|
+
margin-block: var(--sp-5) var(--sp-2);
|
|
110
|
+
background: var(--c-surface-tint);
|
|
111
|
+
color: var(--c-text);
|
|
112
|
+
border-radius: var(--radius-md);
|
|
113
|
+
padding: var(--sp-5) var(--sp-6);
|
|
114
|
+
font-family: var(--font-display);
|
|
115
|
+
font-size: var(--text-h3);
|
|
116
|
+
line-height: var(--leading-h3);
|
|
117
|
+
letter-spacing: var(--tracking-h3);
|
|
118
|
+
max-width: none;
|
|
119
|
+
text-wrap: pretty;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@media (max-width: 640px) {
|
|
123
|
+
.outcome {
|
|
124
|
+
padding: var(--sp-4) var(--sp-5);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.head {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.row {
|
|
132
|
+
grid-template-columns: 1fr;
|
|
133
|
+
gap: var(--sp-2);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
</style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* The top of a page: what it is, what it says, and how fresh that is, with the page's
|
|
4
|
+
* actions beside it. Actions go in the "actions" slot.
|
|
5
|
+
*/
|
|
6
|
+
interface Props {
|
|
7
|
+
eyebrow?: string;
|
|
8
|
+
title: string;
|
|
9
|
+
lede?: string;
|
|
10
|
+
/** How fresh the data is. Say it plainly, such as "Through 31 Oct". */
|
|
11
|
+
meta?: string;
|
|
12
|
+
/** Ids, for a page that fills these in once its data arrives. */
|
|
13
|
+
ids?: { eyebrow?: string; title?: string; lede?: string; meta?: string };
|
|
14
|
+
}
|
|
15
|
+
const { eyebrow, title, lede, meta, ids = {} } = Astro.props;
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<header class="page-header">
|
|
19
|
+
<div class="text">
|
|
20
|
+
{(eyebrow || ids.eyebrow) && <p class="eyebrow" id={ids.eyebrow}>{eyebrow}</p>}
|
|
21
|
+
<h1 id={ids.title}>{title}</h1>
|
|
22
|
+
{(lede || ids.lede) && <p class="lede" id={ids.lede}>{lede}</p>}
|
|
23
|
+
{(meta || ids.meta) && <p class="meta t-meta" id={ids.meta}>{meta}</p>}
|
|
24
|
+
</div>
|
|
25
|
+
{Astro.slots.has('actions') && <div class="actions"><slot name="actions" /></div>}
|
|
26
|
+
</header>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
.page-header {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-wrap: wrap;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
gap: var(--sp-4) var(--sp-6);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.text {
|
|
38
|
+
flex: 1 1 420px;
|
|
39
|
+
min-width: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.eyebrow {
|
|
43
|
+
margin: 0 0 var(--sp-1);
|
|
44
|
+
font-size: var(--text-label);
|
|
45
|
+
font-weight: 600;
|
|
46
|
+
color: var(--c-text-accent);
|
|
47
|
+
min-height: 1lh;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
h1 {
|
|
51
|
+
margin: 0;
|
|
52
|
+
max-width: 32ch;
|
|
53
|
+
font-family: var(--font-display);
|
|
54
|
+
font-weight: 600;
|
|
55
|
+
font-size: var(--text-h2);
|
|
56
|
+
line-height: var(--leading-h2);
|
|
57
|
+
letter-spacing: var(--tracking-h2);
|
|
58
|
+
text-wrap: balance;
|
|
59
|
+
/* Keeps its height while a page waits for data. */
|
|
60
|
+
min-height: 1lh;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.lede {
|
|
64
|
+
margin: var(--sp-2) 0 0;
|
|
65
|
+
max-width: 62ch;
|
|
66
|
+
font-size: var(--text-body-sm);
|
|
67
|
+
line-height: var(--leading-body-sm);
|
|
68
|
+
color: var(--c-text-secondary);
|
|
69
|
+
min-height: 2lh;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.meta {
|
|
73
|
+
margin: var(--sp-2) 0 0;
|
|
74
|
+
min-height: 1lh;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.actions {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-wrap: wrap;
|
|
80
|
+
gap: var(--sp-2);
|
|
81
|
+
}
|
|
82
|
+
</style>
|
package/src/Quote.astro
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A research quote in its own panel. The mark does the job an avatar would, which
|
|
4
|
+
* is to say "someone said this", and it needs no artwork.
|
|
5
|
+
*
|
|
6
|
+
* Quotes are evidence, so the attribution is required. A quote with no source
|
|
7
|
+
* is decoration.
|
|
8
|
+
*/
|
|
9
|
+
import Icon from './Icon.astro';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
/** Who said it, and in what setting. */
|
|
13
|
+
from: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { from } = Astro.props;
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
<figure class="quote">
|
|
20
|
+
<span class="mark" aria-hidden="true">
|
|
21
|
+
<Icon name="quote" size={18} />
|
|
22
|
+
</span>
|
|
23
|
+
<div>
|
|
24
|
+
<blockquote>
|
|
25
|
+
<slot />
|
|
26
|
+
</blockquote>
|
|
27
|
+
<figcaption>{from}</figcaption>
|
|
28
|
+
</div>
|
|
29
|
+
</figure>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.quote {
|
|
33
|
+
display: grid;
|
|
34
|
+
grid-template-columns: 40px minmax(0, 1fr);
|
|
35
|
+
gap: var(--sp-5);
|
|
36
|
+
align-items: start;
|
|
37
|
+
margin-block: var(--sp-6) var(--sp-7);
|
|
38
|
+
padding: var(--sp-6);
|
|
39
|
+
background: var(--c-surface);
|
|
40
|
+
border: 1px solid var(--c-border);
|
|
41
|
+
border-radius: var(--radius-lg);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.mark {
|
|
45
|
+
display: grid;
|
|
46
|
+
place-items: center;
|
|
47
|
+
width: 40px;
|
|
48
|
+
height: 40px;
|
|
49
|
+
border-radius: var(--radius-full);
|
|
50
|
+
background: var(--c-surface-tint);
|
|
51
|
+
color: var(--c-text-accent);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
blockquote {
|
|
55
|
+
margin: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Italic display. The panel does the framing, so no rule and no oversized
|
|
59
|
+
punctuation are needed. */
|
|
60
|
+
/* No measure cap: the panel already constrains the line, and capping again
|
|
61
|
+
* left the text in a narrow column inside a wide box. */
|
|
62
|
+
blockquote :global(p) {
|
|
63
|
+
font-family: var(--font-display);
|
|
64
|
+
font-style: italic;
|
|
65
|
+
font-weight: 400;
|
|
66
|
+
font-size: var(--text-h3);
|
|
67
|
+
line-height: 1.45;
|
|
68
|
+
max-width: none;
|
|
69
|
+
margin: 0;
|
|
70
|
+
text-wrap: pretty;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
figcaption {
|
|
74
|
+
margin-top: var(--sp-4);
|
|
75
|
+
font-size: var(--text-body-sm);
|
|
76
|
+
line-height: var(--leading-body-sm);
|
|
77
|
+
color: var(--c-text-muted);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@media (max-width: 560px) {
|
|
81
|
+
.quote {
|
|
82
|
+
grid-template-columns: 1fr;
|
|
83
|
+
gap: var(--sp-4);
|
|
84
|
+
padding: var(--sp-5);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
</style>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Ranked bars in plain HTML and CSS, so the labels are real text. Safari lays out
|
|
4
|
+
* SVG text with the fallback font's widths and then paints the web font, so
|
|
5
|
+
* right-aligned SVG labels come out uneven and run into the bars. No script reaches
|
|
6
|
+
* the browser, and the data stays in this page's HTML. Rows keep the order given.
|
|
7
|
+
* `alt` speaks for the chart, and needs every value.
|
|
8
|
+
*/
|
|
9
|
+
import Figure from './Figure.astro';
|
|
10
|
+
|
|
11
|
+
interface Row {
|
|
12
|
+
label: string;
|
|
13
|
+
value: number;
|
|
14
|
+
valueLabel?: string;
|
|
15
|
+
/** A token, such as var(--c-chart-1). Without one, the de-emphasis tone. */
|
|
16
|
+
color?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
data: Row[];
|
|
21
|
+
title?: string;
|
|
22
|
+
alt: string;
|
|
23
|
+
caption?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { data, title, alt, caption } = Astro.props;
|
|
27
|
+
const max = Math.max(...data.map((d) => d.value));
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
<Figure title={title} caption={caption}>
|
|
31
|
+
<div class="ranked-bars" role="img" aria-label={alt}>
|
|
32
|
+
<ul aria-hidden="true">
|
|
33
|
+
{
|
|
34
|
+
data.map((d) => (
|
|
35
|
+
<li>
|
|
36
|
+
<span class="label">{d.label}</span>
|
|
37
|
+
<span class="track">
|
|
38
|
+
<i style={`--share: ${d.value / max}; background: ${d.color ?? 'var(--c-chart-neutral)'}`} />
|
|
39
|
+
<span class="value">{d.valueLabel ?? d.value}</span>
|
|
40
|
+
</span>
|
|
41
|
+
</li>
|
|
42
|
+
))
|
|
43
|
+
}
|
|
44
|
+
</ul>
|
|
45
|
+
</div>
|
|
46
|
+
</Figure>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
.ranked-bars {
|
|
50
|
+
min-width: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
ul {
|
|
54
|
+
display: grid;
|
|
55
|
+
grid-template-columns: max-content minmax(0, 1fr);
|
|
56
|
+
list-style: none;
|
|
57
|
+
margin: 0;
|
|
58
|
+
padding: 0;
|
|
59
|
+
font-size: var(--text-label);
|
|
60
|
+
line-height: var(--leading-label);
|
|
61
|
+
color: var(--c-text);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
li {
|
|
65
|
+
display: contents;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.label {
|
|
69
|
+
padding-right: var(--sp-3);
|
|
70
|
+
align-self: center;
|
|
71
|
+
text-align: end;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.track {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: var(--sp-2);
|
|
78
|
+
padding-block: 6px;
|
|
79
|
+
border-left: 1px solid var(--c-chart-axis);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* The room left for the value is what keeps the longest bar and its number inside. */
|
|
83
|
+
i {
|
|
84
|
+
display: block;
|
|
85
|
+
flex: none;
|
|
86
|
+
width: calc(var(--share) * (100% - 3.5rem));
|
|
87
|
+
height: 22px;
|
|
88
|
+
border-radius: 0 4px 4px 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.value {
|
|
92
|
+
font-family: var(--font-mono);
|
|
93
|
+
font-variant-numeric: tabular-nums;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@container (max-width: 560px) {
|
|
97
|
+
ul {
|
|
98
|
+
display: block;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
li {
|
|
102
|
+
display: block;
|
|
103
|
+
margin-bottom: var(--sp-3);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.label {
|
|
107
|
+
display: block;
|
|
108
|
+
padding: 0 0 var(--sp-1);
|
|
109
|
+
text-align: start;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.track {
|
|
113
|
+
padding-block: 0;
|
|
114
|
+
border-left: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
i {
|
|
118
|
+
border-radius: 4px;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@media (forced-colors: active) {
|
|
123
|
+
i {
|
|
124
|
+
background: CanvasText !important;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
</style>
|