@esmirnov.ai/sperm-lab 0.4.1 → 0.4.3
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/dist/react/sperm-lab.js +2 -2
- package/dist/styles.css +17 -16
- package/package.json +1 -1
package/dist/react/sperm-lab.js
CHANGED
|
@@ -415,10 +415,10 @@ export function SpermLab({ seed = 42, count = 48, initialFactors, initialFactor,
|
|
|
415
415
|
return _jsx("aside", { className: `sl-controls sl-controls-${side}`, "aria-label": `${side === "left" ? "Exercise and habits" : "Body and chemicals"} factors`, children: groups.filter(group => group.side === side).map(group => _jsxs("fieldset", { className: "sl-factor-group", children: [_jsx("legend", { children: group.title }), group.ids.map(id => {
|
|
416
416
|
const factor = FACTORS.find(item => item.id === id), value = Math.round((factors[id] ?? 0) * 100);
|
|
417
417
|
const rangeId = `${prefix}-${id}`;
|
|
418
|
-
return _jsxs("div", { className: "sl-factor", children: [_jsxs("div", { className: "sl-factor-row", children: [_jsx("label", { htmlFor: rangeId, children: shortLabels[id] }), _jsx("input", { id: rangeId, "data-factor": id, type: "range", min: "0", max: "100", step: "1", value: value, "aria-label": shortLabels[id] === factor.title ? factor.title : `${shortLabels[id]}: ${factor.title}`, "aria-valuetext": `${value} of 100, relative illustrative setting`, onChange: event => changeFactor(id, Number(event.target.value) / 100) }), _jsx("output", { htmlFor: rangeId, children: value })] }), _jsxs("details", { className: "sl-factor-help", children: [_jsxs("summary", { children: [_jsxs("span", { children: ["About ", shortLabels[id].toLowerCase()] }), _jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: _jsx("path", { d: "m5 6 3 3 3-3" }) })] }), _jsx("p", { children: factor.summary }), _jsx("p", { children: factor.mechanism }), _jsx("p", { className: "sl-evidence", children: factor.evidence }), _jsx("p", { children: factor.limits }), _jsx("p", { className: "sl-help-timescale", children: factor.timescale }), _jsx("ul", { children: factor.sources.map(source => _jsx("li", { children: _jsx("a", { href: source.url, target: "_blank", rel: "noopener noreferrer", children: source.title }) }, source.url)) })] })] }, id);
|
|
418
|
+
return _jsxs("div", { className: "sl-factor", children: [_jsxs("div", { className: "sl-factor-row", children: [_jsx("label", { htmlFor: rangeId, children: shortLabels[id] }), _jsx("input", { id: rangeId, "data-factor": id, type: "range", min: "0", max: "100", step: "1", value: value, "aria-label": shortLabels[id] === factor.title ? factor.title : `${shortLabels[id]}: ${factor.title}`, "aria-valuetext": `${value} of 100, relative illustrative setting`, style: { "--sl-progress": `${value}%` }, onChange: event => changeFactor(id, Number(event.target.value) / 100) }), _jsx("output", { htmlFor: rangeId, children: value })] }), _jsxs("details", { className: "sl-factor-help", children: [_jsxs("summary", { children: [_jsxs("span", { children: ["About ", shortLabels[id].toLowerCase()] }), _jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: _jsx("path", { d: "m5 6 3 3 3-3" }) })] }), _jsx("p", { children: factor.summary }), _jsx("p", { children: factor.mechanism }), _jsx("p", { className: "sl-evidence", children: factor.evidence }), _jsx("p", { children: factor.limits }), _jsx("p", { className: "sl-help-timescale", children: factor.timescale }), _jsx("ul", { children: factor.sources.map(source => _jsx("li", { children: _jsx("a", { href: source.url, target: "_blank", rel: "noopener noreferrer", children: source.title }) }, source.url)) })] })] }, id);
|
|
419
419
|
})] }, group.title)) });
|
|
420
420
|
}
|
|
421
|
-
return _jsxs("div", { ref: root, className: `sperm-lab sl-lab sl-lab-v3 ${className}`.trim(), style: style, children: [_jsxs("div", { className: "sl-intro-line", children: [_jsxs("p", { children: [_jsx("strong", { children: "Change the factors. Watch one sample." }), " Each slider acts independently."] }), _jsx("span", { children: "All 12 settings use relative scales." })] }), _jsxs("div", { className: "sl-workbench", children: [
|
|
421
|
+
return _jsxs("div", { ref: root, className: `sperm-lab sl-lab sl-lab-v3 ${className}`.trim(), style: style, children: [_jsxs("div", { className: "sl-intro-line", children: [_jsxs("p", { children: [_jsx("strong", { children: "Change the factors. Watch one sample." }), " Each slider acts independently."] }), _jsx("span", { children: "All 12 settings use relative scales." })] }), _jsxs("div", { className: "sl-workbench", children: [_jsxs("section", { className: "sl-field", "aria-label": "Live sperm sample", children: [_jsxs("div", { className: "sl-sample-bar", children: [_jsxs("div", { children: [_jsx("h2", { children: prepared ? "Prepared defect examples" : defaults.teachingPopulation ? "Illustrative sample" : "Live sample" }), _jsxs("span", { children: [metrics.total, " fictional cells"] })] }), _jsxs("div", { className: "sl-actions", children: [_jsx("button", { className: "sl-explore", type: "button", "aria-pressed": popupOpen, "aria-controls": `${prefix}-sample`, onClick: explore, children: "Explore" }), _jsx("button", { type: "button", "aria-pressed": paused, onClick: () => setPaused(value => !value), children: paused ? "Resume" : "Pause" }), _jsx("button", { type: "button", onClick: reset, children: "Reset sample" })] })] }), _jsxs("div", { className: "sl-concentration", children: [_jsx("span", { id: `${prefix}-concentration`, children: "Concentration" }), _jsxs("output", { "data-concentration": metrics.total, "aria-labelledby": `${prefix}-concentration`, children: [metrics.total, " cells / model field"] }), _jsx("small", { children: "Synthetic model count. No clinical units." })] }), unavailable && _jsx("p", { role: "status", children: "Canvas is unavailable. The sample counts, cell inspector, and factor explanations remain available." }), _jsxs("div", { id: `${prefix}-sample`, className: "sl-canvas-wrap", "data-popup": popupOpen && Boolean(selected), style: { "--sl-popup-min-height": `${popupHeight}px` }, children: [_jsx("canvas", { ref: canvas, tabIndex: 0, role: "group", "aria-label": "Interactive sperm sample. Use Explore to follow a swimmer. Drag to stir. Click a cell for details. Arrow keys create currents. Enter selects the next cell and opens its details. Escape closes details. Space pauses.", "aria-describedby": `${prefix}-help`, onPointerDown: pointerDown, onPointerMove: pointerMove, onPointerUp: pointerUp, onPointerCancel: () => actions.current.release(), onLostPointerCapture: () => { pointer.current = null; }, onKeyDown: keyboard, onContextMenu: event => event.preventDefault(), children: "The sample needs canvas support. Use the cell inspector and model counts for a text alternative." }), popupOpen && selected && _jsxs(_Fragment, { children: [_jsx("svg", { className: "sl-popup-connector", "aria-hidden": "true", children: _jsx("line", { ref: popupConnector }) }), _jsxs("div", { ref: popup, className: "sl-cell-popup", role: "dialog", "aria-modal": "false", "aria-labelledby": `${prefix}-popup-title`, "data-cell-popup": "true", "data-cell-id": selected.id, children: [_jsxs("header", { children: [_jsxs("h3", { id: `${prefix}-popup-title`, children: ["Cell ", selected.id + 1] }), _jsx("button", { ref: popupClose, className: "sl-popup-close", type: "button", "aria-label": "Close cell details", onClick: () => { setPopupOpen(false); canvas.current?.focus({ preventScroll: true }); }, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "m5 5 10 10M15 5 5 15" }) }) })] }), _jsx(CellPopupDetails, { cell: selected, dna: dna }), _jsx("button", { className: "sl-popup-anatomy", type: "button", onClick: () => { setPopupOpen(false); requestAnimationFrame(() => inspector.current?.scrollIntoView({ block: "start", behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth" })); }, children: "Full anatomy" })] })] })] }), _jsxs("div", { className: "sl-sample-tools", children: [_jsx("button", { type: "button", onClick: () => current(.3, .1), disabled: paused, children: "Create a current" }), _jsx("button", { type: "button", onClick: () => nextCell(), children: "Next swimmer" }), _jsx("button", { type: "button", onClick: prepareExamples, children: "Inspect defect examples" }), prepared && _jsx("button", { type: "button", onClick: restore, children: "Return to current settings" })] }), _jsxs("div", { className: "sl-display", children: [_jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: dna, onChange: event => setDna(event.target.checked) }), "DNA overlay"] }), _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: trails, onChange: event => setTrails(event.target.checked) }), "Trails"] }), _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: slowMotion, onChange: event => setSlowMotion(event.target.checked) }), "Slow motion"] })] })] }), controlColumn("left"), controlColumn("right"), _jsxs("div", { className: "sl-sample-notes", children: [_jsx("p", { id: `${prefix}-help`, className: "sl-canvas-help", children: "Use Explore to follow a swimmer. Click or tap another cell to switch. Drag to stir the sample." }), defaults.teachingPopulation && !prepared && _jsx("p", { className: "sl-teaching-population", children: "The teaching sample includes common defect examples. Counts do not show their frequency in people." }), _jsx("p", { className: "sl-overlay-note", children: "Red marks illustrated abnormalities. Disconnected red pieces inside the nucleus show schematic DNA fragmentation. The overlay is not ordinary microscopy." }), _jsx("p", { className: "sl-model-note", children: "Sliders prepare an illustrative later cohort. Counts do not predict personal fertility." }), prepared && _jsx("div", { className: "sl-prepared-note", children: _jsx("p", { children: "These examples contain head, tail, midpiece, and DNA traits. They do not show the effects of a specific exposure." }) })] }), _jsxs("section", { className: "sl-readouts", "aria-labelledby": `${prefix}-counts-title`, children: [_jsx("h2", { id: `${prefix}-counts-title`, children: "In this sample" }), _jsx("dl", { children: [
|
|
422
422
|
["Cells", metrics.total], ["Active motion", metrics.motile], ["Forward", metrics.progressive], ["Slow", metrics.slow],
|
|
423
423
|
["Nonprogressive", metrics.nonprogressive], ["Still", metrics.immotile], ["Alive", metrics.alive],
|
|
424
424
|
].map(([label, value]) => _jsxs("div", { children: [_jsx("dt", { children: label }), _jsx("dd", { children: value })] }, label)) })] }), _jsxs("section", { className: "sl-catalog", "aria-labelledby": `${prefix}-catalog-title`, children: [_jsxs("header", { children: [_jsx("h2", { id: `${prefix}-catalog-title`, children: "Common examples" }), _jsx("p", { children: "These curated examples explain separate traits. Their frequency is not clinical prevalence. Select an example to inspect its cell." })] }), _jsx("div", { className: "sl-defect-catalog", children: DEFECT_CATALOG.map(defect => {
|
package/dist/styles.css
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
--sl-accent: #785448;
|
|
5
5
|
--sl-paper: #eff2ed;
|
|
6
6
|
--sl-rule: color-mix(in oklch, var(--sl-ink) 22%, transparent);
|
|
7
|
+
--sl-track: color-mix(in oklch, var(--sl-ink) 28%, var(--sl-surface));
|
|
7
8
|
--sl-sage: #6f897c;
|
|
8
9
|
--sl-clay: #a67769;
|
|
9
10
|
--sl-damage: #b82735;
|
|
@@ -23,18 +24,23 @@
|
|
|
23
24
|
.sl-intro-line p { margin: 0; font-size: 13px; }
|
|
24
25
|
.sl-intro-line strong { font-weight: 600; }
|
|
25
26
|
.sl-intro-line > span { font-size: 11px; opacity: .75; }
|
|
26
|
-
.sl-workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.3fr) minmax(0, 1fr); grid-template-areas: "left field right" "left readouts right" "catalog catalog catalog" "inspector inspector inspector"; align-items: start; gap: 20px 24px; }
|
|
27
|
+
.sl-workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.3fr) minmax(0, 1fr); grid-template-areas: "left field right" "left notes right" "left readouts right" "catalog catalog catalog" "inspector inspector inspector"; align-items: start; gap: 20px 24px; }
|
|
27
28
|
.sl-controls { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
|
|
28
29
|
.sl-controls-left { grid-area: left; }
|
|
29
30
|
.sl-controls-right { grid-area: right; }
|
|
30
31
|
.sl-factor-group { min-width: 0; border: 0; padding: 0; margin: 0; }
|
|
31
32
|
.sl-factor-group + .sl-factor-group { padding-top: 16px; border-top: 1px solid var(--sl-rule); }
|
|
32
33
|
.sl-factor-group legend { width: 100%; padding: 0; margin-bottom: 8px; font-size: 13px; line-height: 1.5; font-weight: 600; }
|
|
33
|
-
.sl-factor + .sl-factor { margin-top:
|
|
34
|
-
.sl-factor-row { display: grid; grid-template-columns: minmax(
|
|
35
|
-
.sl-factor-row label { font-size:
|
|
36
|
-
.sl-factor-row input[type="range"] { display: block; width: 100%; min-width: 0;
|
|
37
|
-
.sl-factor-row
|
|
34
|
+
.sl-factor + .sl-factor { margin-top: 12px; }
|
|
35
|
+
.sl-factor-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; }
|
|
36
|
+
.sl-factor-row label { grid-column: 1; grid-row: 1; font-size: 13px; line-height: 18px; overflow-wrap: normal; }
|
|
37
|
+
.sl-factor-row input[type="range"] { grid-column: 1 / -1; grid-row: 2; appearance: none; -webkit-appearance: none; display: block; width: 100%; min-width: 0; height: 44px; padding: 0; margin: 0; border: 0; background: transparent; accent-color: var(--sl-accent); cursor: pointer; }
|
|
38
|
+
.sl-factor-row input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; background: linear-gradient(to right, var(--sl-accent) 0 var(--sl-progress), var(--sl-track) var(--sl-progress) 100%); }
|
|
39
|
+
.sl-factor-row input[type="range"]::-moz-range-track { height: 8px; border-radius: 999px; background: var(--sl-track); }
|
|
40
|
+
.sl-factor-row input[type="range"]::-moz-range-progress { height: 8px; border-radius: 999px; background: var(--sl-accent); }
|
|
41
|
+
.sl-factor-row input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; margin-top: -6px; border: 0; border-radius: 50%; background: var(--sl-accent); }
|
|
42
|
+
.sl-factor-row input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--sl-accent); }
|
|
43
|
+
.sl-factor-row output { grid-column: 2; grid-row: 1; font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; text-align: right; opacity: .8; }
|
|
38
44
|
.sl-factor-help { min-width: 0; }
|
|
39
45
|
.sl-factor-help summary { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 26px; width: 100%; cursor: pointer; font-size: 10px; color: var(--sl-accent); list-style: none; }
|
|
40
46
|
.sl-factor-help summary::-webkit-details-marker { display: none; }
|
|
@@ -47,6 +53,8 @@
|
|
|
47
53
|
.sl-factor-help ul { margin: 8px 0 0; padding: 0; list-style: none; }
|
|
48
54
|
.sl-factor-help a { display: inline-flex; align-items: center; min-height: 32px; font-size: 10px; line-height: 1.5; color: var(--sl-accent); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
|
|
49
55
|
.sl-field { grid-area: field; min-width: 0; }
|
|
56
|
+
.sl-sample-notes { grid-area: notes; min-width: 0; }
|
|
57
|
+
.sl-sample-notes > :first-child { margin-top: 0; }
|
|
50
58
|
.sl-sample-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; padding-bottom: 9px; border-bottom: 1px solid var(--sl-rule); }
|
|
51
59
|
.sl-sample-bar > div:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
|
|
52
60
|
.sl-sample-bar h2 { margin: 0; font-size: 14px; line-height: 1.5; font-weight: 600; }
|
|
@@ -162,20 +170,15 @@
|
|
|
162
170
|
.sl-mechanisms li small { margin-top: 5px; color: var(--sl-accent); font-size: 10px; }
|
|
163
171
|
.sl-prepared-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--sl-rule); }
|
|
164
172
|
.sl-prepared-note p { margin: 0; font-size: 11px; }
|
|
165
|
-
.sl-prepared-note button { margin-top: 3px; padding-inline: 0; border: 0; text-decoration: underline; text-underline-offset: 3px; }
|
|
166
173
|
@container sperm-lab (max-width: 1000px) {
|
|
167
174
|
.sl-workbench { grid-template-columns: minmax(0, 1fr) minmax(0, 2.3fr) minmax(0, 1fr); gap: 18px 18px; }
|
|
168
|
-
.sl-factor-row { grid-template-columns: minmax(68px, 1.1fr) minmax(32px, 1fr) 22px; gap: 5px; }
|
|
169
|
-
.sl-factor-row label { font-size: 11px; }
|
|
170
175
|
.sl-canvas-wrap { min-height: 280px; }
|
|
171
176
|
.sl-defect-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
172
177
|
}
|
|
173
178
|
@container sperm-lab (max-width: 800px) {
|
|
174
|
-
.sl-workbench { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "field field" "readouts readouts" "catalog catalog" "inspector inspector"
|
|
179
|
+
.sl-workbench { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "field field" "left right" "readouts readouts" "notes notes" "catalog catalog" "inspector inspector"; gap: 22px; }
|
|
175
180
|
.sl-defect-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
|
|
176
181
|
.sl-controls { padding-top: 18px; border-top: 1px solid var(--sl-rule); }
|
|
177
|
-
.sl-factor-row { grid-template-columns: minmax(100px, 1.2fr) minmax(50px, 1fr) 28px; gap: 8px; }
|
|
178
|
-
.sl-factor-row label { font-size: 12px; }
|
|
179
182
|
.sl-factor-row input[type="range"] { min-height: 44px; }
|
|
180
183
|
.sl-factor-help summary { min-height: 36px; }
|
|
181
184
|
.sl-canvas-wrap { min-height: 300px; max-height: 450px; aspect-ratio: 1.6; }
|
|
@@ -183,11 +186,9 @@
|
|
|
183
186
|
.sl-inspector-content { gap: 18px; }
|
|
184
187
|
}
|
|
185
188
|
@container sperm-lab (max-width: 560px) {
|
|
186
|
-
.sl-workbench { grid-template-columns: minmax(0, 1fr); grid-template-areas: "field" "
|
|
189
|
+
.sl-workbench { grid-template-columns: minmax(0, 1fr); grid-template-areas: "field" "left" "right" "readouts" "notes" "catalog" "inspector"; }
|
|
187
190
|
.sl-defect-catalog { grid-template-columns: minmax(0, 1fr); }
|
|
188
191
|
.sl-canvas-wrap { min-height: 270px; max-height: 360px; aspect-ratio: 1.15; }
|
|
189
|
-
.sl-factor-row { grid-template-columns: minmax(110px, 1.2fr) minmax(80px, 1fr) 30px; }
|
|
190
|
-
.sl-factor-row label { font-size: 13px; }
|
|
191
192
|
.sl-factor-help summary { min-height: 38px; font-size: 11px; }
|
|
192
193
|
.sl-factor-help p, .sl-factor-help a { font-size: 12px; }
|
|
193
194
|
.sl-factor-help a { min-height: 44px; }
|
|
@@ -199,7 +200,6 @@
|
|
|
199
200
|
.sl-mechanisms > ul { grid-template-columns: minmax(0, 1fr); }
|
|
200
201
|
}
|
|
201
202
|
@container sperm-lab (max-width: 330px) {
|
|
202
|
-
.sl-factor-row { grid-template-columns: 104px minmax(50px, 1fr) 26px; gap: 6px; }
|
|
203
203
|
.sl-readouts dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
204
204
|
.sl-sample-tools button { font-size: 10px; }
|
|
205
205
|
}
|
|
@@ -207,5 +207,6 @@
|
|
|
207
207
|
@media (forced-colors: active) {
|
|
208
208
|
.sl-lab { --sl-ink: CanvasText; --sl-accent: LinkText; --sl-rule: CanvasText; }
|
|
209
209
|
.sl-canvas-wrap { border: 1px solid CanvasText; }
|
|
210
|
+
.sl-factor-row input[type="range"] { appearance: auto; -webkit-appearance: auto; }
|
|
210
211
|
}
|
|
211
212
|
@media print { .sl-lab canvas, .sl-actions, .sl-sample-tools, .sl-factor-row input { display: none; } }
|
package/package.json
CHANGED