@metacensus/library-ui 0.18.0 → 0.20.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/README.md +4 -4
- package/dist/site/links.js +7 -5
- package/dist/site/links.js.map +1 -1
- package/dist/tools/CiteThisPage.d.ts +8 -6
- package/dist/tools/CiteThisPage.js +10 -5
- package/dist/tools/CiteThisPage.js.map +1 -1
- package/dist/tools/Float.d.ts +11 -0
- package/dist/tools/Float.js +34 -0
- package/dist/tools/Float.js.map +1 -0
- package/dist/tools/display.js +6 -25
- package/dist/tools/display.js.map +1 -1
- package/package.json +1 -1
- package/src/chrome/Footer.astro +5 -2
- package/src/css/styles.css +50 -31
- package/src/css/tokens.css +1 -1
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ import { Header, Nav, Button, displayScript } from '@metacensus/library-ui'
|
|
|
60
60
|
<Button variant="danger">Delete account</Button>
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
`CiteThisPage` takes a `citation` (`title`, `authors` as `Family, Given`, an ISO `date`, `publisher` and `url`) plus `risHref` and `bibHref`, and renders a `Cite this page`
|
|
63
|
+
`CiteThisPage` takes a `citation` (`title`, `authors` as `Family, Given`, an ISO `date`, `publisher` and `url`) plus `risHref` and `bibHref`, and renders a round `Cite this page` button fixed at the viewport's left edge, vertically centred, like `DisplayControls` at the bottom-left. Hover, focus or a tap opens a panel beside it with the citation as text and a download link to each file. Render it once per page, from the layout, and hydrate it alone (`client:load`); it renders nothing when `citation.url` is empty. The page owns the URL and its permanence. The formatters are pure functions: a page writes the two files at build and links to them.
|
|
64
64
|
|
|
65
65
|
```astro
|
|
66
66
|
---
|
|
@@ -68,7 +68,7 @@ import { Header, Nav, Button, displayScript } from '@metacensus/library-ui'
|
|
|
68
68
|
import { CiteThisPage } from '@metacensus/library-ui'
|
|
69
69
|
import { citation } from '../citation'
|
|
70
70
|
---
|
|
71
|
-
<CiteThisPage citation={citation} risHref="/a-page.ris" bibHref="/a-page.bib" />
|
|
71
|
+
<CiteThisPage client:load citation={citation} risHref="/a-page.ris" bibHref="/a-page.bib" />
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
```ts
|
|
@@ -216,7 +216,7 @@ A step is `--mc-<family>-<step>`, as `--mc-purple-bold`. `--mc-white` and `--mc-
|
|
|
216
216
|
| `--mc-surface` | grey tint | grey bold, deeper |
|
|
217
217
|
| `--mc-hairline` | grey tint | grey bold, deepest |
|
|
218
218
|
| `--mc-ink` | grey bold | grey tint |
|
|
219
|
-
| `--mc-ink-secondary` | grey
|
|
219
|
+
| `--mc-ink-secondary` | grey bold | grey mid |
|
|
220
220
|
| `--mc-line-input` | grey mid | grey mid |
|
|
221
221
|
| `--mc-series` | blue bold | blue mid |
|
|
222
222
|
| `--mc-ink-accent` | purple bold | purple tint |
|
|
@@ -245,7 +245,7 @@ The default for a chip, pill, badge or callout: the family's tint as the fill, i
|
|
|
245
245
|
|
|
246
246
|
### Slate Mist
|
|
247
247
|
|
|
248
|
-
`--mc-grey-mid` is for text demoted in place: copy that stops being the subject and becomes context for what replaced it. Copy that is merely secondary starts in Charcoal, which is `--mc-ink`.
|
|
248
|
+
`--mc-grey-mid` is for text demoted in place: copy that stops being the subject and becomes context for what replaced it. Copy that is merely secondary starts in Charcoal, which is `--mc-ink`. `--mc-ink-secondary` is Charcoal in light, where Slate Mist is about 3.2:1 on white, and Slate Mist in dark, where it clears 4.5:1 on the night ground, so it holds small text in both. For an outline, use `--mc-line-input`.
|
|
249
249
|
|
|
250
250
|
### Shape (provisional)
|
|
251
251
|
|
package/dist/site/links.js
CHANGED
|
@@ -16,7 +16,7 @@ export const SECTION_LINKS = [
|
|
|
16
16
|
];
|
|
17
17
|
export const FOOTER_COLUMNS = [
|
|
18
18
|
{
|
|
19
|
-
label: '
|
|
19
|
+
label: 'Explore',
|
|
20
20
|
links: [
|
|
21
21
|
...SECTION_LINKS,
|
|
22
22
|
BLOG_LINK,
|
|
@@ -24,7 +24,7 @@ export const FOOTER_COLUMNS = [
|
|
|
24
24
|
],
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
label: '
|
|
27
|
+
label: 'Get involved',
|
|
28
28
|
links: [
|
|
29
29
|
{ label: 'Join us', href: JOIN_PATH },
|
|
30
30
|
{
|
|
@@ -36,9 +36,11 @@ export const FOOTER_COLUMNS = [
|
|
|
36
36
|
],
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
label: '
|
|
40
|
-
links: [
|
|
39
|
+
label: 'About',
|
|
40
|
+
links: [
|
|
41
|
+
{ label: 'GitHub', href: 'https://github.com/metacensus' },
|
|
42
|
+
{ label: 'Legal', href: LEGAL_PATH },
|
|
43
|
+
],
|
|
41
44
|
},
|
|
42
|
-
{ label: 'About this site', links: [{ label: 'Legal', href: LEGAL_PATH }] },
|
|
43
45
|
];
|
|
44
46
|
//# sourceMappingURL=links.js.map
|
package/dist/site/links.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../src/site/links.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAA;AACnC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA;AAEpC,kEAAkE;AAClE,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAA;AAEnC,MAAM,SAAS,GAAa,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;AAE7D,MAAM,CAAC,MAAM,YAAY,GAAwB;IAC/C,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE;IAC3B,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,kCAAkC,EAAE;IAC/D,SAAS;CACV,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAwB;IAChD,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,KAAK,EAAE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EAAE,cAAc;QACrB,KAAK,EAAE;YACL,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;YACrC;gBACE,KAAK,EAAE,sBAAsB;gBAC7B,IAAI,EAAE,iCAAiC;aACxC;YACD,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE;YACvC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE;SACtC;KACF;IACD;QACE,KAAK,EAAE,OAAO;QACd,KAAK,EAAE;YACL,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,+BAA+B,EAAE;YAC1D,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE;SACrC;KACF;CACF,CAAA"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type { DetailsHTMLAttributes } from 'react';
|
|
2
1
|
import { type Citation } from './cite.js';
|
|
3
|
-
type CiteThisPageProps =
|
|
2
|
+
type CiteThisPageProps = {
|
|
4
3
|
citation: Citation;
|
|
5
4
|
/** Where the page serves its RIS file, from `formatRis`. */
|
|
6
5
|
risHref: string;
|
|
7
6
|
/** Where the page serves its BibTeX file, from `formatBibtex`. */
|
|
8
7
|
bibHref: string;
|
|
8
|
+
className?: string;
|
|
9
9
|
};
|
|
10
|
-
/** A `Cite this page`
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
10
|
+
/** A round `Cite this page` button fixed at the viewport's left edge, vertically
|
|
11
|
+
* centred. Hover, focus or a tap opens a panel beside it with the citation as
|
|
12
|
+
* text and a download link to each file; Escape, moving away or a tap
|
|
13
|
+
* elsewhere closes it. It formats what the page gives it and renders nothing
|
|
14
|
+
* without a url. Render it once per page, from the layout; hydrate it alone. */
|
|
15
|
+
export declare function CiteThisPage({ citation, risHref, bibHref, className, }: CiteThisPageProps): import("react").JSX.Element | null;
|
|
14
16
|
export {};
|
|
@@ -2,12 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { formatCitationText } from './cite.js';
|
|
3
3
|
import { Button } from './Button.js';
|
|
4
4
|
import { cn } from './cn.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
|
|
5
|
+
import { Float } from './Float.js';
|
|
6
|
+
/** A round `Cite this page` button fixed at the viewport's left edge, vertically
|
|
7
|
+
* centred. Hover, focus or a tap opens a panel beside it with the citation as
|
|
8
|
+
* text and a download link to each file; Escape, moving away or a tap
|
|
9
|
+
* elsewhere closes it. It formats what the page gives it and renders nothing
|
|
10
|
+
* without a url. Render it once per page, from the layout; hydrate it alone. */
|
|
11
|
+
export function CiteThisPage({ citation, risHref, bibHref, className, }) {
|
|
9
12
|
if (!citation.url?.trim())
|
|
10
13
|
return null;
|
|
11
|
-
return (_jsxs(
|
|
14
|
+
return (_jsxs(Float, { className: cn('mc-cite', className), label: "Cite this page", icon:
|
|
15
|
+
/* Lucide's `quote`, under the ISC license in LICENSES/ISC.txt. */
|
|
16
|
+
_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }), _jsx("path", { d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" })] }), children: [_jsx("p", { className: "mc-cite-text", children: formatCitationText(citation) }), _jsxs("p", { className: "mc-cite-downloads", children: [_jsx(Button, { variant: "secondary", href: risHref, download: true, children: "Download RIS" }), _jsx(Button, { variant: "secondary", href: bibHref, download: true, children: "Download BibTeX" })] })] }));
|
|
12
17
|
}
|
|
13
18
|
//# sourceMappingURL=CiteThisPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CiteThisPage.js","sourceRoot":"","sources":["../../src/tools/CiteThisPage.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"CiteThisPage.js","sourceRoot":"","sources":["../../src/tools/CiteThisPage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAiB,MAAM,WAAW,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAWlC;;;;iFAIiF;AACjF,MAAM,UAAU,YAAY,CAAC,EAC3B,QAAQ,EACR,OAAO,EACP,OAAO,EACP,SAAS,GACS;IAClB,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE;QAAE,OAAO,IAAI,CAAA;IACtC,OAAO,CACL,MAAC,KAAK,IACJ,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,EACnC,KAAK,EAAC,gBAAgB,EACtB,IAAI;QACF,kEAAkE;QAClE,eACE,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAE,CAAC,EACd,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,iBACV,MAAM,aAElB,eAAM,CAAC,EAAC,gIAAgI,GAAG,EAC3I,eAAM,CAAC,EAAC,+HAA+H,GAAG,IACtI,aAGR,YAAG,SAAS,EAAC,cAAc,YAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAK,EAC9D,aAAG,SAAS,EAAC,mBAAmB,aAC9B,KAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,mCAE1C,EACT,KAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,sCAE1C,IACP,IACE,CACT,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** A round icon button fixed to the viewport, with a panel beside it. Hover,
|
|
3
|
+
* focus or a tap opens the panel; Escape, moving away or a tap elsewhere
|
|
4
|
+
* closes it, and Escape returns focus to the button. Where it sits is the
|
|
5
|
+
* caller's class. */
|
|
6
|
+
export declare function Float({ className, label, icon, children, }: {
|
|
7
|
+
className?: string;
|
|
8
|
+
label: string;
|
|
9
|
+
icon: ReactNode;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { cn } from './cn.js';
|
|
4
|
+
/** A round icon button fixed to the viewport, with a panel beside it. Hover,
|
|
5
|
+
* focus or a tap opens the panel; Escape, moving away or a tap elsewhere
|
|
6
|
+
* closes it, and Escape returns focus to the button. Where it sits is the
|
|
7
|
+
* caller's class. */
|
|
8
|
+
export function Float({ className, label, icon, children, }) {
|
|
9
|
+
const [open, setOpen] = useState(false);
|
|
10
|
+
const button = useRef(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!open)
|
|
13
|
+
return;
|
|
14
|
+
const close = (e) => {
|
|
15
|
+
if (!e.target.closest('.mc-float'))
|
|
16
|
+
setOpen(false);
|
|
17
|
+
};
|
|
18
|
+
document.addEventListener('pointerdown', close);
|
|
19
|
+
return () => document.removeEventListener('pointerdown', close);
|
|
20
|
+
}, [open]);
|
|
21
|
+
return (_jsxs("div", { className: cn('mc-float', className), onPointerEnter: (e) => e.pointerType === 'mouse' && setOpen(true), onPointerLeave: (e) => e.pointerType === 'mouse' && setOpen(false), onFocus: () => setOpen(true),
|
|
22
|
+
// Safari does not focus a control it is clicked on: no `relatedTarget`
|
|
23
|
+
// means focus went nowhere a page can name, not that it left.
|
|
24
|
+
onBlur: (e) => {
|
|
25
|
+
if (e.relatedTarget && !e.currentTarget.contains(e.relatedTarget))
|
|
26
|
+
setOpen(false);
|
|
27
|
+
}, onKeyDown: (e) => {
|
|
28
|
+
if (e.key !== 'Escape')
|
|
29
|
+
return;
|
|
30
|
+
button.current?.focus();
|
|
31
|
+
setOpen(false);
|
|
32
|
+
}, children: [_jsx("button", { ref: button, type: "button", className: "mc-float-button", "aria-label": label, "aria-expanded": open, onClick: () => setOpen(true), children: icon }), _jsx("div", { className: "mc-float-panel", hidden: !open, children: children })] }));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=Float.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Float.js","sourceRoot":"","sources":["../../src/tools/Float.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAA;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B;;;sBAGsB;AACtB,MAAM,UAAU,KAAK,CAAC,EACpB,SAAS,EACT,KAAK,EACL,IAAI,EACJ,QAAQ,GAMT;IACC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACvC,MAAM,MAAM,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAA;IAE9C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,IAAI;YAAE,OAAM;QACjB,MAAM,KAAK,GAAG,CAAC,CAAe,EAAE,EAAE;YAChC,IAAI,CAAE,CAAC,CAAC,MAAkB,CAAC,OAAO,CAAC,WAAW,CAAC;gBAAE,OAAO,CAAC,KAAK,CAAC,CAAA;QACjE,CAAC,CAAA;QACD,QAAQ,CAAC,gBA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"}
|
package/dist/tools/display.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useSyncExternalStore } from 'react';
|
|
3
3
|
import { cn } from './cn.js';
|
|
4
|
+
import { Float } from './Float.js';
|
|
4
5
|
import { Checkbox, RadioGroup } from './form.js';
|
|
5
6
|
const THEME_KEY = 'mc-theme';
|
|
6
7
|
const MOTION_KEY = 'mc-motion';
|
|
@@ -73,29 +74,9 @@ const THEME_OPTIONS = [
|
|
|
73
74
|
export function DisplayControls({ className }) {
|
|
74
75
|
const { theme, setTheme } = useTheme();
|
|
75
76
|
const { still, setStill } = useStill();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return;
|
|
81
|
-
const close = (e) => {
|
|
82
|
-
if (!e.target.closest('.mc-display'))
|
|
83
|
-
setOpen(false);
|
|
84
|
-
};
|
|
85
|
-
document.addEventListener('pointerdown', close);
|
|
86
|
-
return () => document.removeEventListener('pointerdown', close);
|
|
87
|
-
}, [open]);
|
|
88
|
-
return (_jsxs("div", { className: cn('mc-display', className), onPointerEnter: (e) => e.pointerType === 'mouse' && setOpen(true), onPointerLeave: (e) => e.pointerType === 'mouse' && setOpen(false), onFocus: () => setOpen(true),
|
|
89
|
-
// Safari does not focus a control it is clicked on: no `relatedTarget`
|
|
90
|
-
// means focus went nowhere a page can name, not that it left.
|
|
91
|
-
onBlur: (e) => {
|
|
92
|
-
if (e.relatedTarget && !e.currentTarget.contains(e.relatedTarget))
|
|
93
|
-
setOpen(false);
|
|
94
|
-
}, onKeyDown: (e) => {
|
|
95
|
-
if (e.key !== 'Escape')
|
|
96
|
-
return;
|
|
97
|
-
button.current?.focus();
|
|
98
|
-
setOpen(false);
|
|
99
|
-
}, children: [_jsx("button", { ref: button, type: "button", className: "mc-display-button", "aria-label": "Display", "aria-expanded": open, onClick: () => setOpen(true), children: _jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M21 4h-7M10 4H3M21 12h-9M8 12H3M21 20h-5M12 20H3" }), _jsx("path", { d: "M14 2v4M8 10v4M16 18v4" })] }) }), _jsxs("div", { className: "mc-display-panel", hidden: !open, children: [_jsx(RadioGroup, { legend: "Theme", name: "mc-display-theme", options: THEME_OPTIONS, value: theme, onChange: (value) => setTheme(value) }), _jsx(Checkbox, { label: "Stop animations", checked: still, onChange: (e) => setStill(e.target.checked) })] })] }));
|
|
77
|
+
return (_jsxs(Float, { className: cn('mc-display', className), label: "Display", icon:
|
|
78
|
+
/* Lucide's `sliders-horizontal`, under the ISC license in
|
|
79
|
+
LICENSES/ISC.txt. */
|
|
80
|
+
_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M21 4h-7M10 4H3M21 12h-9M8 12H3M21 20h-5M12 20H3" }), _jsx("path", { d: "M14 2v4M8 10v4M16 18v4" })] }), children: [_jsx(RadioGroup, { legend: "Theme", name: "mc-display-theme", options: THEME_OPTIONS, value: theme, onChange: (value) => setTheme(value) }), _jsx(Checkbox, { label: "Stop animations", checked: still, onChange: (e) => setStill(e.target.checked) })] }));
|
|
100
81
|
}
|
|
101
82
|
//# sourceMappingURL=display.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../src/tools/display.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../src/tools/display.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EA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,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAC3C,IACI,CACT,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
package/src/chrome/Footer.astro
CHANGED
|
@@ -13,8 +13,11 @@ import { FOOTER_COLUMNS } from '@metacensus/library-ui/site-links'
|
|
|
13
13
|
</div>
|
|
14
14
|
<div class="mc-footer-columns">
|
|
15
15
|
{
|
|
16
|
-
FOOTER_COLUMNS.map((column) => (
|
|
17
|
-
<nav class="mc-footer-column" aria-
|
|
16
|
+
FOOTER_COLUMNS.map((column, i) => (
|
|
17
|
+
<nav class="mc-footer-column" aria-labelledby={`mc-footer-column-${i}`}>
|
|
18
|
+
<h2 class="mc-footer-heading" id={`mc-footer-column-${i}`}>
|
|
19
|
+
{column.label}
|
|
20
|
+
</h2>
|
|
18
21
|
{column.links.map((link) => (
|
|
19
22
|
<a href={link.href}>{link.label}</a>
|
|
20
23
|
))}
|
package/src/css/styles.css
CHANGED
|
@@ -227,16 +227,25 @@
|
|
|
227
227
|
.mc-footer-tagline {
|
|
228
228
|
margin: 0.75rem 0 0;
|
|
229
229
|
}
|
|
230
|
+
/* The columns share the row beside the brand in equal tracks, and wrap to as many as fit under it. */
|
|
230
231
|
.mc-footer-columns {
|
|
231
|
-
display:
|
|
232
|
-
flex
|
|
232
|
+
display: grid;
|
|
233
|
+
flex: 1 1 24rem;
|
|
234
|
+
min-width: 0;
|
|
235
|
+
grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
|
|
233
236
|
gap: 2rem;
|
|
237
|
+
max-width: 40rem;
|
|
234
238
|
}
|
|
235
239
|
.mc-footer-column {
|
|
236
240
|
display: flex;
|
|
237
241
|
flex-direction: column;
|
|
238
242
|
gap: 0.75rem;
|
|
239
243
|
}
|
|
244
|
+
.mc-footer-heading {
|
|
245
|
+
margin: 0;
|
|
246
|
+
font-size: 1rem;
|
|
247
|
+
font-weight: 600;
|
|
248
|
+
}
|
|
240
249
|
.mc-footer a {
|
|
241
250
|
color: var(--mc-ink);
|
|
242
251
|
}
|
|
@@ -398,24 +407,29 @@
|
|
|
398
407
|
color: var(--mc-tint-blue-ink);
|
|
399
408
|
}
|
|
400
409
|
|
|
401
|
-
/* CiteThisPage: a
|
|
410
|
+
/* CiteThisPage: a floating button at the left edge, vertically centred, with
|
|
411
|
+
its panel to the right. */
|
|
402
412
|
.mc-cite {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
background: var(--mc-card);
|
|
407
|
-
color: var(--mc-ink);
|
|
413
|
+
inset-block-start: 50%;
|
|
414
|
+
inset-inline-start: 1rem;
|
|
415
|
+
transform: translateY(-50%);
|
|
408
416
|
}
|
|
409
|
-
.mc-cite-
|
|
410
|
-
|
|
411
|
-
|
|
417
|
+
.mc-cite .mc-float-panel {
|
|
418
|
+
inset-block-start: 50%;
|
|
419
|
+
inset-inline-start: calc(100% + 0.5rem);
|
|
420
|
+
transform: translateY(-50%);
|
|
421
|
+
width: 18rem;
|
|
422
|
+
max-width: calc(100vw - 5.5rem);
|
|
412
423
|
}
|
|
413
|
-
.mc-cite-
|
|
414
|
-
|
|
415
|
-
|
|
424
|
+
.mc-cite .mc-float-panel::before {
|
|
425
|
+
inset-block: 0;
|
|
426
|
+
inset-inline-start: -0.5rem;
|
|
427
|
+
inset-inline-end: auto;
|
|
428
|
+
width: 0.5rem;
|
|
429
|
+
height: auto;
|
|
416
430
|
}
|
|
417
431
|
.mc-cite-text {
|
|
418
|
-
margin: 0
|
|
432
|
+
margin: 0;
|
|
419
433
|
overflow-wrap: anywhere;
|
|
420
434
|
}
|
|
421
435
|
.mc-cite-downloads {
|
|
@@ -475,15 +489,14 @@
|
|
|
475
489
|
font-size: 0.875rem;
|
|
476
490
|
}
|
|
477
491
|
|
|
478
|
-
/*
|
|
479
|
-
corner,
|
|
480
|
-
|
|
492
|
+
/* Floating controls: a round icon button fixed to the viewport, with a panel
|
|
493
|
+
beside it. DisplayControls sits at the bottom-left corner, the panel above;
|
|
494
|
+
CiteThisPage sets its own place. */
|
|
495
|
+
.mc-float {
|
|
481
496
|
position: fixed;
|
|
482
|
-
inset-block-end: 1rem;
|
|
483
|
-
inset-inline-start: 1rem;
|
|
484
497
|
z-index: 40;
|
|
485
498
|
}
|
|
486
|
-
.mc-
|
|
499
|
+
.mc-float-button {
|
|
487
500
|
display: grid;
|
|
488
501
|
place-items: center;
|
|
489
502
|
width: 2.75rem;
|
|
@@ -496,17 +509,13 @@
|
|
|
496
509
|
box-shadow: 0 2px 8px color-mix(in srgb, var(--mc-ink) 20%, transparent);
|
|
497
510
|
cursor: pointer;
|
|
498
511
|
}
|
|
499
|
-
.mc-
|
|
512
|
+
.mc-float-button svg {
|
|
500
513
|
width: 1.25rem;
|
|
501
514
|
height: 1.25rem;
|
|
502
515
|
}
|
|
503
|
-
.mc-
|
|
516
|
+
.mc-float-panel {
|
|
504
517
|
position: absolute;
|
|
505
|
-
inset-block-end: calc(100% + 0.5rem);
|
|
506
|
-
inset-inline-start: 0;
|
|
507
518
|
box-sizing: border-box;
|
|
508
|
-
width: 14rem;
|
|
509
|
-
max-width: calc(100vw - 2rem);
|
|
510
519
|
display: flex;
|
|
511
520
|
flex-direction: column;
|
|
512
521
|
gap: 0.75rem;
|
|
@@ -518,21 +527,31 @@
|
|
|
518
527
|
box-shadow: 0 2px 8px color-mix(in srgb, var(--mc-ink) 20%, transparent);
|
|
519
528
|
}
|
|
520
529
|
/* Bridges the gap to the button so the pointer crosses it without leaving. */
|
|
521
|
-
.mc-
|
|
530
|
+
.mc-float-panel::before {
|
|
522
531
|
content: '';
|
|
523
532
|
position: absolute;
|
|
524
533
|
inset-inline: 0;
|
|
525
534
|
inset-block-start: 100%;
|
|
526
535
|
height: 0.5rem;
|
|
527
536
|
}
|
|
528
|
-
.mc-
|
|
537
|
+
.mc-float-panel[hidden] {
|
|
529
538
|
display: none;
|
|
530
539
|
}
|
|
531
|
-
.mc-
|
|
532
|
-
.mc-
|
|
540
|
+
.mc-float-button:focus-visible,
|
|
541
|
+
.mc-float-panel input:focus-visible {
|
|
533
542
|
outline: 2px solid var(--mc-ink-accent);
|
|
534
543
|
outline-offset: 2px;
|
|
535
544
|
}
|
|
545
|
+
.mc-display {
|
|
546
|
+
inset-block-end: 1rem;
|
|
547
|
+
inset-inline-start: 1rem;
|
|
548
|
+
}
|
|
549
|
+
.mc-display .mc-float-panel {
|
|
550
|
+
inset-block-end: calc(100% + 0.5rem);
|
|
551
|
+
inset-inline-start: 0;
|
|
552
|
+
width: 14rem;
|
|
553
|
+
max-width: calc(100vw - 2rem);
|
|
554
|
+
}
|
|
536
555
|
/* The footer's last line stays clear of the button at the page's end. */
|
|
537
556
|
:root:has(.mc-display) .mc-footer {
|
|
538
557
|
padding-block-end: 5rem;
|
package/src/css/tokens.css
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
color-mix(in srgb, var(--mc-grey-bold) 55%, var(--mc-ground))
|
|
41
41
|
);
|
|
42
42
|
--mc-ink: light-dark(var(--mc-grey-bold), var(--mc-grey-tint));
|
|
43
|
-
--mc-ink-secondary: var(--mc-grey-mid);
|
|
43
|
+
--mc-ink-secondary: light-dark(var(--mc-grey-bold), var(--mc-grey-mid));
|
|
44
44
|
--mc-line-input: var(--mc-grey-mid);
|
|
45
45
|
--mc-series: light-dark(var(--mc-blue-bold), var(--mc-blue-mid));
|
|
46
46
|
--mc-ink-accent: light-dark(var(--mc-purple-bold), var(--mc-purple-tint));
|