@metacensus/library-ui 0.13.2 → 0.15.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/LICENSES/ISC.txt +15 -0
- package/README.md +3 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/people/AudienceIcon.d.ts +16 -0
- package/dist/people/AudienceIcon.js +63 -0
- package/dist/people/AudienceIcon.js.map +1 -0
- package/dist/people/ContributorCard.d.ts +27 -0
- package/dist/people/ContributorCard.js +105 -0
- package/dist/people/ContributorCard.js.map +1 -0
- package/dist/tools/theme.d.ts +3 -1
- package/dist/tools/theme.js +18 -3
- package/dist/tools/theme.js.map +1 -1
- package/package.json +3 -2
- package/src/css/styles.css +230 -5
package/LICENSES/ISC.txt
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -30,11 +30,12 @@ Marks are importable as `@metacensus/library-ui/marks/mark.svg` and its siblings
|
|
|
30
30
|
|
|
31
31
|
Any unlayered rule of yours now beats the package's, whatever its specificity: a bare `button { ... }` beats `.mc-button`, which it did not before. That is how your own CSS wins. To choose the layer's name, import it as `@import '@metacensus/library-ui/styles.css' layer(brand);`, which nests the rules as `brand.mc`, and name `brand` in the ordering line in place of `mc`.
|
|
32
32
|
|
|
33
|
-
Components render on the server: no router, auth or API client, and no browser global while rendering. In Astro, add `@astrojs/react`; the marks and chrome render at build with no `client:` directive and ship no JS. Only `ThemeToggle`
|
|
33
|
+
Components render on the server: no router, auth or API client, and no browser global while rendering. In Astro, add `@astrojs/react`; the marks and chrome render at build with no `client:` directive and ship no JS. Only `ThemeToggle` and `ContributorCard` need one, as `client:visible`.
|
|
34
34
|
|
|
35
35
|
- Marks: `MetaCensusMark`, `MetaCensusLockup`, `MetaCensusWordmark` (the lockup's letters alone, in `WORDMARK_VIEWBOX`), `MetaCensusArrow`, `LogoArrowMorph`, and the shared geometry, including the lockup's spacing (`LOCKUP_VIEWBOX`, and `LOCKUP_MARK_BOX` for the mark's box within it).
|
|
36
36
|
- Chrome: `Header` (`nav` and `actions` slots, which wrap on a narrow screen; with no `nav`, the `actions` sit at the end of the row), `Footer` (`brand` replaces the linked lockup and its link is the consumer's; `tagline`; link columns as children), `Nav` (`links`).
|
|
37
37
|
- Tools: `cn`, `Button`, `Notice`, `Chip`, the form kit (`Field`, `Label`, `Input`, `Textarea`, `Select`, `Checkbox`, `RadioGroup`, `FieldError`), `useTheme`, `ThemeToggle`, `themeScript`.
|
|
38
|
+
- People: `ContributorCard` (a person's photo, name, role, flavor chip and bio, whose bio floats open on hover or focus until Escape), `ContributorFlavorKey`, and `AudienceIcon` for each of `AUDIENCES`, labelled from `AUDIENCE_LABELS`. The floating card is portaled into `<body>`, so import `tokens.css` and set the theme on `:root`, not on a wrapper.
|
|
38
39
|
|
|
39
40
|
- Marks take `variant`: `auto` (the default: solid on light, reversed on dark), `solid` or `reversed`, and `gradient` on the lockup, which needs a white or very light ground. Mark usage is in [TRADEMARKS.md](TRADEMARKS.md).
|
|
40
41
|
- `LogoArrowMorph` is a pure function of `progress`, 0 the mark and 1 the arrow; whatever places it owns the timing. Keep it horizontal.
|
|
@@ -42,7 +43,7 @@ Components render on the server: no router, auth or API client, and no browser g
|
|
|
42
43
|
- `Button` takes `variant`: `primary` (the default; one per view), `secondary`, `text`, `danger` or `inverse`. A solid Garnet fill marks only a risky action: one that destroys, discards, revokes or cannot be undone. A vote, a filter or a choice between options is not risky. `inverse` is a white fill for the call to action on a `--mc-fill-solid`, `--mc-gradient-hero` or `--mc-night` ground, where `primary` is the ground's own colour or nearly so. Use it on those grounds only: it reads the same in light and dark, and `secondary` inside `.dark` is its quieter sibling.
|
|
43
44
|
- `Notice` takes `tone`: `alert` (the default, which reads the `--mc-alert-*` roles), `info` (the blue tint) or `success` (the purple tint fill with the accent ink, since the palette has no green). It renders `role="note"`; pass `role="alert"` for an error.
|
|
44
45
|
- `Button` and `Notice` follow the guidelines' illustrated Actions and Callout patterns. Those patterns do not bind yet: the guidelines have yet to state their shape.
|
|
45
|
-
- Theme: inline `themeScript` in `<head>` so a stored override is on `<html>` before first paint. `useTheme` and `ThemeToggle` read and set it: `system` (the OS), `light` or `dark`.
|
|
46
|
+
- Theme: inline `themeScript` in `<head>` so a stored override is on `<html>` before first paint. `useTheme` and `ThemeToggle` read and set it: `system` (the OS), `light` or `dark`. `ThemeToggle` is a round icon button fixed at the viewport's bottom corner, so render it once, from the layout.
|
|
46
47
|
|
|
47
48
|
```astro
|
|
48
49
|
---
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export { Chip } from './tools/Chip.js';
|
|
|
8
8
|
export { cn } from './tools/cn.js';
|
|
9
9
|
export { Checkbox, Field, FieldError, Input, Label, RadioGroup, Select, Textarea, } from './tools/form.js';
|
|
10
10
|
export { Notice } from './tools/Notice.js';
|
|
11
|
+
export { AUDIENCES, AUDIENCE_LABELS, AudienceIcon, type Audience, } from './people/AudienceIcon.js';
|
|
12
|
+
export { ContributorCard, ContributorFlavorKey, type ContributorFlavor, } from './people/ContributorCard.js';
|
|
11
13
|
export { ThemeToggle, themeScript, useTheme, type Theme, } from './tools/theme.js';
|
package/dist/index.js
CHANGED
|
@@ -8,5 +8,7 @@ export { Chip } from './tools/Chip.js';
|
|
|
8
8
|
export { cn } from './tools/cn.js';
|
|
9
9
|
export { Checkbox, Field, FieldError, Input, Label, RadioGroup, Select, Textarea, } from './tools/form.js';
|
|
10
10
|
export { Notice } from './tools/Notice.js';
|
|
11
|
+
export { AUDIENCES, AUDIENCE_LABELS, AudienceIcon, } from './people/AudienceIcon.js';
|
|
12
|
+
export { ContributorCard, ContributorFlavorKey, } from './people/ContributorCard.js';
|
|
11
13
|
export { ThemeToggle, themeScript, useTheme, } from './tools/theme.js';
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,kBAAkB,GACnB,MAAM,kBAAkB,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAgB,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EACL,QAAQ,EACR,KAAK,EACL,UAAU,EACV,KAAK,EACL,KAAK,EACL,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EACL,WAAW,EACX,WAAW,EACX,QAAQ,GAET,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,kBAAkB,GACnB,MAAM,kBAAkB,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAgB,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EACL,QAAQ,EACR,KAAK,EACL,UAAU,EACV,KAAK,EACL,KAAK,EACL,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EACL,SAAS,EACT,eAAe,EACf,YAAY,GAEb,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,eAAe,EACf,oBAAoB,GAErB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,WAAW,EACX,WAAW,EACX,QAAQ,GAET,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type SVGProps } from 'react';
|
|
2
|
+
/** Who a piece of work is for, in the order a page lists them. */
|
|
3
|
+
export declare const AUDIENCES: readonly ["engineers", "researchers", "regulators", "funders", "partners", "contributors"];
|
|
4
|
+
export type Audience = (typeof AUDIENCES)[number];
|
|
5
|
+
export declare const AUDIENCE_LABELS: Record<Audience, string>;
|
|
6
|
+
/** `</>` on a 24-unit square, as strokes: the engineering flavor's glyph and
|
|
7
|
+
* the engineers' symbol. Lucide's `code-xml`, under the ISC license in
|
|
8
|
+
* LICENSES/ISC.txt. */
|
|
9
|
+
export declare const CODE_PATH = "M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16";
|
|
10
|
+
type AudienceIconProps = Omit<SVGProps<SVGSVGElement>, 'children'> & {
|
|
11
|
+
audience: Audience;
|
|
12
|
+
};
|
|
13
|
+
/** A person marked for one audience and labelled with its name, in the text
|
|
14
|
+
* colour at 1.5em. */
|
|
15
|
+
export declare function AudienceIcon({ audience, className, ...props }: AudienceIconProps): import("react").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { cn } from '../tools/cn.js';
|
|
4
|
+
/** Who a piece of work is for, in the order a page lists them. */
|
|
5
|
+
export const AUDIENCES = [
|
|
6
|
+
'engineers',
|
|
7
|
+
'researchers',
|
|
8
|
+
'regulators',
|
|
9
|
+
'funders',
|
|
10
|
+
'partners',
|
|
11
|
+
'contributors',
|
|
12
|
+
];
|
|
13
|
+
export const AUDIENCE_LABELS = {
|
|
14
|
+
engineers: 'Engineers',
|
|
15
|
+
researchers: 'Researchers',
|
|
16
|
+
regulators: 'Regulators and guideline groups',
|
|
17
|
+
funders: 'Funders',
|
|
18
|
+
partners: 'Partners',
|
|
19
|
+
contributors: 'Contributors',
|
|
20
|
+
};
|
|
21
|
+
/** `</>` on a 24-unit square, as strokes: the engineering flavor's glyph and
|
|
22
|
+
* the engineers' symbol. Lucide's `code-xml`, under the ISC license in
|
|
23
|
+
* LICENSES/ISC.txt. */
|
|
24
|
+
export const CODE_PATH = 'M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16';
|
|
25
|
+
const rule = (d, width) => (_jsx("path", { d: d, fill: "none", stroke: "currentColor", strokeWidth: width, strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
26
|
+
const SHIRT = _jsx("path", { d: "M-2.6 3L0 6.8 2.6 3l.5 6.8h-6.2z" });
|
|
27
|
+
const TIE = _jsx("path", { d: "M-.95 6.1L0 5.1l.95 1-.33 3.7h-1.24z" });
|
|
28
|
+
const DRAWINGS = {
|
|
29
|
+
engineers: {
|
|
30
|
+
symbol: (_jsx("g", { transform: "translate(-16.2 -11.6) scale(.35)", children: rule(CODE_PATH, 3.7) })),
|
|
31
|
+
},
|
|
32
|
+
researchers: {
|
|
33
|
+
cut: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M-2.6 1.6l.7 2.1-.9.8.9.8.7 4.5h2.4l.7-4.5.9-.8-.9-.8.7-2.1z" }), rule('M-6.1 8.4h2.6', 1.05), rule('M-5.5 8.4V6.6m.8 1.8V7.2', 0.85)] })),
|
|
34
|
+
symbol: (_jsxs(_Fragment, { children: [rule('M-12.8-11.3v4.1L-15-3.5h6l-2.2-3.7v-4.1', 1.3), rule('M-13.3-11.3h2.6', 1.3)] })),
|
|
35
|
+
},
|
|
36
|
+
regulators: {
|
|
37
|
+
cut: SHIRT,
|
|
38
|
+
ink: TIE,
|
|
39
|
+
symbol: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M-12-11.2l4 2.7q.4.4-.2.7h-7.6q-.6-.3-.2-.7z" }), rule('M-14.4-7.5v3m2.4-3v3m2.4-3v3', 1.3), rule('M-15.4-3.9h6.8', 1.6)] })),
|
|
40
|
+
},
|
|
41
|
+
funders: {
|
|
42
|
+
cut: (_jsxs(_Fragment, { children: [SHIRT, _jsx("circle", { cx: -12, cy: -6.9, r: 1.4 })] })),
|
|
43
|
+
ink: TIE,
|
|
44
|
+
symbol: _jsx("rect", { x: -16.4, y: -9.7, width: 8.8, height: 5.6, rx: 0.8 }),
|
|
45
|
+
},
|
|
46
|
+
partners: {
|
|
47
|
+
cut: SHIRT,
|
|
48
|
+
ink: TIE,
|
|
49
|
+
symbol: (_jsxs(_Fragment, { children: [rule('M-13.6-9.6v-1.5h3.2v1.5', 1.3), _jsx("rect", { x: -16.1, y: -9.6, width: 8.2, height: 5.9, rx: 0.8 })] })),
|
|
50
|
+
},
|
|
51
|
+
contributors: {},
|
|
52
|
+
};
|
|
53
|
+
const BOX = { x: -16.5, y: -12.75, size: 24 };
|
|
54
|
+
/** A person marked for one audience and labelled with its name, in the text
|
|
55
|
+
* colour at 1.5em. */
|
|
56
|
+
export function AudienceIcon({ audience, className, ...props }) {
|
|
57
|
+
const id = `mc-audience-${useId().replace(/:/g, '')}`;
|
|
58
|
+
const { cut, ink, symbol } = DRAWINGS[audience];
|
|
59
|
+
const label = AUDIENCE_LABELS[audience];
|
|
60
|
+
const box = { x: BOX.x, y: BOX.y, width: BOX.size, height: BOX.size };
|
|
61
|
+
return (_jsxs("svg", { viewBox: `${box.x} ${box.y} ${box.width} ${box.height}`, className: cn('mc-audience-icon', className), role: "img", "aria-label": label, fill: "currentColor", ...props, children: [_jsx("title", { children: label }), _jsxs("mask", { id: id, maskUnits: "userSpaceOnUse", ...box, children: [_jsx("rect", { ...box, fill: "white" }), _jsx("g", { fill: "black", color: "black", children: cut })] }), _jsxs("g", { mask: `url(#${id})`, children: [_jsx("path", { d: "M-7.4 9.8c0-10.15 14.8-10.15 14.8 0z" }), _jsx("circle", { cx: 0, cy: -3.2, r: 4 }), symbol] }), ink] }));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=AudienceIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudienceIcon.js","sourceRoot":"","sources":["../../src/people/AudienceIcon.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAA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EAAE,EAAE,CAAC,EAAE,CAAA;IACrD,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IACvC,MAAM,GAAG,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,CAAA;IACrE,OAAO,CACL,eACE,OAAO,EAAE,GAAG,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,EACvD,SAAS,EAAE,EAAE,CAAC,kBAAkB,EAAE,SAAS,CAAC,EAC5C,IAAI,EAAC,KAAK,gBACE,KAAK,EACjB,IAAI,EAAC,cAAc,KACf,KAAK,aAET,0BAAQ,KAAK,GAAS,EACtB,gBAAM,EAAE,EAAE,EAAE,EAAE,SAAS,EAAC,gBAAgB,KAAK,GAAG,aAC9C,kBAAU,GAAG,EAAE,IAAI,EAAC,OAAO,GAAG,EAC9B,YAAG,IAAI,EAAC,OAAO,EAAC,KAAK,EAAC,OAAO,YAC1B,GAAG,GACF,IACC,EACP,aAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,aACpB,eAAM,CAAC,EAAC,sCAAsC,GAAG,EACjD,iBAAQ,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAI,EAChC,MAAM,IACL,EACH,GAAG,IACA,CACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** Which kind of work someone contributes; `both` merges the two chips. */
|
|
3
|
+
export type ContributorFlavor = 'engineering' | 'quantitative' | 'both';
|
|
4
|
+
/** What each flavor chip means, shown once where a roster is introduced. */
|
|
5
|
+
export declare function ContributorFlavorKey({ className }: {
|
|
6
|
+
className?: string;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
type ContributorCardProps = {
|
|
9
|
+
name: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
image?: string;
|
|
12
|
+
role?: string;
|
|
13
|
+
/** `role` is a MetaCensus title, set in the accent. */
|
|
14
|
+
metacensusTitle?: boolean;
|
|
15
|
+
flavor?: ContributorFlavor;
|
|
16
|
+
/** The heading level of the name. */
|
|
17
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
18
|
+
/** The bio, clamped to the card and shown whole while it is hovered or
|
|
19
|
+
* focused. */
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
};
|
|
22
|
+
/** A person who contributes: photo or initials, name, role, flavor and bio,
|
|
23
|
+
* in a fixed 18rem by 12rem footprint. Hovered or focused, the card floats
|
|
24
|
+
* over the page at full height until both end or Escape is pressed, so it
|
|
25
|
+
* needs a `client:` directive to grow. */
|
|
26
|
+
export declare function ContributorCard({ name, href, image, role, metacensusTitle, flavor, level, children, }: ContributorCardProps): import("react").JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState, } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { cn } from '../tools/cn.js';
|
|
5
|
+
import { CODE_PATH } from './AudienceIcon.js';
|
|
6
|
+
const FLAVORS = {
|
|
7
|
+
engineering: {
|
|
8
|
+
label: 'Engineering',
|
|
9
|
+
glyph: (_jsx("svg", { viewBox: "0 0 24 24", className: "mc-flavor-glyph", fill: "none", stroke: "currentColor", strokeWidth: 2.25, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: _jsx("path", { d: CODE_PATH }) })),
|
|
10
|
+
},
|
|
11
|
+
quantitative: {
|
|
12
|
+
label: 'Quantitative science',
|
|
13
|
+
// σ²: variance, not summation. Text, so it takes the page's face.
|
|
14
|
+
glyph: _jsx("span", { className: "mc-flavor-sigma", children: "\u03C3\u00B2" }),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
function FlavorChip({ flavor }) {
|
|
18
|
+
if (flavor === 'both') {
|
|
19
|
+
const { engineering, quantitative } = FLAVORS;
|
|
20
|
+
return (_jsxs("span", { role: "img", "aria-label": `${engineering.label} and ${quantitative.label}`, className: "mc-flavor-pair", children: [_jsx("span", { className: "mc-flavor mc-flavor-engineering", children: engineering.glyph }), _jsx("span", { className: "mc-flavor mc-flavor-quantitative", children: quantitative.glyph })] }));
|
|
21
|
+
}
|
|
22
|
+
const { label, glyph } = FLAVORS[flavor];
|
|
23
|
+
return (_jsx("span", { role: "img", "aria-label": label, className: cn('mc-flavor', `mc-flavor-${flavor}`), children: glyph }));
|
|
24
|
+
}
|
|
25
|
+
/** What each flavor chip means, shown once where a roster is introduced. */
|
|
26
|
+
export function ContributorFlavorKey({ className }) {
|
|
27
|
+
const entries = [
|
|
28
|
+
['engineering', FLAVORS.engineering.label],
|
|
29
|
+
['quantitative', FLAVORS.quantitative.label],
|
|
30
|
+
['both', 'Both'],
|
|
31
|
+
];
|
|
32
|
+
return (_jsx("ul", { "aria-label": "Contributor flavors", className: cn('mc-flavor-key', className), children: entries.map(([flavor, word]) => (_jsxs("li", { children: [_jsx("span", { "aria-hidden": true, children: _jsx(FlavorChip, { flavor: flavor }) }), word] }, flavor))) }));
|
|
33
|
+
}
|
|
34
|
+
/** The floated copy repeats the resting card, which keeps focus and the
|
|
35
|
+
* accessible content: hide the copy from assistive tech and the tab order,
|
|
36
|
+
* and keep its bottom on screen. */
|
|
37
|
+
const settle = (copy) => {
|
|
38
|
+
if (!copy)
|
|
39
|
+
return;
|
|
40
|
+
copy
|
|
41
|
+
.querySelectorAll('a, button, [tabindex]')
|
|
42
|
+
.forEach((el) => (el.tabIndex = -1));
|
|
43
|
+
const over = copy.getBoundingClientRect().bottom - window.innerHeight;
|
|
44
|
+
if (over > 0)
|
|
45
|
+
copy.style.top = `${Math.max(0, parseFloat(copy.style.top) - over)}px`;
|
|
46
|
+
};
|
|
47
|
+
/** A person who contributes: photo or initials, name, role, flavor and bio,
|
|
48
|
+
* in a fixed 18rem by 12rem footprint. Hovered or focused, the card floats
|
|
49
|
+
* over the page at full height until both end or Escape is pressed, so it
|
|
50
|
+
* needs a `client:` directive to grow. */
|
|
51
|
+
export function ContributorCard({ name, href, image, role, metacensusTitle, flavor, level, children, }) {
|
|
52
|
+
const Name = `h${level}`;
|
|
53
|
+
const shellRef = useRef(null);
|
|
54
|
+
const [rect, setRect] = useState(null);
|
|
55
|
+
const [hovered, setHovered] = useState(false);
|
|
56
|
+
const [focused, setFocused] = useState(false);
|
|
57
|
+
// Escape holds the card down until a new focus, or until hover and focus
|
|
58
|
+
// have both ended: removing the copy can fire a fresh mouseenter.
|
|
59
|
+
const [dismissed, setDismissed] = useState(false);
|
|
60
|
+
if (dismissed && !hovered && !focused)
|
|
61
|
+
setDismissed(false);
|
|
62
|
+
const floating = rect !== null && (hovered || focused) && !dismissed;
|
|
63
|
+
const measure = () => {
|
|
64
|
+
const r = shellRef.current?.getBoundingClientRect();
|
|
65
|
+
if (r)
|
|
66
|
+
setRect({ top: r.top, left: r.left, width: r.width });
|
|
67
|
+
};
|
|
68
|
+
// Keep the floating card on its shell while the page scrolls.
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (!floating)
|
|
71
|
+
return;
|
|
72
|
+
window.addEventListener('scroll', measure, true);
|
|
73
|
+
window.addEventListener('resize', measure);
|
|
74
|
+
return () => {
|
|
75
|
+
window.removeEventListener('scroll', measure, true);
|
|
76
|
+
window.removeEventListener('resize', measure);
|
|
77
|
+
};
|
|
78
|
+
}, [floating]);
|
|
79
|
+
// From mount, so an Escape that follows the hover at once is not lost.
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
const onKey = (event) => {
|
|
82
|
+
if (event.key === 'Escape')
|
|
83
|
+
setDismissed(true);
|
|
84
|
+
};
|
|
85
|
+
window.addEventListener('keydown', onKey);
|
|
86
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
87
|
+
}, []);
|
|
88
|
+
const card = (style) => (_jsxs("div", { ref: style && ((copy) => settle(copy)), "aria-hidden": style && true, className: cn('mc-contributor', style ? 'mc-contributor-floating' : 'mc-contributor-resting', children != null && 'mc-contributor-with-bio'), style: style, children: [flavor && (_jsx("span", { className: "mc-contributor-flavor", children: _jsx(FlavorChip, { flavor: flavor }) })), _jsxs("div", { className: "mc-contributor-head", children: [image ? (_jsx("img", { src: image, alt: "", width: 48, height: 48, loading: "lazy", className: "mc-contributor-photo" })) : (_jsx("div", { className: "mc-contributor-photo mc-contributor-initials", "aria-hidden": true, children: name
|
|
89
|
+
.split(' ')
|
|
90
|
+
.slice(0, 2)
|
|
91
|
+
.map((word) => word[0] ?? '')
|
|
92
|
+
.join('') })), _jsxs("div", { className: cn('mc-contributor-names', flavor && `mc-contributor-names-${flavor === 'both' ? 2 : 1}`), children: [_jsx(Name, { className: "mc-contributor-name", children: href ? _jsx("a", { href: href, children: name }) : name }), role && (_jsx("p", { className: cn('mc-contributor-role', metacensusTitle && 'mc-contributor-title'), children: role }))] })] }), children != null && _jsx("div", { className: "mc-contributor-bio", children: children })] }));
|
|
93
|
+
return (_jsxs("div", { ref: shellRef, className: "mc-contributor-shell", onMouseEnter: () => {
|
|
94
|
+
measure();
|
|
95
|
+
setHovered(true);
|
|
96
|
+
}, onMouseLeave: () => setHovered(false), onFocusCapture: () => {
|
|
97
|
+
measure();
|
|
98
|
+
setFocused(true);
|
|
99
|
+
setDismissed(false);
|
|
100
|
+
}, onBlurCapture: (event) => {
|
|
101
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
102
|
+
setFocused(false);
|
|
103
|
+
}, children: [card(), floating && createPortal(card({ ...rect, zIndex: 50 }), document.body)] }));
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=ContributorCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContributorCard.js","sourceRoot":"","sources":["../../src/people/ContributorCard.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAK7C,MAAM,OAAO,GAAG;IACd,WAAW,EAAE;QACX,KAAK,EAAE,aAAa;QACpB,KAAK,EAAE,CACL,cACE,OAAO,EAAC,WAAW,EACnB,SAAS,EAAC,iBAAiB,EAC3B,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAE,IAAI,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,iCAGtB,eAAM,CAAC,EAAE,SAAS,GAAI,GAClB,CACP;KACF;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,sBAAsB;QAC7B,kEAAkE;QAClE,KAAK,EAAE,eAAM,SAAS,EAAC,iBAAiB,6BAAU;KACnD;CACO,CAAA;AAEV,SAAS,UAAU,CAAC,EAAE,MAAM,EAAiC;IAC3D,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;QAC7C,OAAO,CACL,gBACE,IAAI,EAAC,KAAK,gBACE,GAAG,WAAW,CAAC,KAAK,QAAQ,YAAY,CAAC,KAAK,EAAE,EAC5D,SAAS,EAAC,gBAAgB,aAE1B,eAAM,SAAS,EAAC,iCAAiC,YAC9C,WAAW,CAAC,KAAK,GACb,EACP,eAAM,SAAS,EAAC,kCAAkC,YAC/C,YAAY,CAAC,KAAK,GACd,IACF,CACR,C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GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EACrC,cAAc,EAAE,GAAG,EAAE;YACnB,OAAO,EAAE,CAAA;YACT,UAAU,CAAC,IAAI,CAAC,CAAA;YAChB,YAAY,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC,EACD,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;YACvB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,aAA4B,CAAC;gBACnE,UAAU,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC,aAEA,IAAI,EAAE,EAGN,QAAQ,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,IACnE,CACP,CAAA;AACH,CAAC"}
|
package/dist/tools/theme.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ export declare function useTheme(): {
|
|
|
9
9
|
theme: Theme;
|
|
10
10
|
setTheme: typeof write;
|
|
11
11
|
};
|
|
12
|
-
/** A button
|
|
12
|
+
/** A round button fixed at the bottom of the viewport: the current theme's
|
|
13
|
+
* icon, its name on hover or focus, and a click to the next of system, light,
|
|
14
|
+
* dark. Render it once per page, from the layout; hydrate it alone. */
|
|
13
15
|
export declare function ThemeToggle({ className }: {
|
|
14
16
|
className?: string;
|
|
15
17
|
}): import("react").JSX.Element;
|
package/dist/tools/theme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useSyncExternalStore } from 'react';
|
|
3
3
|
import { cn } from './cn.js';
|
|
4
4
|
const KEY = 'mc-theme';
|
|
@@ -45,9 +45,24 @@ const NEXT = {
|
|
|
45
45
|
light: 'dark',
|
|
46
46
|
dark: 'system',
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
const NAMES = {
|
|
49
|
+
system: 'System',
|
|
50
|
+
light: 'Light',
|
|
51
|
+
dark: 'Dark',
|
|
52
|
+
};
|
|
53
|
+
/** Lucide's `monitor`, `sun` and `moon` on a 24-unit square, under the ISC
|
|
54
|
+
* license in LICENSES/ISC.txt. */
|
|
55
|
+
const ICONS = {
|
|
56
|
+
system: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2" }), _jsx("path", { d: "M8 21h8M12 17v4" })] })),
|
|
57
|
+
light: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "12", cy: "12", r: "4" }), _jsx("path", { d: "M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41" })] })),
|
|
58
|
+
dark: _jsx("path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" }),
|
|
59
|
+
};
|
|
60
|
+
/** A round button fixed at the bottom of the viewport: the current theme's
|
|
61
|
+
* icon, its name on hover or focus, and a click to the next of system, light,
|
|
62
|
+
* dark. Render it once per page, from the layout; hydrate it alone. */
|
|
49
63
|
export function ThemeToggle({ className }) {
|
|
50
64
|
const { theme, setTheme } = useTheme();
|
|
51
|
-
|
|
65
|
+
const name = NAMES[theme];
|
|
66
|
+
return (_jsxs("button", { type: "button", className: cn('mc-theme-toggle', className), "aria-label": `Theme: ${name}. Switch to ${NAMES[NEXT[theme]]}`, onClick: () => setTheme(NEXT[theme]), children: [_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: ICONS[theme] }), _jsx("span", { className: "mc-theme-toggle-name", children: name })] }));
|
|
52
67
|
}
|
|
53
68
|
//# sourceMappingURL=theme.js.map
|
package/dist/tools/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/tools/theme.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/tools/theme.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAkB,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAK5B,MAAM,GAAG,GAAG,UAAU,CAAA;AAEtB;yEACyE;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG,kCAAkC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,mFAAmF,CAAA;AAEnK,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AAEvC,SAAS,SAAS,CAAC,QAAoB;IACrC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACvB,OAAO,GAAG,EAAE,CAAC,KAAK,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC9C,CAAC;AAED,2EAA2E;AAC3E,SAAS,IAAI;IACX,MAAM,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAA;IAClD,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC7B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;YACzB,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,QAAQ,CAAA;AAChB,CAAC;AAED,SAAS,KAAK,CAAC,KAAY;IACzB,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAA;IACrC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACtC,IAAI,KAAK,KAAK,QAAQ;QAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACjD,IAAI,CAAC;QACH,IAAI,KAAK,KAAK,QAAQ;YAAE,YA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AK,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAAA;IACtC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;IACzB,OAAO,CACL,kBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,gBAC/B,UAAU,IAAI,eAAe,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAC7D,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,aAEpC,cACE,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,YAEjB,KAAK,CAAC,KAAK,CAAC,GACT,EACN,eAAM,SAAS,EAAC,sBAAsB,YAAE,IAAI,GAAQ,IAC7C,CACV,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metacensus/library-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "MetaCensus brand layer and UI tools for React.",
|
|
5
5
|
"license": "AGPL-3.0-only AND LicenseRef-MetaCensus-Marks",
|
|
6
6
|
"repository": {
|
|
@@ -56,7 +56,8 @@
|
|
|
56
56
|
"pdfjs-dist": "6.5.438"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"react": "^18.3.1"
|
|
59
|
+
"react": "^18.3.1",
|
|
60
|
+
"react-dom": "^18.3.1"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
63
|
"@axe-core/playwright": "^4.14.0",
|
package/src/css/styles.css
CHANGED
|
@@ -321,19 +321,244 @@
|
|
|
321
321
|
font-size: 0.875rem;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
/* Theme toggle
|
|
324
|
+
/* Theme toggle: a round icon button fixed at the viewport's bottom corner
|
|
325
|
+
that widens to show the theme's name on hover or focus. */
|
|
325
326
|
.mc-theme-toggle {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
position: fixed;
|
|
328
|
+
inset-block-end: 1rem;
|
|
329
|
+
inset-inline-end: 1rem;
|
|
330
|
+
z-index: 40;
|
|
331
|
+
display: inline-flex;
|
|
332
|
+
align-items: center;
|
|
333
|
+
min-width: 2.75rem;
|
|
334
|
+
height: 2.75rem;
|
|
335
|
+
padding: 0 0.6875rem;
|
|
336
|
+
border: 1px solid var(--mc-hairline);
|
|
337
|
+
border-radius: 999px;
|
|
338
|
+
background: var(--mc-card);
|
|
330
339
|
color: var(--mc-ink);
|
|
340
|
+
box-shadow: 0 2px 8px color-mix(in srgb, var(--mc-ink) 20%, transparent);
|
|
331
341
|
font: inherit;
|
|
342
|
+
font-weight: 500;
|
|
332
343
|
white-space: nowrap;
|
|
333
344
|
cursor: pointer;
|
|
334
345
|
}
|
|
346
|
+
.mc-theme-toggle svg {
|
|
347
|
+
flex: none;
|
|
348
|
+
width: 1.25rem;
|
|
349
|
+
height: 1.25rem;
|
|
350
|
+
}
|
|
351
|
+
.mc-theme-toggle-name {
|
|
352
|
+
max-width: 0;
|
|
353
|
+
overflow: hidden;
|
|
354
|
+
transition:
|
|
355
|
+
max-width 200ms ease,
|
|
356
|
+
margin 200ms ease;
|
|
357
|
+
}
|
|
358
|
+
.mc-theme-toggle:hover .mc-theme-toggle-name,
|
|
359
|
+
.mc-theme-toggle:focus-visible .mc-theme-toggle-name {
|
|
360
|
+
max-width: 4rem;
|
|
361
|
+
margin-inline: 0.5rem 0.25rem;
|
|
362
|
+
}
|
|
335
363
|
.mc-theme-toggle:focus-visible {
|
|
336
364
|
outline: 2px solid var(--mc-ink-accent);
|
|
337
365
|
outline-offset: 2px;
|
|
338
366
|
}
|
|
367
|
+
@media (prefers-reduced-motion: reduce) {
|
|
368
|
+
.mc-theme-toggle-name {
|
|
369
|
+
transition: none;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/* The footer's last line stays clear of the toggle at the page's end. */
|
|
373
|
+
:root:has(.mc-theme-toggle) .mc-footer {
|
|
374
|
+
padding-block-end: 5rem;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/* Audience icon. */
|
|
378
|
+
.mc-audience-icon {
|
|
379
|
+
display: inline-block;
|
|
380
|
+
flex-shrink: 0;
|
|
381
|
+
width: 1.5em;
|
|
382
|
+
height: 1.5em;
|
|
383
|
+
vertical-align: middle;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/* Contributor card: a fixed footprint the floating card grows out of. */
|
|
387
|
+
.mc-contributor-shell {
|
|
388
|
+
position: relative;
|
|
389
|
+
flex-shrink: 0;
|
|
390
|
+
width: 18rem;
|
|
391
|
+
height: 12rem;
|
|
392
|
+
}
|
|
393
|
+
.mc-contributor {
|
|
394
|
+
--mc-contributor-shade: color-mix(in srgb, black 10%, transparent);
|
|
395
|
+
display: flex;
|
|
396
|
+
flex-direction: column;
|
|
397
|
+
justify-content: center;
|
|
398
|
+
box-sizing: border-box;
|
|
399
|
+
padding: 1rem;
|
|
400
|
+
border: 1px solid color-mix(in oklab, var(--mc-hairline) 70%, transparent);
|
|
401
|
+
border-radius: 0.75rem;
|
|
402
|
+
background: var(--mc-card);
|
|
403
|
+
box-shadow: 0 1px 2px 0 color-mix(in srgb, black 5%, transparent);
|
|
404
|
+
color: var(--mc-ink);
|
|
405
|
+
}
|
|
406
|
+
.mc-contributor-with-bio {
|
|
407
|
+
justify-content: normal;
|
|
408
|
+
gap: 0.5rem;
|
|
409
|
+
}
|
|
410
|
+
.mc-contributor-resting {
|
|
411
|
+
position: absolute;
|
|
412
|
+
inset: 0 0 auto;
|
|
413
|
+
z-index: 10;
|
|
414
|
+
height: 100%;
|
|
415
|
+
overflow: hidden;
|
|
416
|
+
}
|
|
417
|
+
.mc-contributor-floating {
|
|
418
|
+
position: fixed;
|
|
419
|
+
min-height: 12rem;
|
|
420
|
+
border-color: color-mix(in oklab, var(--mc-ink) 40%, transparent);
|
|
421
|
+
box-shadow:
|
|
422
|
+
0 20px 25px -5px var(--mc-contributor-shade),
|
|
423
|
+
0 8px 10px -6px var(--mc-contributor-shade);
|
|
424
|
+
}
|
|
425
|
+
.mc-contributor-flavor {
|
|
426
|
+
position: absolute;
|
|
427
|
+
top: 0.625rem;
|
|
428
|
+
right: 0.625rem;
|
|
429
|
+
}
|
|
430
|
+
.mc-contributor-head {
|
|
431
|
+
display: flex;
|
|
432
|
+
align-items: center;
|
|
433
|
+
gap: 0.75rem;
|
|
434
|
+
}
|
|
435
|
+
.mc-contributor-photo {
|
|
436
|
+
flex-shrink: 0;
|
|
437
|
+
width: 3rem;
|
|
438
|
+
height: 3rem;
|
|
439
|
+
border-radius: 9999px;
|
|
440
|
+
box-shadow: 0 0 0 1px var(--mc-hairline);
|
|
441
|
+
object-fit: cover;
|
|
442
|
+
}
|
|
443
|
+
.mc-contributor-initials {
|
|
444
|
+
display: flex;
|
|
445
|
+
align-items: center;
|
|
446
|
+
justify-content: center;
|
|
447
|
+
background: var(--mc-surface);
|
|
448
|
+
font-size: 0.75rem;
|
|
449
|
+
font-weight: 600;
|
|
450
|
+
line-height: 1rem;
|
|
451
|
+
text-transform: uppercase;
|
|
452
|
+
}
|
|
453
|
+
.mc-contributor-names {
|
|
454
|
+
min-width: 0;
|
|
455
|
+
}
|
|
456
|
+
/* Clear of the flavor chip in the corner. */
|
|
457
|
+
.mc-contributor-names-1 {
|
|
458
|
+
padding-right: 1.75rem;
|
|
459
|
+
}
|
|
460
|
+
.mc-contributor-names-2 {
|
|
461
|
+
padding-right: 3.5rem;
|
|
462
|
+
}
|
|
463
|
+
.mc-contributor-name {
|
|
464
|
+
margin: 0;
|
|
465
|
+
font-size: 0.875rem;
|
|
466
|
+
font-weight: 600;
|
|
467
|
+
line-height: 1.25;
|
|
468
|
+
letter-spacing: -0.025em;
|
|
469
|
+
}
|
|
470
|
+
.mc-contributor-name a {
|
|
471
|
+
color: inherit;
|
|
472
|
+
text-decoration: none;
|
|
473
|
+
text-underline-offset: 4px;
|
|
474
|
+
}
|
|
475
|
+
.mc-contributor-name a:hover {
|
|
476
|
+
text-decoration: underline;
|
|
477
|
+
}
|
|
478
|
+
.mc-contributor-role {
|
|
479
|
+
margin: 0.125rem 0 0;
|
|
480
|
+
font-size: 0.75rem;
|
|
481
|
+
font-weight: 500;
|
|
482
|
+
line-height: 1.375;
|
|
483
|
+
}
|
|
484
|
+
.mc-contributor-title {
|
|
485
|
+
color: var(--mc-ink-accent);
|
|
486
|
+
font-weight: 600;
|
|
487
|
+
}
|
|
488
|
+
.mc-contributor-bio {
|
|
489
|
+
font-size: 0.78125rem;
|
|
490
|
+
line-height: 1.375;
|
|
491
|
+
}
|
|
492
|
+
.mc-contributor-bio > p {
|
|
493
|
+
margin: 0;
|
|
494
|
+
}
|
|
495
|
+
.mc-contributor-resting .mc-contributor-bio > p {
|
|
496
|
+
display: -webkit-box;
|
|
497
|
+
overflow: hidden;
|
|
498
|
+
-webkit-box-orient: vertical;
|
|
499
|
+
-webkit-line-clamp: 6;
|
|
500
|
+
}
|
|
501
|
+
.mc-contributor-bio a {
|
|
502
|
+
color: inherit;
|
|
503
|
+
font-weight: 500;
|
|
504
|
+
text-decoration: underline;
|
|
505
|
+
text-underline-offset: 2px;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/* Flavor chips: a family's tint, the pair drawn as one object. */
|
|
509
|
+
.mc-flavor {
|
|
510
|
+
display: flex;
|
|
511
|
+
align-items: center;
|
|
512
|
+
justify-content: center;
|
|
513
|
+
box-sizing: border-box;
|
|
514
|
+
width: 1.75rem;
|
|
515
|
+
height: 1.75rem;
|
|
516
|
+
border: 2px solid currentColor;
|
|
517
|
+
border-radius: 0.5rem;
|
|
518
|
+
}
|
|
519
|
+
.mc-flavor-engineering {
|
|
520
|
+
background: var(--mc-tint-red-fill);
|
|
521
|
+
color: var(--mc-tint-red-ink);
|
|
522
|
+
}
|
|
523
|
+
.mc-flavor-quantitative {
|
|
524
|
+
background: var(--mc-tint-blue-fill);
|
|
525
|
+
color: var(--mc-tint-blue-ink);
|
|
526
|
+
}
|
|
527
|
+
.mc-flavor-pair {
|
|
528
|
+
display: flex;
|
|
529
|
+
}
|
|
530
|
+
.mc-flavor-pair > :first-child {
|
|
531
|
+
border-right: 0;
|
|
532
|
+
border-radius: 0.5rem 0 0 0.5rem;
|
|
533
|
+
}
|
|
534
|
+
.mc-flavor-pair > :last-child {
|
|
535
|
+
border-left: 0;
|
|
536
|
+
border-radius: 0 0.5rem 0.5rem 0;
|
|
537
|
+
}
|
|
538
|
+
.mc-flavor-glyph {
|
|
539
|
+
width: 1rem;
|
|
540
|
+
height: 1rem;
|
|
541
|
+
}
|
|
542
|
+
.mc-flavor-sigma {
|
|
543
|
+
font-size: 0.84375rem;
|
|
544
|
+
font-weight: 600;
|
|
545
|
+
line-height: 1;
|
|
546
|
+
letter-spacing: -0.025em;
|
|
547
|
+
}
|
|
548
|
+
.mc-flavor-key {
|
|
549
|
+
display: flex;
|
|
550
|
+
flex-wrap: wrap;
|
|
551
|
+
gap: 0.75rem 1.5rem;
|
|
552
|
+
margin: 0;
|
|
553
|
+
padding: 0;
|
|
554
|
+
list-style: none;
|
|
555
|
+
color: var(--mc-ink);
|
|
556
|
+
font-size: 0.875rem;
|
|
557
|
+
line-height: 1.25rem;
|
|
558
|
+
}
|
|
559
|
+
.mc-flavor-key li {
|
|
560
|
+
display: flex;
|
|
561
|
+
align-items: center;
|
|
562
|
+
gap: 0.5rem;
|
|
563
|
+
}
|
|
339
564
|
}
|