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
package/src/locales/de.json
CHANGED
|
@@ -86,10 +86,6 @@
|
|
|
86
86
|
"about.whatYouCanDo": "Was Sie hier tun können",
|
|
87
87
|
"about.builtOn": "Aufgebaut auf",
|
|
88
88
|
"about.howToCite": "Wie zu zitieren",
|
|
89
|
-
"about.licenceAndSource": "Lizenz und Quelltext",
|
|
90
|
-
"about.licence": "{license}, © cheminfo. Nutzen Sie es in einem Kurs, forken Sie es, oder übernehmen Sie einen Teil davon anderswo. Der Quelltext liegt auf {sources}.",
|
|
91
|
-
"about.foundAProblem": "Ein Problem gefunden?",
|
|
92
|
-
"about.reportIt": "Sagen Sie es uns: ein Bericht, der nennt, was Sie eingegeben haben und was zurückkam, ist die schnellste Korrektur, die es gibt. {tracker}.",
|
|
93
89
|
"about.citeWork": "{what} zitieren",
|
|
94
90
|
"about.built": "Erstellt {builtAt}.",
|
|
95
91
|
"about.builtFromCommit": "Erstellt {builtAt} aus Commit {commit}.",
|
|
@@ -189,6 +185,8 @@
|
|
|
189
185
|
"download.hintRasterSvg": "Ein SVG, das ein Bild von {pixels} enthält: eine 3D-Szene hat keine Vektorform.",
|
|
190
186
|
"download.hintSvg": "Öffnet sich mit {pixels} und bleibt in jeder Größe scharf.",
|
|
191
187
|
"download.hintPng": "Gespeichert {pixels}.",
|
|
188
|
+
"download.hintCopied": "In die Zwischenablage kopiert: PNG mit {pixels}.",
|
|
189
|
+
"download.copyUnsupported": "Dieser Browser kann kein Bild in die Zwischenablage legen. Speichern Sie es stattdessen.",
|
|
192
190
|
"download.size": "Größe",
|
|
193
191
|
"download.sizeHelp": "Die Form, in der die Abbildung für die Datei gezeichnet wird. Sie wird neu gesetzt, sodass Achsen und Beschriftungen in diese Form passen, statt hineingedehnt zu werden. Eine Zeitschriftenspalte ist 8,5 cm breit, und ihr Text wird in der Größe gedruckt, in der er auf dem Bildschirm steht.",
|
|
194
192
|
"download.sizeScreen": "Wie angezeigt",
|
package/src/locales/en.json
CHANGED
|
@@ -86,10 +86,6 @@
|
|
|
86
86
|
"about.whatYouCanDo": "What you can do here",
|
|
87
87
|
"about.builtOn": "Built on",
|
|
88
88
|
"about.howToCite": "How to cite",
|
|
89
|
-
"about.licenceAndSource": "Licence and source",
|
|
90
|
-
"about.licence": "{license}, © cheminfo. Use it in a course, fork it, or lift a piece of it into something else. The sources are at {sources}.",
|
|
91
|
-
"about.foundAProblem": "Found a problem?",
|
|
92
|
-
"about.reportIt": "Tell us: a report naming what you typed and what came back is the fastest fix there is. {tracker}.",
|
|
93
89
|
"about.citeWork": "Cite {what}",
|
|
94
90
|
"about.built": "Built {builtAt}.",
|
|
95
91
|
"about.builtFromCommit": "Built {builtAt} from commit {commit}.",
|
|
@@ -189,6 +185,8 @@
|
|
|
189
185
|
"download.hintRasterSvg": "An SVG holding a picture of {pixels}: a 3D scene has no vector form.",
|
|
190
186
|
"download.hintSvg": "Opens at {pixels}, and stays sharp at any size.",
|
|
191
187
|
"download.hintPng": "Saved {pixels}.",
|
|
188
|
+
"download.hintCopied": "Copied {pixels} to the clipboard, as a PNG.",
|
|
189
|
+
"download.copyUnsupported": "This browser cannot put a picture on the clipboard. Save it instead.",
|
|
192
190
|
"download.size": "Size",
|
|
193
191
|
"download.sizeHelp": "The shape the figure is drawn at for the file. It is laid out again, so the axes and labels fit that shape instead of being stretched into it. A journal column is 8.5 cm wide, and its text prints at the size it reads on screen.",
|
|
194
192
|
"download.sizeScreen": "As shown",
|
package/src/locales/es.json
CHANGED
|
@@ -86,10 +86,6 @@
|
|
|
86
86
|
"about.whatYouCanDo": "Lo que puede hacer aquí",
|
|
87
87
|
"about.builtOn": "Construido sobre",
|
|
88
88
|
"about.howToCite": "Cómo citar",
|
|
89
|
-
"about.licenceAndSource": "Licencia y código fuente",
|
|
90
|
-
"about.licence": "{license}, © cheminfo. Úselo en un curso, bifúrquelo, o llévese un trozo a otra parte. El código está en {sources}.",
|
|
91
|
-
"about.foundAProblem": "¿Ha encontrado un problema?",
|
|
92
|
-
"about.reportIt": "Díganoslo: un informe que indique lo que escribió y lo que obtuvo es la corrección más rápida que existe. {tracker}.",
|
|
93
89
|
"about.citeWork": "Citar {what}",
|
|
94
90
|
"about.built": "Compilado {builtAt}.",
|
|
95
91
|
"about.builtFromCommit": "Compilado {builtAt} desde el commit {commit}.",
|
|
@@ -189,6 +185,8 @@
|
|
|
189
185
|
"download.hintRasterSvg": "Un SVG que contiene una imagen de {pixels}: una escena 3D no tiene forma vectorial.",
|
|
190
186
|
"download.hintSvg": "Se abre a {pixels}, y se mantiene nítido a cualquier tamaño.",
|
|
191
187
|
"download.hintPng": "Guardado {pixels}.",
|
|
188
|
+
"download.hintCopied": "Copiado al portapapeles: PNG de {pixels}.",
|
|
189
|
+
"download.copyUnsupported": "Este navegador no puede poner una imagen en el portapapeles. Guárdala en su lugar.",
|
|
192
190
|
"download.size": "Tamaño",
|
|
193
191
|
"download.sizeHelp": "La forma con la que se dibuja la figura para el archivo. Se vuelve a maquetar, de modo que los ejes y las etiquetas se ajustan a esa forma en lugar de estirarse. Una columna de revista mide 8,5 cm, y su texto se imprime al tamaño con que se lee en pantalla.",
|
|
194
192
|
"download.sizeScreen": "Como se muestra",
|
package/src/locales/fr.json
CHANGED
|
@@ -86,10 +86,6 @@
|
|
|
86
86
|
"about.whatYouCanDo": "Ce que vous pouvez faire ici",
|
|
87
87
|
"about.builtOn": "Construit sur",
|
|
88
88
|
"about.howToCite": "Comment citer",
|
|
89
|
-
"about.licenceAndSource": "Licence et sources",
|
|
90
|
-
"about.licence": "{license}, © cheminfo. Utilisez-le dans un cours, forkez-le, ou reprenez-en un morceau ailleurs. Les sources sont sur {sources}.",
|
|
91
|
-
"about.foundAProblem": "Un problème ?",
|
|
92
|
-
"about.reportIt": "Dites-le-nous : un rapport indiquant ce que vous avez saisi et ce qui est revenu est la correction la plus rapide qui soit. {tracker}.",
|
|
93
89
|
"about.citeWork": "Citer {what}",
|
|
94
90
|
"about.built": "Compilé {builtAt}.",
|
|
95
91
|
"about.builtFromCommit": "Compilé {builtAt} depuis le commit {commit}.",
|
|
@@ -189,6 +185,8 @@
|
|
|
189
185
|
"download.hintRasterSvg": "Un SVG contenant une image de {pixels} : une scène 3D n'a pas de forme vectorielle.",
|
|
190
186
|
"download.hintSvg": "S'ouvre à {pixels}, et reste net à toute taille.",
|
|
191
187
|
"download.hintPng": "Enregistré {pixels}.",
|
|
188
|
+
"download.hintCopied": "Copié dans le presse-papiers : PNG de {pixels}.",
|
|
189
|
+
"download.copyUnsupported": "Ce navigateur ne peut pas copier une image dans le presse-papiers. Enregistrez-la plutôt.",
|
|
192
190
|
"download.size": "Taille",
|
|
193
191
|
"download.sizeHelp": "La forme à laquelle la figure est dessinée pour le fichier. Elle est remise en page, si bien que les axes et les étiquettes s'ajustent à cette forme au lieu d'y être étirés. Une colonne de revue mesure 8,5 cm, et son texte s'imprime à la taille où il se lit à l'écran.",
|
|
194
192
|
"download.sizeScreen": "Comme affichée",
|
package/src/locales/it.json
CHANGED
|
@@ -86,10 +86,6 @@
|
|
|
86
86
|
"about.whatYouCanDo": "Cosa si può fare qui",
|
|
87
87
|
"about.builtOn": "Costruito su",
|
|
88
88
|
"about.howToCite": "Come citare",
|
|
89
|
-
"about.licenceAndSource": "Licenza e codice sorgente",
|
|
90
|
-
"about.licence": "{license}, © cheminfo. Si può usare in un corso, farne un fork, o riprenderne un pezzo per altro. Il codice è su {sources}.",
|
|
91
|
-
"about.foundAProblem": "Ha trovato un problema?",
|
|
92
|
-
"about.reportIt": "Ce lo dica: una segnalazione che indichi cosa ha scritto e cosa ha ottenuto è la correzione più rapida che esista. {tracker}.",
|
|
93
89
|
"about.citeWork": "Citare {what}",
|
|
94
90
|
"about.built": "Compilato {builtAt}.",
|
|
95
91
|
"about.builtFromCommit": "Compilato {builtAt} dal commit {commit}.",
|
|
@@ -189,6 +185,8 @@
|
|
|
189
185
|
"download.hintRasterSvg": "Un SVG che contiene un'immagine di {pixels}: una scena 3D non ha forma vettoriale.",
|
|
190
186
|
"download.hintSvg": "Si apre a {pixels}, e resta nitido a qualsiasi dimensione.",
|
|
191
187
|
"download.hintPng": "Salvato {pixels}.",
|
|
188
|
+
"download.hintCopied": "Copiato negli appunti: PNG di {pixels}.",
|
|
189
|
+
"download.copyUnsupported": "Questo browser non può mettere un'immagine negli appunti. Salvala invece.",
|
|
192
190
|
"download.size": "Dimensione",
|
|
193
191
|
"download.sizeHelp": "La forma con cui la figura viene disegnata per il file. Viene ricomposta, così gli assi e le etichette si adattano a quella forma invece di essere stirati. Una colonna di rivista è larga 8,5 cm, e il suo testo si stampa alla dimensione con cui si legge sullo schermo.",
|
|
194
192
|
"download.sizeScreen": "Come mostrata",
|
|
@@ -78,6 +78,12 @@ export interface OverlayPanelProps {
|
|
|
78
78
|
* @default derived from the type size — 88 at the compact size
|
|
79
79
|
*/
|
|
80
80
|
nameWidth?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Fixed width of the panel, for one whose hint changes with its choices:
|
|
83
|
+
* left to its content, it would resize under the pointer at every pick.
|
|
84
|
+
* @default undefined — as wide as its content
|
|
85
|
+
*/
|
|
86
|
+
width?: number | string;
|
|
81
87
|
/**
|
|
82
88
|
* Value of the `data-testid` attribute of the panel.
|
|
83
89
|
* @default undefined
|
|
@@ -104,7 +110,7 @@ export interface OverlayPanelProps {
|
|
|
104
110
|
export function OverlayPanel(props: OverlayPanelProps): ReactElement {
|
|
105
111
|
const { title, children, onReset, resetLabel, help } = props;
|
|
106
112
|
const t = useChromeT();
|
|
107
|
-
const { actions, hint, nameWidth, testId } = props;
|
|
113
|
+
const { actions, hint, nameWidth, width: panelWidth, testId } = props;
|
|
108
114
|
const { metrics } = useOverlaySurface();
|
|
109
115
|
const titleId = useId();
|
|
110
116
|
const reset = useOverlayInteraction();
|
|
@@ -120,7 +126,7 @@ export function OverlayPanel(props: OverlayPanelProps): ReactElement {
|
|
|
120
126
|
role="group"
|
|
121
127
|
aria-labelledby={titleId}
|
|
122
128
|
data-testid={testId}
|
|
123
|
-
style={overlayPanelSurfaceStyle(metrics)}
|
|
129
|
+
style={overlayPanelSurfaceStyle(metrics, panelWidth)}
|
|
124
130
|
>
|
|
125
131
|
<div style={overlayPanelHeaderStyle(metrics)}>
|
|
126
132
|
<span style={overlayPanelTitleStyle(metrics)}>
|
|
@@ -26,14 +26,17 @@ import { overlayFocusRing } from './overlayValueStyles.ts';
|
|
|
26
26
|
* The panel itself: a header, a body, and whatever the figure can be told to
|
|
27
27
|
* do at the foot.
|
|
28
28
|
* @param metrics - The measurements the card is drawn from.
|
|
29
|
+
* @param width - A fixed width, or `undefined` for as wide as its content.
|
|
29
30
|
* @returns The panel's rules.
|
|
30
31
|
*/
|
|
31
32
|
export function overlayPanelSurfaceStyle(
|
|
32
33
|
metrics: OverlayMetrics,
|
|
34
|
+
width?: number | string,
|
|
33
35
|
): CSSProperties {
|
|
34
36
|
return {
|
|
35
37
|
display: 'flex',
|
|
36
38
|
flexDirection: 'column',
|
|
39
|
+
width,
|
|
37
40
|
minWidth: OVERLAY_PANEL_MIN_WIDTH,
|
|
38
41
|
color: 'var(--text)',
|
|
39
42
|
fontSize: metrics.fontSize,
|
|
@@ -37,12 +37,6 @@ export interface ElementCellProps {
|
|
|
37
37
|
* @default '' — nothing is written
|
|
38
38
|
*/
|
|
39
39
|
detail?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Whether the table this cell belongs to writes a third line at all. A table
|
|
42
|
-
* that writes none gives the room to the symbol, and its rows are shorter.
|
|
43
|
-
* @default whether this cell has one
|
|
44
|
-
*/
|
|
45
|
-
writesDetail?: boolean;
|
|
46
40
|
/**
|
|
47
41
|
* Whether the cell is the one the tools are pointed at.
|
|
48
42
|
* @default false
|
|
@@ -82,7 +76,6 @@ export function ElementCell(props: ElementCellProps): ReactElement {
|
|
|
82
76
|
row,
|
|
83
77
|
onSelect,
|
|
84
78
|
detail = '',
|
|
85
|
-
writesDetail = detail !== '',
|
|
86
79
|
isSelected = false,
|
|
87
80
|
isIncluded = true,
|
|
88
81
|
onHover,
|
|
@@ -137,7 +130,7 @@ export function ElementCell(props: ElementCellProps): ReactElement {
|
|
|
137
130
|
<span
|
|
138
131
|
style={{
|
|
139
132
|
...symbolStyle,
|
|
140
|
-
fontSize: symbolFontSize(symbol
|
|
133
|
+
fontSize: symbolFontSize(symbol),
|
|
141
134
|
}}
|
|
142
135
|
>
|
|
143
136
|
{symbol}
|
|
@@ -158,12 +151,10 @@ export function ElementCell(props: ElementCellProps): ReactElement {
|
|
|
158
151
|
* ones whose second letter is an `m` — which are written a tenth smaller
|
|
159
152
|
* rather than run into the edges of their cell.
|
|
160
153
|
* @param symbol - The chemical symbol.
|
|
161
|
-
* @param writesDetail - Whether the table writes a third line under it.
|
|
162
154
|
* @returns A CSS length.
|
|
163
155
|
*/
|
|
164
|
-
function symbolFontSize(symbol: string
|
|
165
|
-
|
|
166
|
-
return fitted(symbolWidthInEm(symbol), cap, '0.5rem');
|
|
156
|
+
function symbolFontSize(symbol: string): string {
|
|
157
|
+
return fitted(symbolWidthInEm(symbol), SYMBOL_CQW, '0.5rem');
|
|
167
158
|
}
|
|
168
159
|
|
|
169
160
|
/**
|
|
@@ -233,17 +224,24 @@ const TABULAR_EM = 0.6;
|
|
|
233
224
|
/** The size the symbol is written at wherever it fits, as a share of the table. */
|
|
234
225
|
const SYMBOL_CQW = '2.4cqw';
|
|
235
226
|
|
|
236
|
-
/** The same, in a table that writes nothing under the symbol. */
|
|
237
|
-
const SYMBOL_ALONE_CQW = '2.8cqw';
|
|
238
|
-
|
|
239
227
|
/**
|
|
240
228
|
* The tallest the third line is ever written, as a share of the table.
|
|
241
229
|
*
|
|
242
|
-
* Close to
|
|
243
|
-
*
|
|
244
|
-
*
|
|
230
|
+
* Close to two thirds of the symbol: the symbol is how a cell is found, but
|
|
231
|
+
* the value is what the table is being read for, and a value half the size of
|
|
232
|
+
* the symbol is the one thing on the cell a class cannot make out.
|
|
233
|
+
*/
|
|
234
|
+
const DETAIL_CQW = '1.6cqw';
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The band at each end of a cell: the atomic number at the top, whatever the
|
|
238
|
+
* tool writes at the bottom.
|
|
239
|
+
*
|
|
240
|
+
* They are one length, not two, and that is what makes the symbol between them
|
|
241
|
+
* sit at the centre of the cell rather than near it — a bottom band wider than
|
|
242
|
+
* the top one by a third lifted every symbol in the table two pixels.
|
|
245
243
|
*/
|
|
246
|
-
const
|
|
244
|
+
const EDGE_BAND = '1.8cqw';
|
|
247
245
|
|
|
248
246
|
/** How wide one column is, as a share of the table's width. */
|
|
249
247
|
const CELL_CQW = '4.85cqw';
|
|
@@ -251,49 +249,48 @@ const CELL_CQW = '4.85cqw';
|
|
|
251
249
|
/** What the border and the padding of a cell take off that width. */
|
|
252
250
|
const CELL_CHROME = '4px';
|
|
253
251
|
|
|
252
|
+
/**
|
|
253
|
+
* A cell is three bands of its own, and every cell has all three.
|
|
254
|
+
*
|
|
255
|
+
* The atomic number is in the top band, against its left edge; the symbol is
|
|
256
|
+
* centred in the middle one; whatever the tool writes is centred in the
|
|
257
|
+
* bottom one. The bands keep their height whether or not anything is written
|
|
258
|
+
* in the last of them, so a number sits at one height across the whole table
|
|
259
|
+
* and a symbol at one other — before this, both rode on a stack the cell
|
|
260
|
+
* centred and moved whenever a neighbour's value was written smaller.
|
|
261
|
+
*/
|
|
254
262
|
const cellStyle = {
|
|
255
|
-
alignItems: 'center',
|
|
256
263
|
border: '1px solid rgb(255 255 255 / 0.55)',
|
|
257
264
|
borderRadius: 3,
|
|
258
265
|
cursor: 'pointer',
|
|
259
|
-
display: '
|
|
260
|
-
flexDirection: 'column',
|
|
266
|
+
display: 'grid',
|
|
261
267
|
font: 'inherit',
|
|
262
|
-
|
|
268
|
+
gridTemplateRows: `${EDGE_BAND} 1fr ${EDGE_BAND}`,
|
|
269
|
+
justifyItems: 'center',
|
|
263
270
|
minWidth: 0,
|
|
264
271
|
overflow: 'hidden',
|
|
265
272
|
padding: '1px',
|
|
266
|
-
// The corner the atomic number is pinned into.
|
|
267
|
-
position: 'relative',
|
|
268
273
|
transition: 'opacity 120ms ease, filter 120ms ease',
|
|
269
274
|
} as const satisfies CSSProperties;
|
|
270
275
|
|
|
271
|
-
/**
|
|
272
|
-
* The atomic number sits out of the flow, in the corner.
|
|
273
|
-
*
|
|
274
|
-
* In the flow it rode on top of a stack the cell centres, so it moved down
|
|
275
|
-
* whenever what is written under the symbol was written smaller — the numbers
|
|
276
|
-
* of a row then sat at as many heights as the row had word lengths. Out of it,
|
|
277
|
-
* the number is in the same corner of every cell, and the symbol is centred in
|
|
278
|
-
* the cell rather than in what is left of it.
|
|
279
|
-
*/
|
|
280
276
|
const numberStyle = {
|
|
277
|
+
alignSelf: 'start',
|
|
281
278
|
fontSize: 'max(0.33rem, 1.1cqw)',
|
|
282
279
|
fontVariantNumeric: 'tabular-nums',
|
|
283
|
-
|
|
280
|
+
justifySelf: 'start',
|
|
284
281
|
lineHeight: 1,
|
|
285
282
|
opacity: 0.8,
|
|
286
|
-
position: 'absolute',
|
|
287
|
-
top: 'max(1px, 0.14cqw)',
|
|
288
283
|
} as const satisfies CSSProperties;
|
|
289
284
|
|
|
290
285
|
const symbolStyle = {
|
|
286
|
+
alignSelf: 'center',
|
|
291
287
|
fontWeight: 700,
|
|
292
288
|
letterSpacing: '-0.02em',
|
|
293
289
|
lineHeight: 1.02,
|
|
294
290
|
} as const satisfies CSSProperties;
|
|
295
291
|
|
|
296
292
|
const detailStyle = {
|
|
293
|
+
alignSelf: 'center',
|
|
297
294
|
fontVariantNumeric: 'tabular-nums',
|
|
298
295
|
lineHeight: 1,
|
|
299
296
|
maxWidth: '100%',
|
|
@@ -147,7 +147,6 @@ export function PeriodicTable(props: PeriodicTableProps): ReactElement {
|
|
|
147
147
|
} = props;
|
|
148
148
|
|
|
149
149
|
const t = useChromeT();
|
|
150
|
-
const writesDetail = detailOf !== undefined;
|
|
151
150
|
const gridRef = useRef<HTMLDivElement>(null);
|
|
152
151
|
const cameFromKeyRef = useRef(false);
|
|
153
152
|
const offset = headers ? 1 : 0;
|
|
@@ -178,7 +177,7 @@ export function PeriodicTable(props: PeriodicTableProps): ReactElement {
|
|
|
178
177
|
role="grid"
|
|
179
178
|
aria-label={t('periodic.table')}
|
|
180
179
|
data-testid="periodic-table"
|
|
181
|
-
style={gridStyle(headers
|
|
180
|
+
style={gridStyle(headers)}
|
|
182
181
|
onKeyDown={handleKeyDown}
|
|
183
182
|
>
|
|
184
183
|
{headers ? <HeaderStrips onSelectRange={onSelectRange} /> : null}
|
|
@@ -193,7 +192,6 @@ export function PeriodicTable(props: PeriodicTableProps): ReactElement {
|
|
|
193
192
|
symbol={element.symbol}
|
|
194
193
|
name={nameOf(element)}
|
|
195
194
|
detail={detailOf?.(element)}
|
|
196
|
-
writesDetail={writesDetail}
|
|
197
195
|
swatch={swatchOf(element)}
|
|
198
196
|
isSelected={element.symbol === selected}
|
|
199
197
|
isIncluded={isIncluded?.(element)}
|
|
@@ -218,8 +216,9 @@ function insetStyle(offset: number): CSSProperties {
|
|
|
218
216
|
return {
|
|
219
217
|
alignItems: 'center',
|
|
220
218
|
display: 'flex',
|
|
221
|
-
//
|
|
222
|
-
|
|
219
|
+
// A column of air on each side, so the writing reads as sitting in the
|
|
220
|
+
// block rather than as running into the cells beside it.
|
|
221
|
+
padding: '0 2.4cqw',
|
|
223
222
|
gridColumn: `${String(EMPTY_BLOCK.column + offset)} / span ${String(EMPTY_BLOCK.columnSpan)}`,
|
|
224
223
|
gridRow: `${String(EMPTY_BLOCK.row + offset)} / span ${String(EMPTY_BLOCK.rowSpan)}`,
|
|
225
224
|
// A share of the table, with a floor, exactly as a cell sizes its symbol:
|
|
@@ -251,14 +250,13 @@ const MIN_WIDTH = 280;
|
|
|
251
250
|
/**
|
|
252
251
|
* How tall one row of elements is, as a share of the table's width.
|
|
253
252
|
*
|
|
254
|
-
* A column is about 5.
|
|
255
|
-
*
|
|
256
|
-
* cell need to be
|
|
253
|
+
* A column is about 5.2% of that width, so a cell is a third taller than it is
|
|
254
|
+
* wide — the proportion of a wall chart, and the room the three bands of a
|
|
255
|
+
* cell need to be read from the back of a room. It is the same height in every
|
|
256
|
+
* table: a cell keeps the band it writes a value in whether or not that table
|
|
257
|
+
* writes one.
|
|
257
258
|
*/
|
|
258
|
-
const ROW_HEIGHT = '6.
|
|
259
|
-
|
|
260
|
-
/** The same, in a table that writes nothing under the symbol. */
|
|
261
|
-
const ROW_HEIGHT_ALONE = '4.9cqw';
|
|
259
|
+
const ROW_HEIGHT = '6.8cqw';
|
|
262
260
|
|
|
263
261
|
/** The band the two inner-transition series were lifted out across. */
|
|
264
262
|
const SERIES_GAP = 'max(6px, 1.1cqw)';
|
|
@@ -285,14 +283,11 @@ const baseGridStyle = {
|
|
|
285
283
|
* The grid the cells are placed on.
|
|
286
284
|
* @param headers - Whether a leading column and row hold the period and group
|
|
287
285
|
* numbers.
|
|
288
|
-
* @param writesDetail - Whether a cell writes a third line, which is what a
|
|
289
|
-
* row is tall enough for.
|
|
290
286
|
* @returns The style of the grid.
|
|
291
287
|
*/
|
|
292
|
-
function gridStyle(headers: boolean
|
|
293
|
-
const row = writesDetail ? ROW_HEIGHT : ROW_HEIGHT_ALONE;
|
|
288
|
+
function gridStyle(headers: boolean): CSSProperties {
|
|
294
289
|
// The eighth row is the gap the inner-transition series are lifted out into.
|
|
295
|
-
const rows = `repeat(7, ${
|
|
290
|
+
const rows = `repeat(7, ${ROW_HEIGHT}) ${SERIES_GAP} repeat(2, ${ROW_HEIGHT})`;
|
|
296
291
|
if (!headers) {
|
|
297
292
|
return {
|
|
298
293
|
...baseGridStyle,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What can be linked to inside a repository, and when.
|
|
3
|
-
*
|
|
4
|
-
* Only GitHub has the addresses the About page builds — a release tag, a
|
|
5
|
-
* commit — and only a repository a visitor can open is worth pointing them at.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* The sources as a base a release or a commit can be appended to.
|
|
9
|
-
* @param repository - Where the sources live.
|
|
10
|
-
* @returns The address without its trailing slash, or `undefined` when it is
|
|
11
|
-
* not a GitHub repository and nothing inside it can be addressed.
|
|
12
|
-
*/
|
|
13
|
-
export declare function githubSources(repository: string): string | undefined;
|
|
14
|
-
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/about/core/repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKpE"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What can be linked to inside a repository, and when.
|
|
3
|
-
*
|
|
4
|
-
* Only GitHub has the addresses the About page builds — a release tag, a
|
|
5
|
-
* commit — and only a repository a visitor can open is worth pointing them at.
|
|
6
|
-
*/
|
|
7
|
-
/** Where our repositories live, and the only host whose paths we know. */
|
|
8
|
-
const GITHUB = 'https://github.com/';
|
|
9
|
-
/**
|
|
10
|
-
* The sources as a base a release or a commit can be appended to.
|
|
11
|
-
* @param repository - Where the sources live.
|
|
12
|
-
* @returns The address without its trailing slash, or `undefined` when it is
|
|
13
|
-
* not a GitHub repository and nothing inside it can be addressed.
|
|
14
|
-
*/
|
|
15
|
-
export function githubSources(repository) {
|
|
16
|
-
const sources = repository.endsWith('/')
|
|
17
|
-
? repository.slice(0, -1)
|
|
18
|
-
: repository;
|
|
19
|
-
return sources.startsWith(GITHUB) ? sources : undefined;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/about/core/repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,GAAG,qBAAqB,CAAC;AAErC;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC;QACtC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACzB,CAAC,CAAC,UAAU,CAAC;IACf,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A row of buttons with the name box among them, wrapping when the dialog is
|
|
3
|
-
* too narrow for them.
|
|
4
|
-
*/
|
|
5
|
-
export declare const exportButtonsStyle: {
|
|
6
|
-
readonly display: "flex";
|
|
7
|
-
readonly flexWrap: "wrap";
|
|
8
|
-
readonly alignItems: "center";
|
|
9
|
-
readonly gap: 6;
|
|
10
|
-
};
|
|
11
|
-
/** One group of an export dialog: what it offers, in a column. */
|
|
12
|
-
export declare const exportSectionStyle: {
|
|
13
|
-
readonly display: "flex";
|
|
14
|
-
readonly flexDirection: "column";
|
|
15
|
-
readonly gap: 8;
|
|
16
|
-
};
|
|
17
|
-
/** Text that says something about a control rather than being one. */
|
|
18
|
-
export declare const exportNoteStyle: {
|
|
19
|
-
readonly fontSize: 12;
|
|
20
|
-
readonly opacity: 0.7;
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=exportStyles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exportStyles.d.ts","sourceRoot":"","sources":["../../../src/download/core/exportStyles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAEX,kEAAkE;AAClE,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAC;AAEX,sEAAsE;AACtE,eAAO,MAAM,eAAe;;;CAA0C,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A row of buttons with the name box among them, wrapping when the dialog is
|
|
3
|
-
* too narrow for them.
|
|
4
|
-
*/
|
|
5
|
-
export const exportButtonsStyle = {
|
|
6
|
-
display: 'flex',
|
|
7
|
-
flexWrap: 'wrap',
|
|
8
|
-
alignItems: 'center',
|
|
9
|
-
gap: 6,
|
|
10
|
-
};
|
|
11
|
-
/** One group of an export dialog: what it offers, in a column. */
|
|
12
|
-
export const exportSectionStyle = {
|
|
13
|
-
display: 'flex',
|
|
14
|
-
flexDirection: 'column',
|
|
15
|
-
gap: 8,
|
|
16
|
-
};
|
|
17
|
-
/** Text that says something about a control rather than being one. */
|
|
18
|
-
export const exportNoteStyle = { fontSize: 12, opacity: 0.7 };
|
|
19
|
-
//# sourceMappingURL=exportStyles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exportStyles.js","sourceRoot":"","sources":["../../../src/download/core/exportStyles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,QAAQ;IACpB,GAAG,EAAE,CAAC;CACE,CAAC;AAEX,kEAAkE;AAClE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,QAAQ;IACvB,GAAG,EAAE,CAAC;CACE,CAAC;AAEX,sEAAsE;AACtE,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAW,CAAC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/** How big a picture is written out, as a multiple of the size it is drawn at. */
|
|
2
|
-
export interface ImageResolution {
|
|
3
|
-
/** Identifies the resolution in a picker. */
|
|
4
|
-
id: string;
|
|
5
|
-
/** What the option reads. */
|
|
6
|
-
label: string;
|
|
7
|
-
/** How many pixels each drawing unit becomes. */
|
|
8
|
-
scale: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* The sizes a picture leaves the editor at.
|
|
12
|
-
*
|
|
13
|
-
* A drawing unit is about a screen pixel, so the multipliers read as what the
|
|
14
|
-
* picture is for rather than as numbers: what is on screen, the same again on a
|
|
15
|
-
* retina display, and the two steps up a figure needs to survive being printed
|
|
16
|
-
* or thrown on a wall.
|
|
17
|
-
*/
|
|
18
|
-
export declare const IMAGE_RESOLUTIONS: readonly [{
|
|
19
|
-
readonly id: "screen";
|
|
20
|
-
readonly label: "Screen (1×)";
|
|
21
|
-
readonly scale: 1;
|
|
22
|
-
}, {
|
|
23
|
-
readonly id: "retina";
|
|
24
|
-
readonly label: "Retina (2×)";
|
|
25
|
-
readonly scale: 2;
|
|
26
|
-
}, {
|
|
27
|
-
readonly id: "print";
|
|
28
|
-
readonly label: "Print (4×)";
|
|
29
|
-
readonly scale: 4;
|
|
30
|
-
}, {
|
|
31
|
-
readonly id: "poster";
|
|
32
|
-
readonly label: "Poster (8×)";
|
|
33
|
-
readonly scale: 8;
|
|
34
|
-
}];
|
|
35
|
-
/** One of the resolutions offered. */
|
|
36
|
-
export type ImageResolutionId = (typeof IMAGE_RESOLUTIONS)[number]['id'];
|
|
37
|
-
/**
|
|
38
|
-
* The resolution a picture is written out at unless another is picked: what is
|
|
39
|
-
* on screen, doubled, which is what a picture pasted into a document wants.
|
|
40
|
-
*/
|
|
41
|
-
export declare const DEFAULT_IMAGE_RESOLUTION: {
|
|
42
|
-
readonly id: "retina";
|
|
43
|
-
readonly label: "Retina (2×)";
|
|
44
|
-
readonly scale: 2;
|
|
45
|
-
};
|
|
46
|
-
/** How big a picture comes out, in pixels. */
|
|
47
|
-
export interface ImageSize {
|
|
48
|
-
/** Width of the picture, in pixels. */
|
|
49
|
-
width: number;
|
|
50
|
-
/** Height of the picture, in pixels. */
|
|
51
|
-
height: number;
|
|
52
|
-
/**
|
|
53
|
-
* What each drawing unit was actually worth. Below the resolution that was
|
|
54
|
-
* asked for when it would have made a picture too big to rasterize.
|
|
55
|
-
*/
|
|
56
|
-
scale: number;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* How big a rectangle of the drawing comes out at a given resolution.
|
|
60
|
-
*
|
|
61
|
-
* The resolution is a wish rather than an instruction: a wide glycan asked for
|
|
62
|
-
* at 8× would run past what a browser can rasterize and come back blank, so the
|
|
63
|
-
* scale is brought down until the picture fits instead. The scale it settled on
|
|
64
|
-
* comes back with the size, so what will actually be written can be shown
|
|
65
|
-
* before it is.
|
|
66
|
-
* @param box - The rectangle being written out.
|
|
67
|
-
* @param box.width - How wide it is, in drawing units.
|
|
68
|
-
* @param box.height - How tall it is, in drawing units.
|
|
69
|
-
* @param scale - How many pixels each drawing unit should become.
|
|
70
|
-
* @returns The size, and the scale it was reached at.
|
|
71
|
-
*/
|
|
72
|
-
export declare function imageSize(box: {
|
|
73
|
-
width: number;
|
|
74
|
-
height: number;
|
|
75
|
-
}, scale: number): ImageSize;
|
|
76
|
-
/**
|
|
77
|
-
* The resolution an identifier stands for.
|
|
78
|
-
* @param id - What was picked.
|
|
79
|
-
* @returns The resolution, falling back to the default one.
|
|
80
|
-
*/
|
|
81
|
-
export declare function imageResolution(id: string): ImageResolution;
|
|
82
|
-
/**
|
|
83
|
-
* A size, written the way it is shown next to the resolution it comes from.
|
|
84
|
-
* @param size - The size to write, `null` when nothing is drawn.
|
|
85
|
-
* @returns The text, e.g. `1440 × 620 px`.
|
|
86
|
-
*/
|
|
87
|
-
export declare function formatImageSize(size: ImageSize | null): string;
|
|
88
|
-
//# sourceMappingURL=imageResolution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"imageResolution.d.ts","sourceRoot":"","sources":["../../../src/download/core/imageResolution.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;EAKiB,CAAC;AAEhD,sCAAsC;AACtC,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;CAAuB,CAAC;AAa7D,8CAA8C;AAC9C,MAAM,WAAW,SAAS;IACxB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACtC,KAAK,EAAE,MAAM,GACZ,SAAS,CAoBX;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,CAK3D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,MAAM,CAG9D"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The sizes a picture leaves the editor at.
|
|
3
|
-
*
|
|
4
|
-
* A drawing unit is about a screen pixel, so the multipliers read as what the
|
|
5
|
-
* picture is for rather than as numbers: what is on screen, the same again on a
|
|
6
|
-
* retina display, and the two steps up a figure needs to survive being printed
|
|
7
|
-
* or thrown on a wall.
|
|
8
|
-
*/
|
|
9
|
-
export const IMAGE_RESOLUTIONS = [
|
|
10
|
-
{ id: 'screen', label: 'Screen (1×)', scale: 1 },
|
|
11
|
-
{ id: 'retina', label: 'Retina (2×)', scale: 2 },
|
|
12
|
-
{ id: 'print', label: 'Print (4×)', scale: 4 },
|
|
13
|
-
{ id: 'poster', label: 'Poster (8×)', scale: 8 },
|
|
14
|
-
];
|
|
15
|
-
/**
|
|
16
|
-
* The resolution a picture is written out at unless another is picked: what is
|
|
17
|
-
* on screen, doubled, which is what a picture pasted into a document wants.
|
|
18
|
-
*/
|
|
19
|
-
export const DEFAULT_IMAGE_RESOLUTION = IMAGE_RESOLUTIONS[1];
|
|
20
|
-
/**
|
|
21
|
-
* Longest side a browser rasterizes reliably.
|
|
22
|
-
*
|
|
23
|
-
* Above roughly this, Safari and Chrome quietly hand back an empty canvas
|
|
24
|
-
* instead of refusing, so the picture would be saved blank.
|
|
25
|
-
*/
|
|
26
|
-
const MAXIMUM_SIDE = 8192;
|
|
27
|
-
/** Most pixels a rasterized picture is allowed to hold. */
|
|
28
|
-
const MAXIMUM_PIXELS = 32 * 1024 * 1024;
|
|
29
|
-
/**
|
|
30
|
-
* How big a rectangle of the drawing comes out at a given resolution.
|
|
31
|
-
*
|
|
32
|
-
* The resolution is a wish rather than an instruction: a wide glycan asked for
|
|
33
|
-
* at 8× would run past what a browser can rasterize and come back blank, so the
|
|
34
|
-
* scale is brought down until the picture fits instead. The scale it settled on
|
|
35
|
-
* comes back with the size, so what will actually be written can be shown
|
|
36
|
-
* before it is.
|
|
37
|
-
* @param box - The rectangle being written out.
|
|
38
|
-
* @param box.width - How wide it is, in drawing units.
|
|
39
|
-
* @param box.height - How tall it is, in drawing units.
|
|
40
|
-
* @param scale - How many pixels each drawing unit should become.
|
|
41
|
-
* @returns The size, and the scale it was reached at.
|
|
42
|
-
*/
|
|
43
|
-
export function imageSize(box, scale) {
|
|
44
|
-
const wanted = Number.isFinite(scale) && scale > 0 ? scale : 1;
|
|
45
|
-
const width = Math.max(box.width, 1);
|
|
46
|
-
const height = Math.max(box.height, 1);
|
|
47
|
-
const limit = Math.min(MAXIMUM_SIDE / width, MAXIMUM_SIDE / height, Math.sqrt(MAXIMUM_PIXELS / (width * height)));
|
|
48
|
-
const used = Math.min(wanted, limit);
|
|
49
|
-
// A picture held back by the limit is rounded down rather than to the nearest
|
|
50
|
-
// pixel, so rounding cannot put it back over what it was held to.
|
|
51
|
-
const toPixels = used < wanted ? Math.floor : Math.round;
|
|
52
|
-
return {
|
|
53
|
-
width: Math.max(1, toPixels(width * used)),
|
|
54
|
-
height: Math.max(1, toPixels(height * used)),
|
|
55
|
-
scale: used,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* The resolution an identifier stands for.
|
|
60
|
-
* @param id - What was picked.
|
|
61
|
-
* @returns The resolution, falling back to the default one.
|
|
62
|
-
*/
|
|
63
|
-
export function imageResolution(id) {
|
|
64
|
-
return (IMAGE_RESOLUTIONS.find((resolution) => resolution.id === id) ??
|
|
65
|
-
DEFAULT_IMAGE_RESOLUTION);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* A size, written the way it is shown next to the resolution it comes from.
|
|
69
|
-
* @param size - The size to write, `null` when nothing is drawn.
|
|
70
|
-
* @returns The text, e.g. `1440 × 620 px`.
|
|
71
|
-
*/
|
|
72
|
-
export function formatImageSize(size) {
|
|
73
|
-
if (!size)
|
|
74
|
-
return 'nothing to export';
|
|
75
|
-
return `${size.width} × ${size.height} px`;
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=imageResolution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"imageResolution.js","sourceRoot":"","sources":["../../../src/download/core/imageResolution.ts"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE;IAChD,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE;IAChD,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE;IAC9C,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE;CACH,CAAC;AAKhD;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,2DAA2D;AAC3D,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAexC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,SAAS,CACvB,GAAsC,EACtC,KAAa;IAEb,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAEvC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CACpB,YAAY,GAAG,KAAK,EACpB,YAAY,GAAG,MAAM,EACrB,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAC7C,CAAC;IACF,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrC,8EAA8E;IAC9E,kEAAkE;IAClE,MAAM,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IAEzD,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;QAC1C,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QAC5C,KAAK,EAAE,IAAI;KACZ,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,OAAO,CACL,iBAAiB,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC;QAC5D,wBAAwB,CACzB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAsB;IACpD,IAAI,CAAC,IAAI;QAAE,OAAO,mBAAmB,CAAC;IACtC,OAAO,GAAG,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,MAAM,KAAK,CAAC;AAC7C,CAAC"}
|