@rxova/astro-ui 0.5.1 → 0.6.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 +2 -2
- package/src/components/CopyButton.astro +107 -0
- package/src/components/PageHeader.astro +1 -1
- package/src/components/QuickStart.astro +8 -57
- package/src/components/ScreenshotGrid.astro +11 -0
- package/src/components/SiteFooter.astro +2 -2
- package/src/components/icons/Check.astro +11 -0
- package/src/components/icons/Copy.astro +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxova/astro-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Astro components, Starlight preset and shared chrome for rxova.org",
|
|
6
6
|
"keywords": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@rxova/brand": "^1.
|
|
49
|
+
"@rxova/brand": "^1.3.0",
|
|
50
50
|
"lucide-static": "^1.45.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* An icon button that puts `text` on the clipboard and shows a tick for a moment. Drawn in
|
|
4
|
+
* `currentColor`, so it sits on any surface, a dark terminal included; the caller places it.
|
|
5
|
+
*/
|
|
6
|
+
import Check from './icons/Check.astro'
|
|
7
|
+
import Copy from './icons/Copy.astro'
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
/** What goes on the clipboard. */
|
|
11
|
+
text: string
|
|
12
|
+
/** The accessible name and tooltip; there is no visible text, so this is what a screen reader says. */
|
|
13
|
+
label?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { text, label = 'Copy' } = Astro.props
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
<button class="rx-copy" type="button" data-rx-copy={text} aria-label={label} title={label}>
|
|
20
|
+
<Copy class="rx-copy__idle" />
|
|
21
|
+
<Check class="rx-copy__done" />
|
|
22
|
+
<span class="rx-copy__status" role="status"></span>
|
|
23
|
+
</button>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
for (const button of document.querySelectorAll<HTMLButtonElement>('[data-rx-copy]')) {
|
|
27
|
+
if (button.dataset.rxCopyBound) continue
|
|
28
|
+
button.dataset.rxCopyBound = ''
|
|
29
|
+
const status = button.querySelector<HTMLElement>('.rx-copy__status')
|
|
30
|
+
button.addEventListener('click', async () => {
|
|
31
|
+
try {
|
|
32
|
+
await navigator.clipboard.writeText(button.dataset.rxCopy ?? '')
|
|
33
|
+
} catch {
|
|
34
|
+
// Clipboard access can be denied; saying nothing beats claiming a copy that did not happen.
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
button.dataset.state = 'done'
|
|
38
|
+
if (status) status.textContent = 'Copied'
|
|
39
|
+
window.setTimeout(() => {
|
|
40
|
+
delete button.dataset.state
|
|
41
|
+
if (status) status.textContent = ''
|
|
42
|
+
}, 1600)
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<style>
|
|
48
|
+
/* One glyph over the other, so the button keeps its size when the state flips. */
|
|
49
|
+
.rx-copy {
|
|
50
|
+
position: relative;
|
|
51
|
+
display: grid;
|
|
52
|
+
place-items: center;
|
|
53
|
+
flex: none;
|
|
54
|
+
width: 2rem;
|
|
55
|
+
height: 2rem;
|
|
56
|
+
padding: 0;
|
|
57
|
+
color: inherit;
|
|
58
|
+
background: transparent;
|
|
59
|
+
border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
|
|
60
|
+
border-radius: var(--rx-radius-sm);
|
|
61
|
+
opacity: 0.85;
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
transition:
|
|
64
|
+
border-color 0.15s ease,
|
|
65
|
+
opacity 0.15s ease;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.rx-copy:hover {
|
|
69
|
+
opacity: 1;
|
|
70
|
+
border-color: color-mix(in srgb, currentColor 65%, transparent);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.rx-copy:focus-visible {
|
|
74
|
+
outline: 2px solid currentColor;
|
|
75
|
+
outline-offset: 2px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.rx-copy :global(.rx-copy__idle),
|
|
79
|
+
.rx-copy :global(.rx-copy__done) {
|
|
80
|
+
grid-area: 1 / 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.rx-copy :global(.rx-copy__done),
|
|
84
|
+
.rx-copy[data-state='done'] :global(.rx-copy__idle) {
|
|
85
|
+
visibility: hidden;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.rx-copy[data-state='done'] :global(.rx-copy__done) {
|
|
89
|
+
visibility: visible;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Announced to screen readers, never shown: the tick is the visible cue. */
|
|
93
|
+
.rx-copy__status {
|
|
94
|
+
position: absolute;
|
|
95
|
+
width: 1px;
|
|
96
|
+
height: 1px;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
clip-path: inset(50%);
|
|
99
|
+
white-space: nowrap;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@media (prefers-reduced-motion: reduce) {
|
|
103
|
+
.rx-copy {
|
|
104
|
+
transition: none;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
</style>
|
|
@@ -40,7 +40,7 @@ const { title, back, variant = 'index', measure = 'wide' } = Astro.props
|
|
|
40
40
|
letter-spacing: -0.02em;
|
|
41
41
|
margin-bottom: 0.6rem;
|
|
42
42
|
}
|
|
43
|
-
/* One title across /
|
|
43
|
+
/* One title across /projects, /blog and /updates, so switching pages does not move it. */
|
|
44
44
|
.index h1 {
|
|
45
45
|
line-height: 1.15;
|
|
46
46
|
font-weight: 650;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
/**
|
|
3
|
-
* An install command with a
|
|
3
|
+
* An install command with a `CopyButton` beside a "Use" pane. The snippet arrives through the slot,
|
|
4
4
|
* so a page can write a fenced block and get the same Shiki highlighting as the docs.
|
|
5
5
|
*/
|
|
6
|
+
import CopyButton from './CopyButton.astro'
|
|
7
|
+
|
|
6
8
|
interface Props {
|
|
7
9
|
command: string
|
|
8
10
|
}
|
|
@@ -21,12 +23,7 @@ const { command } = Astro.props
|
|
|
21
23
|
</span>
|
|
22
24
|
{command}
|
|
23
25
|
</code>
|
|
24
|
-
<
|
|
25
|
-
<span class="rx-qs__copy-idle">Copy</span>
|
|
26
|
-
<span class="rx-qs__copy-done" aria-hidden="true">
|
|
27
|
-
Copied
|
|
28
|
-
</span>
|
|
29
|
-
</button>
|
|
26
|
+
<CopyButton text={command} label="Copy the install command" />
|
|
30
27
|
</div>
|
|
31
28
|
</div>
|
|
32
29
|
|
|
@@ -38,21 +35,6 @@ const { command } = Astro.props
|
|
|
38
35
|
</div>
|
|
39
36
|
</div>
|
|
40
37
|
|
|
41
|
-
<script>
|
|
42
|
-
for (const button of document.querySelectorAll<HTMLButtonElement>('.rx-qs__copy')) {
|
|
43
|
-
button.addEventListener('click', async () => {
|
|
44
|
-
try {
|
|
45
|
-
await navigator.clipboard.writeText(button.dataset.copy ?? '')
|
|
46
|
-
} catch {
|
|
47
|
-
// Clipboard access can be denied; saying nothing beats claiming a copy that did not happen.
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
button.dataset.state = 'done'
|
|
51
|
-
window.setTimeout(() => delete button.dataset.state, 1600)
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
</script>
|
|
55
|
-
|
|
56
38
|
<style>
|
|
57
39
|
.rx-qs {
|
|
58
40
|
display: grid;
|
|
@@ -77,6 +59,10 @@ const { command } = Astro.props
|
|
|
77
59
|
}
|
|
78
60
|
|
|
79
61
|
/* Not `flex: 1`: a one-line command stretched to the snippet's height floats in an empty box. */
|
|
62
|
+
.rx-qs__term :global(.rx-copy) {
|
|
63
|
+
color: var(--rx-muted);
|
|
64
|
+
}
|
|
65
|
+
|
|
80
66
|
.rx-qs__term {
|
|
81
67
|
display: flex;
|
|
82
68
|
align-items: center;
|
|
@@ -103,41 +89,6 @@ const { command } = Astro.props
|
|
|
103
89
|
user-select: none;
|
|
104
90
|
}
|
|
105
91
|
|
|
106
|
-
/* One label over the other, so the button keeps its size when the state flips. */
|
|
107
|
-
.rx-qs__copy {
|
|
108
|
-
display: grid;
|
|
109
|
-
flex: none;
|
|
110
|
-
padding: 0.4rem 0.85rem;
|
|
111
|
-
color: var(--rx-muted);
|
|
112
|
-
background: var(--rx-bg);
|
|
113
|
-
border: 1px solid var(--rx-rule-strong);
|
|
114
|
-
border-radius: var(--rx-radius-pill);
|
|
115
|
-
font: inherit;
|
|
116
|
-
font-size: 0.78rem;
|
|
117
|
-
font-weight: 500;
|
|
118
|
-
cursor: pointer;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.rx-qs__copy:hover {
|
|
122
|
-
color: var(--rx-fg);
|
|
123
|
-
border-color: var(--rx-primary);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.rx-qs__copy-idle,
|
|
127
|
-
.rx-qs__copy-done {
|
|
128
|
-
grid-area: 1 / 1;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.rx-qs__copy-done,
|
|
132
|
-
.rx-qs__copy[data-state='done'] .rx-qs__copy-idle {
|
|
133
|
-
visibility: hidden;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.rx-qs__copy[data-state='done'] .rx-qs__copy-done {
|
|
137
|
-
visibility: visible;
|
|
138
|
-
color: var(--rx-primary);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
92
|
.rx-qs__code {
|
|
142
93
|
flex: 1;
|
|
143
94
|
}
|
|
@@ -106,6 +106,17 @@ const { shots, link } = Astro.props
|
|
|
106
106
|
height: auto;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/* A light capture is the brightest thing on a dark page; dimmed, it sits on the surface instead of glaring. */
|
|
110
|
+
@media (prefers-color-scheme: dark) {
|
|
111
|
+
:global(html:not([data-theme='light'])) .rx-shots__frame :global(img) {
|
|
112
|
+
filter: brightness(0.8);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:global(html[data-theme='dark']) .rx-shots__frame :global(img) {
|
|
117
|
+
filter: brightness(0.8);
|
|
118
|
+
}
|
|
119
|
+
|
|
109
120
|
/* Index beside the label, detail hanging under the label; the indent binds the pair. */
|
|
110
121
|
.rx-shots__caption {
|
|
111
122
|
display: grid;
|
|
@@ -19,7 +19,7 @@ interface Props {
|
|
|
19
19
|
docs?: { label: string; href: string }[]
|
|
20
20
|
/**
|
|
21
21
|
* Standalone surfaces listed under "Site", below Home. Only the umbrella repo knows which are
|
|
22
|
-
* deployed; the default (for docs sites)
|
|
22
|
+
* deployed; the default (for docs sites) is `SECTIONS`: Projects, Blog and Updates.
|
|
23
23
|
*/
|
|
24
24
|
site?: readonly SiteLink[]
|
|
25
25
|
/**
|
|
@@ -131,7 +131,7 @@ const surfaces: readonly SiteLink[] =
|
|
|
131
131
|
<a href="https://www.npmjs.com/org/rxova">npm</a>
|
|
132
132
|
</li>
|
|
133
133
|
<li>
|
|
134
|
-
<a href="mailto:rxova
|
|
134
|
+
<a href="mailto:jonatan@rxova.org">jonatan@rxova.org</a>
|
|
135
135
|
</li>
|
|
136
136
|
</ul>
|
|
137
137
|
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ComponentProps } from 'astro/types'
|
|
3
|
+
import Icon from '../Icon.astro'
|
|
4
|
+
|
|
5
|
+
/** A tick: done. */
|
|
6
|
+
type Props = Omit<ComponentProps<typeof Icon>, 'solid'>
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<Icon {...Astro.props}>
|
|
10
|
+
<path d="m3.2 8.4 3 3 6.6-6.8"></path>
|
|
11
|
+
</Icon>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ComponentProps } from 'astro/types'
|
|
3
|
+
import Icon from '../Icon.astro'
|
|
4
|
+
|
|
5
|
+
/** Two overlapping sheets: the front one is what goes on the clipboard. */
|
|
6
|
+
type Props = Omit<ComponentProps<typeof Icon>, 'solid'>
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<Icon {...Astro.props}>
|
|
10
|
+
<rect x="5.5" y="5.5" width="8" height="8" rx="1.6"></rect>
|
|
11
|
+
<path d="M10.5 3A1.5 1.5 0 0 0 9 1.5H3A1.5 1.5 0 0 0 1.5 3v6A1.5 1.5 0 0 0 3 10.5"></path>
|
|
12
|
+
</Icon>
|