react-cheminfo 0.34.0 → 0.35.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 +28 -28
- package/lib/about/core/about.d.ts +1 -30
- package/lib/about/core/about.d.ts.map +1 -1
- package/lib/about/core/about.js +0 -16
- package/lib/about/core/about.js.map +1 -1
- package/lib/about/core/index.d.ts +0 -1
- package/lib/about/core/index.d.ts.map +1 -1
- package/lib/about/core/index.js +0 -1
- package/lib/about/core/index.js.map +1 -1
- package/lib/about/ui/AboutBuild.d.ts +2 -5
- package/lib/about/ui/AboutBuild.d.ts.map +1 -1
- package/lib/about/ui/AboutBuild.js +7 -19
- package/lib/about/ui/AboutBuild.js.map +1 -1
- package/lib/about/ui/AboutPage.d.ts +2 -2
- package/lib/about/ui/AboutPage.d.ts.map +1 -1
- package/lib/about/ui/AboutPage.js +3 -14
- package/lib/about/ui/AboutPage.js.map +1 -1
- package/lib/about/ui/AboutVersion.d.ts +0 -4
- package/lib/about/ui/AboutVersion.d.ts.map +1 -1
- package/lib/about/ui/AboutVersion.js +3 -31
- package/lib/about/ui/AboutVersion.js.map +1 -1
- package/lib/download/core/index.d.ts +0 -5
- package/lib/download/core/index.d.ts.map +1 -1
- package/lib/download/core/index.js +0 -3
- package/lib/download/core/index.js.map +1 -1
- package/lib/download/ui/FigureDownload.d.ts +4 -55
- package/lib/download/ui/FigureDownload.d.ts.map +1 -1
- package/lib/download/ui/FigureDownload.js +6 -66
- package/lib/download/ui/FigureDownload.js.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.d.ts +16 -2
- package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.js +11 -30
- package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
- package/lib/download/ui/figureDownloadHint.d.ts +30 -0
- package/lib/download/ui/figureDownloadHint.d.ts.map +1 -0
- package/lib/download/ui/figureDownloadHint.js +33 -0
- package/lib/download/ui/figureDownloadHint.js.map +1 -0
- package/lib/download/ui/index.d.ts +3 -10
- package/lib/download/ui/index.d.ts.map +1 -1
- package/lib/download/ui/index.js +1 -5
- package/lib/download/ui/index.js.map +1 -1
- package/lib/download/ui/useFigureActions.d.ts +50 -0
- package/lib/download/ui/useFigureActions.d.ts.map +1 -0
- package/lib/download/ui/useFigureActions.js +58 -0
- package/lib/download/ui/useFigureActions.js.map +1 -0
- package/lib/download/ui/useFigureDownload.d.ts +85 -0
- package/lib/download/ui/useFigureDownload.d.ts.map +1 -0
- package/lib/download/ui/useFigureDownload.js +75 -0
- package/lib/download/ui/useFigureDownload.js.map +1 -0
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js +0 -40
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/core/types.d.ts +0 -10
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/ir/core/irCommands.d.ts +2 -2
- package/lib/ir/core/irCommands.js +2 -2
- package/lib/ir/core/irCommands.js.map +1 -1
- package/lib/ir/ui/IrAboutDialog.d.ts.map +1 -1
- package/lib/ir/ui/IrAboutDialog.js +1 -1
- package/lib/ir/ui/IrAboutDialog.js.map +1 -1
- package/lib/ir/ui/IrCanvas.d.ts +6 -0
- package/lib/ir/ui/IrCanvas.d.ts.map +1 -1
- package/lib/ir/ui/IrCanvas.js +2 -2
- package/lib/ir/ui/IrCanvas.js.map +1 -1
- package/lib/ir/ui/IrShell.d.ts.map +1 -1
- package/lib/ir/ui/IrShell.js +16 -11
- package/lib/ir/ui/IrShell.js.map +1 -1
- package/lib/ir/ui/IrToolbar.d.ts +11 -1
- package/lib/ir/ui/IrToolbar.d.ts.map +1 -1
- package/lib/ir/ui/IrToolbar.js +12 -2
- package/lib/ir/ui/IrToolbar.js.map +1 -1
- package/lib/ir/ui/index.d.ts +1 -0
- package/lib/ir/ui/index.d.ts.map +1 -1
- package/lib/ir/ui/index.js.map +1 -1
- package/lib/locales/de.json +2 -4
- package/lib/locales/en.json +2 -4
- package/lib/locales/es.json +2 -4
- package/lib/locales/fr.json +2 -4
- package/lib/locales/it.json +2 -4
- package/lib/overlay/ui/OverlayPanel.d.ts +6 -0
- package/lib/overlay/ui/OverlayPanel.d.ts.map +1 -1
- package/lib/overlay/ui/OverlayPanel.js +2 -2
- package/lib/overlay/ui/OverlayPanel.js.map +1 -1
- package/lib/overlay/ui/overlayPanelStyles.d.ts +2 -1
- package/lib/overlay/ui/overlayPanelStyles.d.ts.map +1 -1
- package/lib/overlay/ui/overlayPanelStyles.js +3 -1
- package/lib/overlay/ui/overlayPanelStyles.js.map +1 -1
- package/lib/periodic/ui/ElementCell.d.ts +0 -6
- package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
- package/lib/periodic/ui/ElementCell.js +34 -30
- package/lib/periodic/ui/ElementCell.js.map +1 -1
- package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTable.js +12 -15
- package/lib/periodic/ui/PeriodicTable.js.map +1 -1
- package/package.json +1 -1
- package/src/about/core/about.ts +1 -51
- package/src/about/core/index.ts +0 -1
- package/src/about/ui/AboutBuild.tsx +8 -37
- package/src/about/ui/AboutPage.tsx +8 -64
- package/src/about/ui/AboutVersion.tsx +5 -45
- package/src/download/core/index.ts +0 -25
- package/src/download/ui/FigureDownload.tsx +11 -148
- package/src/download/ui/FigureDownloadPanel.tsx +46 -45
- package/src/download/ui/figureDownloadHint.ts +52 -0
- package/src/download/ui/index.ts +6 -10
- package/src/download/ui/useFigureActions.ts +113 -0
- package/src/download/ui/useFigureDownload.tsx +191 -0
- package/src/ecosystem/core/sites.ts +0 -40
- package/src/ecosystem/core/types.ts +0 -10
- package/src/ir/core/irCommands.ts +2 -2
- package/src/ir/ui/IrAboutDialog.tsx +0 -13
- package/src/ir/ui/IrCanvas.tsx +8 -2
- package/src/ir/ui/IrShell.tsx +23 -25
- package/src/ir/ui/IrToolbar.tsx +36 -6
- package/src/ir/ui/index.ts +1 -0
- package/src/locales/de.json +2 -4
- package/src/locales/en.json +2 -4
- package/src/locales/es.json +2 -4
- package/src/locales/fr.json +2 -4
- package/src/locales/it.json +2 -4
- package/src/overlay/ui/OverlayPanel.tsx +8 -2
- package/src/overlay/ui/overlayPanelStyles.ts +3 -0
- package/src/periodic/ui/ElementCell.tsx +34 -37
- package/src/periodic/ui/PeriodicTable.tsx +12 -17
- package/lib/about/core/repository.d.ts +0 -14
- package/lib/about/core/repository.d.ts.map +0 -1
- package/lib/about/core/repository.js +0 -21
- package/lib/about/core/repository.js.map +0 -1
- package/lib/download/core/exportStyles.d.ts +0 -22
- package/lib/download/core/exportStyles.d.ts.map +0 -1
- package/lib/download/core/exportStyles.js +0 -19
- package/lib/download/core/exportStyles.js.map +0 -1
- package/lib/download/core/imageResolution.d.ts +0 -88
- package/lib/download/core/imageResolution.d.ts.map +0 -1
- package/lib/download/core/imageResolution.js +0 -77
- package/lib/download/core/imageResolution.js.map +0 -1
- package/lib/download/core/pictureExport.d.ts +0 -93
- package/lib/download/core/pictureExport.d.ts.map +0 -1
- package/lib/download/core/pictureExport.js +0 -116
- package/lib/download/core/pictureExport.js.map +0 -1
- package/lib/download/ui/ExportDialogFrame.d.ts +0 -46
- package/lib/download/ui/ExportDialogFrame.d.ts.map +0 -1
- package/lib/download/ui/ExportDialogFrame.js +0 -24
- package/lib/download/ui/ExportDialogFrame.js.map +0 -1
- package/lib/download/ui/ExportImageDialog.d.ts +0 -47
- package/lib/download/ui/ExportImageDialog.d.ts.map +0 -1
- package/lib/download/ui/ExportImageDialog.js +0 -25
- package/lib/download/ui/ExportImageDialog.js.map +0 -1
- package/lib/download/ui/ExportNameField.d.ts +0 -29
- package/lib/download/ui/ExportNameField.d.ts.map +0 -1
- package/lib/download/ui/ExportNameField.js +0 -99
- package/lib/download/ui/ExportNameField.js.map +0 -1
- package/lib/download/ui/ExportPictureSection.d.ts +0 -38
- package/lib/download/ui/ExportPictureSection.d.ts.map +0 -1
- package/lib/download/ui/ExportPictureSection.js +0 -48
- package/lib/download/ui/ExportPictureSection.js.map +0 -1
- package/lib/download/ui/useDrawingBox.d.ts +0 -23
- package/lib/download/ui/useDrawingBox.d.ts.map +0 -1
- package/lib/download/ui/useDrawingBox.js +0 -21
- package/lib/download/ui/useDrawingBox.js.map +0 -1
- package/src/about/core/repository.ts +0 -22
- package/src/download/core/exportStyles.ts +0 -20
- package/src/download/core/imageResolution.ts +0 -118
- package/src/download/core/pictureExport.ts +0 -207
- package/src/download/ui/ExportDialogFrame.tsx +0 -86
- package/src/download/ui/ExportImageDialog.tsx +0 -91
- package/src/download/ui/ExportNameField.tsx +0 -148
- package/src/download/ui/ExportPictureSection.tsx +0 -142
- package/src/download/ui/useDrawingBox.ts +0 -37
|
@@ -7,7 +7,7 @@ import { useChromeT } from "../../i18n/ui/useT.js";
|
|
|
7
7
|
* @returns The cell.
|
|
8
8
|
*/
|
|
9
9
|
export function ElementCell(props) {
|
|
10
|
-
const { className, atomicNumber, symbol, name, swatch, column, row, onSelect, detail = '',
|
|
10
|
+
const { className, atomicNumber, symbol, name, swatch, column, row, onSelect, detail = '', isSelected = false, isIncluded = true, onHover, } = props;
|
|
11
11
|
const t = useChromeT();
|
|
12
12
|
const [isHovered, setIsHovered] = useState(false);
|
|
13
13
|
return (_jsxs("button", { type: "button", className: className, "data-testid": `element-${symbol}`, "data-symbol": symbol, title: detail === '' ? name : `${name} · ${detail}`, "aria-label": t('periodic.cellLabel', {
|
|
@@ -41,7 +41,7 @@ export function ElementCell(props) {
|
|
|
41
41
|
filter: isHovered ? 'brightness(1.08)' : undefined,
|
|
42
42
|
}, children: [_jsx("span", { style: numberStyle, children: atomicNumber }), _jsx("span", { style: {
|
|
43
43
|
...symbolStyle,
|
|
44
|
-
fontSize: symbolFontSize(symbol
|
|
44
|
+
fontSize: symbolFontSize(symbol),
|
|
45
45
|
}, children: symbol }), detail === '' ? null : (_jsx("span", { style: { ...detailStyle, fontSize: detailFontSize(detail) }, children: detail }))] }));
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -51,12 +51,10 @@ export function ElementCell(props) {
|
|
|
51
51
|
* ones whose second letter is an `m` — which are written a tenth smaller
|
|
52
52
|
* rather than run into the edges of their cell.
|
|
53
53
|
* @param symbol - The chemical symbol.
|
|
54
|
-
* @param writesDetail - Whether the table writes a third line under it.
|
|
55
54
|
* @returns A CSS length.
|
|
56
55
|
*/
|
|
57
|
-
function symbolFontSize(symbol
|
|
58
|
-
|
|
59
|
-
return fitted(symbolWidthInEm(symbol), cap, '0.5rem');
|
|
56
|
+
function symbolFontSize(symbol) {
|
|
57
|
+
return fitted(symbolWidthInEm(symbol), SYMBOL_CQW, '0.5rem');
|
|
60
58
|
}
|
|
61
59
|
/**
|
|
62
60
|
* The size the third line takes so the whole of it is written.
|
|
@@ -121,60 +119,66 @@ function detailWidthInEm(detail) {
|
|
|
121
119
|
const TABULAR_EM = 0.6;
|
|
122
120
|
/** The size the symbol is written at wherever it fits, as a share of the table. */
|
|
123
121
|
const SYMBOL_CQW = '2.4cqw';
|
|
124
|
-
/** The same, in a table that writes nothing under the symbol. */
|
|
125
|
-
const SYMBOL_ALONE_CQW = '2.8cqw';
|
|
126
122
|
/**
|
|
127
123
|
* The tallest the third line is ever written, as a share of the table.
|
|
128
124
|
*
|
|
129
|
-
* Close to
|
|
130
|
-
*
|
|
131
|
-
*
|
|
125
|
+
* Close to two thirds of the symbol: the symbol is how a cell is found, but
|
|
126
|
+
* the value is what the table is being read for, and a value half the size of
|
|
127
|
+
* the symbol is the one thing on the cell a class cannot make out.
|
|
132
128
|
*/
|
|
133
|
-
const DETAIL_CQW = '1.
|
|
129
|
+
const DETAIL_CQW = '1.6cqw';
|
|
130
|
+
/**
|
|
131
|
+
* The band at each end of a cell: the atomic number at the top, whatever the
|
|
132
|
+
* tool writes at the bottom.
|
|
133
|
+
*
|
|
134
|
+
* They are one length, not two, and that is what makes the symbol between them
|
|
135
|
+
* sit at the centre of the cell rather than near it — a bottom band wider than
|
|
136
|
+
* the top one by a third lifted every symbol in the table two pixels.
|
|
137
|
+
*/
|
|
138
|
+
const EDGE_BAND = '1.8cqw';
|
|
134
139
|
/** How wide one column is, as a share of the table's width. */
|
|
135
140
|
const CELL_CQW = '4.85cqw';
|
|
136
141
|
/** What the border and the padding of a cell take off that width. */
|
|
137
142
|
const CELL_CHROME = '4px';
|
|
143
|
+
/**
|
|
144
|
+
* A cell is three bands of its own, and every cell has all three.
|
|
145
|
+
*
|
|
146
|
+
* The atomic number is in the top band, against its left edge; the symbol is
|
|
147
|
+
* centred in the middle one; whatever the tool writes is centred in the
|
|
148
|
+
* bottom one. The bands keep their height whether or not anything is written
|
|
149
|
+
* in the last of them, so a number sits at one height across the whole table
|
|
150
|
+
* and a symbol at one other — before this, both rode on a stack the cell
|
|
151
|
+
* centred and moved whenever a neighbour's value was written smaller.
|
|
152
|
+
*/
|
|
138
153
|
const cellStyle = {
|
|
139
|
-
alignItems: 'center',
|
|
140
154
|
border: '1px solid rgb(255 255 255 / 0.55)',
|
|
141
155
|
borderRadius: 3,
|
|
142
156
|
cursor: 'pointer',
|
|
143
|
-
display: '
|
|
144
|
-
flexDirection: 'column',
|
|
157
|
+
display: 'grid',
|
|
145
158
|
font: 'inherit',
|
|
146
|
-
|
|
159
|
+
gridTemplateRows: `${EDGE_BAND} 1fr ${EDGE_BAND}`,
|
|
160
|
+
justifyItems: 'center',
|
|
147
161
|
minWidth: 0,
|
|
148
162
|
overflow: 'hidden',
|
|
149
163
|
padding: '1px',
|
|
150
|
-
// The corner the atomic number is pinned into.
|
|
151
|
-
position: 'relative',
|
|
152
164
|
transition: 'opacity 120ms ease, filter 120ms ease',
|
|
153
165
|
};
|
|
154
|
-
/**
|
|
155
|
-
* The atomic number sits out of the flow, in the corner.
|
|
156
|
-
*
|
|
157
|
-
* In the flow it rode on top of a stack the cell centres, so it moved down
|
|
158
|
-
* whenever what is written under the symbol was written smaller — the numbers
|
|
159
|
-
* of a row then sat at as many heights as the row had word lengths. Out of it,
|
|
160
|
-
* the number is in the same corner of every cell, and the symbol is centred in
|
|
161
|
-
* the cell rather than in what is left of it.
|
|
162
|
-
*/
|
|
163
166
|
const numberStyle = {
|
|
167
|
+
alignSelf: 'start',
|
|
164
168
|
fontSize: 'max(0.33rem, 1.1cqw)',
|
|
165
169
|
fontVariantNumeric: 'tabular-nums',
|
|
166
|
-
|
|
170
|
+
justifySelf: 'start',
|
|
167
171
|
lineHeight: 1,
|
|
168
172
|
opacity: 0.8,
|
|
169
|
-
position: 'absolute',
|
|
170
|
-
top: 'max(1px, 0.14cqw)',
|
|
171
173
|
};
|
|
172
174
|
const symbolStyle = {
|
|
175
|
+
alignSelf: 'center',
|
|
173
176
|
fontWeight: 700,
|
|
174
177
|
letterSpacing: '-0.02em',
|
|
175
178
|
lineHeight: 1.02,
|
|
176
179
|
};
|
|
177
180
|
const detailStyle = {
|
|
181
|
+
alignSelf: 'center',
|
|
178
182
|
fontVariantNumeric: 'tabular-nums',
|
|
179
183
|
lineHeight: 1,
|
|
180
184
|
maxWidth: '100%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementCell.js","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ElementCell.js","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AA8CnD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,MAAM,EACJ,SAAS,EACT,YAAY,EACZ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pC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;IAChD;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;IAChD;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;IAC9C;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC;IACnD;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC9C;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CA6ErE"}
|
|
@@ -14,7 +14,6 @@ import { HeaderStrips, InnerTransitionMarkers, } from "./PeriodicTableChrome.js"
|
|
|
14
14
|
export function PeriodicTable(props) {
|
|
15
15
|
const { selected, onSelect, swatchOf = defaultSwatchOf, detailOf, nameOf = defaultNameOf, isIncluded, inset, headers = false, onSelectRange, legend = false, markers = true, keyboard = true, onHover, className, } = props;
|
|
16
16
|
const t = useChromeT();
|
|
17
|
-
const writesDetail = detailOf !== undefined;
|
|
18
17
|
const gridRef = useRef(null);
|
|
19
18
|
const cameFromKeyRef = useRef(false);
|
|
20
19
|
const offset = headers ? 1 : 0;
|
|
@@ -36,7 +35,7 @@ export function PeriodicTable(props) {
|
|
|
36
35
|
cameFromKeyRef.current = true;
|
|
37
36
|
onSelect(next.symbol);
|
|
38
37
|
}
|
|
39
|
-
return (_jsxs("div", { className: className, style: rootStyle, children: [_jsxs("div", { ref: gridRef, role: "grid", "aria-label": t('periodic.table'), "data-testid": "periodic-table", style: gridStyle(headers
|
|
38
|
+
return (_jsxs("div", { className: className, style: rootStyle, children: [_jsxs("div", { ref: gridRef, role: "grid", "aria-label": t('periodic.table'), "data-testid": "periodic-table", style: gridStyle(headers), onKeyDown: handleKeyDown, children: [headers ? _jsx(HeaderStrips, { onSelectRange: onSelectRange }) : null, inset === undefined ? null : (_jsx("div", { style: insetStyle(offset), children: inset })), markers ? _jsx(InnerTransitionMarkers, { offset: offset }) : null, placedElements().map(({ element, cell }) => (_jsx(ElementCell, { atomicNumber: element.atomicNumber, symbol: element.symbol, name: nameOf(element), detail: detailOf?.(element), swatch: swatchOf(element), isSelected: element.symbol === selected, isIncluded: isIncluded?.(element), column: cell.column + offset, row: cell.row + offset, onSelect: onSelect ?? noop, onHover: onHover }, element.symbol)))] }), legend ? _jsx(CategoryLegend, {}) : null] }));
|
|
40
39
|
}
|
|
41
40
|
/**
|
|
42
41
|
* Where what the caller writes in the empty block is placed.
|
|
@@ -47,8 +46,9 @@ function insetStyle(offset) {
|
|
|
47
46
|
return {
|
|
48
47
|
alignItems: 'center',
|
|
49
48
|
display: 'flex',
|
|
50
|
-
//
|
|
51
|
-
|
|
49
|
+
// A column of air on each side, so the writing reads as sitting in the
|
|
50
|
+
// block rather than as running into the cells beside it.
|
|
51
|
+
padding: '0 2.4cqw',
|
|
52
52
|
gridColumn: `${String(EMPTY_BLOCK.column + offset)} / span ${String(EMPTY_BLOCK.columnSpan)}`,
|
|
53
53
|
gridRow: `${String(EMPTY_BLOCK.row + offset)} / span ${String(EMPTY_BLOCK.rowSpan)}`,
|
|
54
54
|
// A share of the table, with a floor, exactly as a cell sizes its symbol:
|
|
@@ -75,13 +75,13 @@ const MIN_WIDTH = 280;
|
|
|
75
75
|
/**
|
|
76
76
|
* How tall one row of elements is, as a share of the table's width.
|
|
77
77
|
*
|
|
78
|
-
* A column is about 5.
|
|
79
|
-
*
|
|
80
|
-
* cell need to be
|
|
78
|
+
* A column is about 5.2% of that width, so a cell is a third taller than it is
|
|
79
|
+
* wide — the proportion of a wall chart, and the room the three bands of a
|
|
80
|
+
* cell need to be read from the back of a room. It is the same height in every
|
|
81
|
+
* table: a cell keeps the band it writes a value in whether or not that table
|
|
82
|
+
* writes one.
|
|
81
83
|
*/
|
|
82
|
-
const ROW_HEIGHT = '6.
|
|
83
|
-
/** The same, in a table that writes nothing under the symbol. */
|
|
84
|
-
const ROW_HEIGHT_ALONE = '4.9cqw';
|
|
84
|
+
const ROW_HEIGHT = '6.8cqw';
|
|
85
85
|
/** The band the two inner-transition series were lifted out across. */
|
|
86
86
|
const SERIES_GAP = 'max(6px, 1.1cqw)';
|
|
87
87
|
const rootStyle = {
|
|
@@ -104,14 +104,11 @@ const baseGridStyle = {
|
|
|
104
104
|
* The grid the cells are placed on.
|
|
105
105
|
* @param headers - Whether a leading column and row hold the period and group
|
|
106
106
|
* numbers.
|
|
107
|
-
* @param writesDetail - Whether a cell writes a third line, which is what a
|
|
108
|
-
* row is tall enough for.
|
|
109
107
|
* @returns The style of the grid.
|
|
110
108
|
*/
|
|
111
|
-
function gridStyle(headers
|
|
112
|
-
const row = writesDetail ? ROW_HEIGHT : ROW_HEIGHT_ALONE;
|
|
109
|
+
function gridStyle(headers) {
|
|
113
110
|
// The eighth row is the gap the inner-transition series are lifted out into.
|
|
114
|
-
const rows = `repeat(7, ${
|
|
111
|
+
const rows = `repeat(7, ${ROW_HEIGHT}) ${SERIES_GAP} repeat(2, ${ROW_HEIGHT})`;
|
|
115
112
|
if (!headers) {
|
|
116
113
|
return {
|
|
117
114
|
...baseGridStyle,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeriodicTable.js","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,sBAAsB,GACvB,MAAM,0BAA2B,CAAC;AAwFnC;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,eAAe,EAC1B,QAAQ,EACR,MAAM,GAAG,aAAa,EACtB,UAAU,EACV,KAAK,EACL,OAAO,GAAG,KAAK,EACf,aAAa,EACb,MAAM,GAAG,KAAK,EACd,OAAO,GAAG,IAAI,EACd,QAAQ,GAAG,IAAI,EACf,OAAO,EACP,SAAS,GACV,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IACvB,MAAM,
|
|
1
|
+
{"version":3,"file":"PeriodicTable.js","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,cAAc,GACf,MAAM,mBA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;;;GAQG;AACH,MAAM,UAAU,GAAG,QAAQ,CAAC;AAE5B,uEAAuE;AACvE,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAEtC,MAAM,SAAS,GAAG;IAChB,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,QAAQ;IACvB,GAAG,EAAE,CAAC;IACN,QAAQ,EAAE,SAAS;IACnB,6EAA6E;IAC7E,0EAA0E;IAC1E,sEAAsE;IACtE,aAAa,EAAE,aAAa;CACI,CAAC;AAEnC,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,MAAM;IACf,GAAG,EAAE,CAAC;IACN,QAAQ,EAAE,SAAS;IACnB,KAAK,EAAE,MAAM;CACmB,CAAC;AAEnC;;;;;GAKG;AACH,SAAS,SAAS,CAAC,OAAgB;IACjC,6EAA6E;IAC7E,MAAM,IAAI,GAAG,aAAa,UAAU,KAAK,UAAU,cAAc,UAAU,GAAG,CAAC;IAC/E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,GAAG,aAAa;YAChB,mBAAmB,EAAE,UAAU,MAAM,CAAC,YAAY,CAAC,mBAAmB;YACtE,gBAAgB,EAAE,IAAI;SACvB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,GAAG,aAAa;QAChB,mBAAmB,EAAE,4BAA4B,MAAM,CAAC,YAAY,CAAC,mBAAmB;QACxF,gBAAgB,EAAE,mBAAmB,IAAI,EAAE;KAC5C,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cheminfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
|
|
6
6
|
"author": "Luc Patiny",
|
package/src/about/core/about.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { providers } from './providers.ts';
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* What a site says about itself: the one page a visitor opens to find out what
|
|
13
|
-
* the tool is,
|
|
13
|
+
* the tool is, who provides it, and what it stands on.
|
|
14
14
|
*
|
|
15
15
|
* Every field is content, never markup. A site writes this record and the page
|
|
16
16
|
* is drawn from it, which is what keeps fourteen About pages in one order and
|
|
@@ -53,35 +53,12 @@ export interface AboutContent {
|
|
|
53
53
|
* @default undefined
|
|
54
54
|
*/
|
|
55
55
|
providedBy?: readonly ProviderId[];
|
|
56
|
-
/**
|
|
57
|
-
* Licence the site itself is published under.
|
|
58
|
-
* @default 'MIT'
|
|
59
|
-
*/
|
|
60
|
-
license?: string;
|
|
61
|
-
/**
|
|
62
|
-
* Where the sources live.
|
|
63
|
-
* @default the repository of the ECOSYSTEM_SITES record
|
|
64
|
-
*/
|
|
65
|
-
repository?: string;
|
|
66
|
-
/**
|
|
67
|
-
* Whether a visitor can open that repository. A site naming a repository of
|
|
68
|
-
* its own says so here too, since the family's record then describes another
|
|
69
|
-
* one.
|
|
70
|
-
* @default the `publicRepository` of the ECOSYSTEM_SITES record
|
|
71
|
-
*/
|
|
72
|
-
publicRepository?: boolean;
|
|
73
56
|
/**
|
|
74
57
|
* Which build is running, from `react-cheminfo/build-info` — never written
|
|
75
58
|
* by hand, which is what keeps it true after the next release.
|
|
76
59
|
* @default undefined — the site's build does not publish one
|
|
77
60
|
*/
|
|
78
61
|
build?: BuildInfo;
|
|
79
|
-
/**
|
|
80
|
-
* Where a problem is reported: an address a visitor can actually open, so a
|
|
81
|
-
* site whose sources are private names one of its own or says nothing.
|
|
82
|
-
* @default the repository's /issues, and none at all when it is private
|
|
83
|
-
*/
|
|
84
|
-
issues?: string;
|
|
85
62
|
}
|
|
86
63
|
|
|
87
64
|
/** One person who made a site. */
|
|
@@ -114,14 +91,8 @@ export interface ResolvedAbout {
|
|
|
114
91
|
people: readonly AboutPerson[];
|
|
115
92
|
/** The institutions providing the site, empty when the site names none. */
|
|
116
93
|
providedBy: ProviderEntry[];
|
|
117
|
-
license: string;
|
|
118
|
-
repository: string;
|
|
119
|
-
/** Whether a visitor can open the repository, and so whether it is named. */
|
|
120
|
-
publicRepository: boolean;
|
|
121
94
|
/** Which build is running, or `undefined` when the site does not say. */
|
|
122
95
|
build: BuildInfo | undefined;
|
|
123
|
-
/** Where a problem is reported, or `undefined` when there is nowhere open. */
|
|
124
|
-
issues: string | undefined;
|
|
125
96
|
}
|
|
126
97
|
|
|
127
98
|
/**
|
|
@@ -137,10 +108,6 @@ export function resolveAbout(content: AboutContent): ResolvedAbout {
|
|
|
137
108
|
typeof content.siteId === 'string'
|
|
138
109
|
? siteById(content.siteId)
|
|
139
110
|
: content.siteId;
|
|
140
|
-
const repository = content.repository ?? site.repository;
|
|
141
|
-
const publicRepository =
|
|
142
|
-
content.publicRepository ?? site.publicRepository ?? false;
|
|
143
|
-
|
|
144
111
|
return {
|
|
145
112
|
site,
|
|
146
113
|
what: content.what,
|
|
@@ -150,17 +117,7 @@ export function resolveAbout(content: AboutContent): ResolvedAbout {
|
|
|
150
117
|
cite: content.cite ?? [],
|
|
151
118
|
people: content.people ?? [],
|
|
152
119
|
providedBy: providers(content.providedBy ?? []),
|
|
153
|
-
license: content.license ?? DEFAULT_LICENSE,
|
|
154
|
-
repository,
|
|
155
|
-
publicRepository,
|
|
156
120
|
build: content.build,
|
|
157
|
-
// A tracker behind a private repository answers 404 to every visitor, so
|
|
158
|
-
// a site that names none of its own asks for a report nowhere.
|
|
159
|
-
issues:
|
|
160
|
-
content.issues ??
|
|
161
|
-
(publicRepository
|
|
162
|
-
? `${withoutTrailingSlash(repository)}/issues`
|
|
163
|
-
: undefined),
|
|
164
121
|
};
|
|
165
122
|
}
|
|
166
123
|
|
|
@@ -222,16 +179,9 @@ export function aboutProblems(content: AboutContent): string[] {
|
|
|
222
179
|
return problems;
|
|
223
180
|
}
|
|
224
181
|
|
|
225
|
-
/** What a site is published under unless it says otherwise. */
|
|
226
|
-
const DEFAULT_LICENSE = 'MIT';
|
|
227
|
-
|
|
228
182
|
const WHAT_LIMIT = 160;
|
|
229
183
|
const CAN_MIN = 3;
|
|
230
184
|
const CAN_MAX = 6;
|
|
231
185
|
const CAN_LINE_LIMIT = 90;
|
|
232
186
|
const PARAGRAPH_MAX = 2;
|
|
233
187
|
const PARAGRAPH_LIMIT = 400;
|
|
234
|
-
|
|
235
|
-
function withoutTrailingSlash(url: string): string {
|
|
236
|
-
return url.endsWith('/') ? url.slice(0, -1) : url;
|
|
237
|
-
}
|
package/src/about/core/index.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import type { CSSProperties, ReactElement
|
|
1
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import type { BuildInfo } from '../../build/core/buildInfo.ts';
|
|
4
4
|
import { formatBuiltAt, shortCommit } from '../../build/core/buildInfo.ts';
|
|
5
5
|
import { useChromeT } from '../../i18n/ui/useT.ts';
|
|
6
|
-
import { githubSources } from '../core/repository.ts';
|
|
7
6
|
|
|
8
7
|
export interface AboutBuildProps {
|
|
9
8
|
/** What the build published about itself. */
|
|
10
9
|
build: BuildInfo;
|
|
11
|
-
/** Where the sources live, which is what the version and commit link into. */
|
|
12
|
-
repository: string;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
12
|
/**
|
|
@@ -17,23 +14,21 @@ export interface AboutBuildProps {
|
|
|
17
14
|
*
|
|
18
15
|
* A report of something going wrong is worth answering only when we know what
|
|
19
16
|
* was running. The version itself is in the hero, where a reader is asked to
|
|
20
|
-
* quote it from; this line carries the rest,
|
|
21
|
-
*
|
|
22
|
-
* that shows it.
|
|
17
|
+
* quote it from; this line carries the rest, so a report can name the exact
|
|
18
|
+
* build the problem was seen on.
|
|
23
19
|
* @param props - See {@link AboutBuildProps}.
|
|
24
20
|
* @returns The line.
|
|
25
21
|
*/
|
|
26
22
|
export function AboutBuild(props: AboutBuildProps): ReactElement {
|
|
27
|
-
const { build
|
|
23
|
+
const { build } = props;
|
|
28
24
|
const t = useChromeT();
|
|
29
|
-
const sources = githubSources(repository);
|
|
30
25
|
const builtAt = formatBuiltAt(build.builtAt);
|
|
31
26
|
if (build.commit === undefined) {
|
|
32
27
|
return <p style={PARAGRAPH_STYLE}>{t('about.built', { builtAt })}</p>;
|
|
33
28
|
}
|
|
34
29
|
|
|
35
|
-
// The commit
|
|
36
|
-
//
|
|
30
|
+
// The commit sits inside a sentence whose word order is the translator's,
|
|
31
|
+
// so the message names where it goes and is split there.
|
|
37
32
|
const [before = '', after = ''] = t('about.builtFromCommit', {
|
|
38
33
|
builtAt,
|
|
39
34
|
}).split('{commit}');
|
|
@@ -41,36 +36,14 @@ export function AboutBuild(props: AboutBuildProps): ReactElement {
|
|
|
41
36
|
return (
|
|
42
37
|
<p style={PARAGRAPH_STYLE}>
|
|
43
38
|
{before}
|
|
44
|
-
<
|
|
45
|
-
href={
|
|
46
|
-
sources === undefined
|
|
47
|
-
? undefined
|
|
48
|
-
: `${sources}/commit/${build.commit}`
|
|
49
|
-
}
|
|
50
|
-
>
|
|
51
|
-
{shortCommit(build.commit)}
|
|
52
|
-
</Reference>
|
|
39
|
+
<code style={CODE_STYLE}>{shortCommit(build.commit)}</code>
|
|
53
40
|
{after}
|
|
54
41
|
</p>
|
|
55
42
|
);
|
|
56
43
|
}
|
|
57
44
|
|
|
58
|
-
function Reference(props: {
|
|
59
|
-
href: string | undefined;
|
|
60
|
-
children: ReactNode;
|
|
61
|
-
}): ReactElement {
|
|
62
|
-
const { href, children } = props;
|
|
63
|
-
if (href === undefined) return <code style={CODE_STYLE}>{children}</code>;
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<a href={href} target="_blank" rel="noopener noreferrer" style={LINK_STYLE}>
|
|
67
|
-
<code style={CODE_STYLE}>{children}</code>
|
|
68
|
-
</a>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
45
|
const PARAGRAPH_STYLE = {
|
|
73
|
-
margin:
|
|
46
|
+
margin: 0,
|
|
74
47
|
color: 'var(--text-muted)',
|
|
75
48
|
fontSize: 13,
|
|
76
49
|
} as const satisfies CSSProperties;
|
|
@@ -79,5 +52,3 @@ const CODE_STYLE = {
|
|
|
79
52
|
fontFamily: 'var(--font-mono, ui-monospace, monospace)',
|
|
80
53
|
fontSize: 13,
|
|
81
54
|
} as const satisfies CSSProperties;
|
|
82
|
-
|
|
83
|
-
const LINK_STYLE = { color: 'var(--accent)' } as const satisfies CSSProperties;
|
|
@@ -47,8 +47,8 @@ export interface AboutPageProps {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* The About page of a site of the family: what the tool is, who provides it,
|
|
50
|
-
* what a visitor can do with it, what it is built on, how to cite it
|
|
51
|
-
*
|
|
50
|
+
* what a visitor can do with it, what it is built on, and how to cite it —
|
|
51
|
+
* always in that order.
|
|
52
52
|
*
|
|
53
53
|
* The order is the point. A reader who has read one of our About pages knows
|
|
54
54
|
* where the credits are on the other thirteen, and a site that writes its own
|
|
@@ -83,11 +83,7 @@ export function AboutPage(props: AboutPageProps): ReactElement {
|
|
|
83
83
|
</p>
|
|
84
84
|
<p style={WHAT_STYLE}>{about.what}</p>
|
|
85
85
|
</div>
|
|
86
|
-
<AboutVersion
|
|
87
|
-
build={about.build}
|
|
88
|
-
repository={about.repository}
|
|
89
|
-
publicRepository={about.publicRepository}
|
|
90
|
-
/>
|
|
86
|
+
<AboutVersion build={about.build} />
|
|
91
87
|
</header>
|
|
92
88
|
|
|
93
89
|
{about.people.length === 0 && about.providedBy.length === 0 ? null : (
|
|
@@ -133,68 +129,18 @@ export function AboutPage(props: AboutPageProps): ReactElement {
|
|
|
133
129
|
)}
|
|
134
130
|
|
|
135
131
|
{/*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
The version stays in the hero, unlinked, so a report still names a build.
|
|
132
|
+
The build the reader has open, last and under no heading: it is what a
|
|
133
|
+
report has to name, not something anybody came to the page to read.
|
|
139
134
|
*/}
|
|
140
|
-
{
|
|
141
|
-
<AboutSection
|
|
142
|
-
|
|
143
|
-
className="about-licence"
|
|
144
|
-
>
|
|
145
|
-
<p style={FIRST_PARAGRAPH_STYLE}>
|
|
146
|
-
{around(
|
|
147
|
-
t('about.licence', { license: about.license }),
|
|
148
|
-
'sources',
|
|
149
|
-
<ExternalLink key="sources" href={about.repository} />,
|
|
150
|
-
)}
|
|
151
|
-
</p>
|
|
152
|
-
{about.build === undefined ? null : (
|
|
153
|
-
<AboutBuild build={about.build} repository={about.repository} />
|
|
154
|
-
)}
|
|
155
|
-
</AboutSection>
|
|
156
|
-
)}
|
|
157
|
-
|
|
158
|
-
{/*
|
|
159
|
-
Asking for a report is worth nothing without somewhere to send it, and
|
|
160
|
-
the tracker of a private repository answers 404 to every visitor.
|
|
161
|
-
*/}
|
|
162
|
-
{about.issues === undefined ? null : (
|
|
163
|
-
<AboutSection title={t('about.foundAProblem')} className="about-issues">
|
|
164
|
-
<p style={FIRST_PARAGRAPH_STYLE}>
|
|
165
|
-
{around(
|
|
166
|
-
t('about.reportIt'),
|
|
167
|
-
'tracker',
|
|
168
|
-
<ExternalLink key="tracker" href={about.issues} />,
|
|
169
|
-
)}
|
|
170
|
-
</p>
|
|
135
|
+
{about.build === undefined ? null : (
|
|
136
|
+
<AboutSection className="about-build">
|
|
137
|
+
<AboutBuild build={about.build} />
|
|
171
138
|
</AboutSection>
|
|
172
139
|
)}
|
|
173
140
|
</div>
|
|
174
141
|
);
|
|
175
142
|
}
|
|
176
143
|
|
|
177
|
-
// A link sits inside a sentence whose word order is the translator's, so the
|
|
178
|
-
// message names where it goes with a placeholder and is split there.
|
|
179
|
-
function around(
|
|
180
|
-
message: string,
|
|
181
|
-
placeholder: string,
|
|
182
|
-
link: ReactNode,
|
|
183
|
-
): ReactNode[] {
|
|
184
|
-
const [before = '', after = ''] = message.split(`{${placeholder}}`);
|
|
185
|
-
return [before, link, after];
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function ExternalLink(props: { href: string }): ReactElement {
|
|
189
|
-
const { href } = props;
|
|
190
|
-
|
|
191
|
-
return (
|
|
192
|
-
<a href={href} target="_blank" rel="noopener noreferrer" style={LINK_STYLE}>
|
|
193
|
-
{href.replace(/^https?:\/\//, '')}
|
|
194
|
-
</a>
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
144
|
const PAGE_STYLE = {
|
|
199
145
|
display: 'flex',
|
|
200
146
|
flexDirection: 'column',
|
|
@@ -250,5 +196,3 @@ const FIRST_PARAGRAPH_STYLE = {
|
|
|
250
196
|
const PARAGRAPH_STYLE = {
|
|
251
197
|
margin: '8px 0 0',
|
|
252
198
|
} as const satisfies CSSProperties;
|
|
253
|
-
|
|
254
|
-
const LINK_STYLE = { color: 'var(--accent)' } as const satisfies CSSProperties;
|
|
@@ -14,17 +14,11 @@ import {
|
|
|
14
14
|
buildLabel,
|
|
15
15
|
buildStamp,
|
|
16
16
|
buildSummary,
|
|
17
|
-
releasedVersion,
|
|
18
17
|
} from '../../build/core/buildInfo.ts';
|
|
19
|
-
import { githubSources } from '../core/repository.ts';
|
|
20
18
|
|
|
21
19
|
export interface AboutVersionProps {
|
|
22
20
|
/** What the build published about itself, or `undefined` when it published none. */
|
|
23
21
|
build: BuildInfo | undefined;
|
|
24
|
-
/** Where the sources live, which is what the badge links into. */
|
|
25
|
-
repository: string;
|
|
26
|
-
/** Whether a visitor can open that repository, and so whether it is linked. */
|
|
27
|
-
publicRepository: boolean;
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
/**
|
|
@@ -34,53 +28,24 @@ export interface AboutVersionProps {
|
|
|
34
28
|
* @returns The badge, or `null` when the build says nothing worth showing.
|
|
35
29
|
*/
|
|
36
30
|
export function AboutVersion(props: AboutVersionProps): ReactElement | null {
|
|
37
|
-
const { build
|
|
31
|
+
const { build } = props;
|
|
38
32
|
const label = buildLabel(build);
|
|
39
33
|
if (build === undefined || label === undefined) return null;
|
|
40
|
-
const href = publicRepository ? addressOf(build, repository) : undefined;
|
|
41
|
-
const summary = buildSummary(build);
|
|
42
34
|
// The instant belongs on the badge rather than in its hover: a version
|
|
43
35
|
// nobody can date says nothing about how old the page they read is.
|
|
44
36
|
const badge = `${label} · ${buildStamp(build.builtAt)}`;
|
|
45
|
-
if (href === undefined) {
|
|
46
|
-
return (
|
|
47
|
-
<span style={BADGE_STYLE} className="about-version" title={summary}>
|
|
48
|
-
{badge}
|
|
49
|
-
</span>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
37
|
|
|
53
38
|
return (
|
|
54
|
-
<
|
|
39
|
+
<span
|
|
40
|
+
style={BADGE_STYLE}
|
|
55
41
|
className="about-version"
|
|
56
|
-
|
|
57
|
-
title={summary}
|
|
58
|
-
target="_blank"
|
|
59
|
-
rel="noopener noreferrer"
|
|
60
|
-
style={LINK_BADGE_STYLE}
|
|
42
|
+
title={buildSummary(build)}
|
|
61
43
|
>
|
|
62
44
|
{badge}
|
|
63
|
-
</
|
|
45
|
+
</span>
|
|
64
46
|
);
|
|
65
47
|
}
|
|
66
48
|
|
|
67
|
-
/**
|
|
68
|
-
* What the badge opens: the release it names, or the commit it was built from.
|
|
69
|
-
* @param build - What the build published about itself.
|
|
70
|
-
* @param repository - Where the sources live.
|
|
71
|
-
* @returns The address, or `undefined` when nothing inside the repository can
|
|
72
|
-
* be addressed.
|
|
73
|
-
*/
|
|
74
|
-
function addressOf(build: BuildInfo, repository: string): string | undefined {
|
|
75
|
-
const sources = githubSources(repository);
|
|
76
|
-
if (sources === undefined) return undefined;
|
|
77
|
-
const version = releasedVersion(build);
|
|
78
|
-
if (version !== undefined) return `${sources}/releases/tag/v${version}`;
|
|
79
|
-
return build.commit === undefined
|
|
80
|
-
? undefined
|
|
81
|
-
: `${sources}/commit/${build.commit}`;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
49
|
const BADGE_STYLE = {
|
|
85
50
|
flex: '0 0 auto',
|
|
86
51
|
fontFamily: 'var(--font-mono, ui-monospace, monospace)',
|
|
@@ -88,8 +53,3 @@ const BADGE_STYLE = {
|
|
|
88
53
|
color: 'var(--text-muted)',
|
|
89
54
|
whiteSpace: 'nowrap',
|
|
90
55
|
} as const satisfies CSSProperties;
|
|
91
|
-
|
|
92
|
-
const LINK_BADGE_STYLE = {
|
|
93
|
-
...BADGE_STYLE,
|
|
94
|
-
color: 'var(--accent)',
|
|
95
|
-
} as const satisfies CSSProperties;
|