@esmirnov.ai/sperm-lab 0.4.1 → 0.4.2
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 +1 -1
- package/dist/styles.css +12 -12
- package/package.json +1 -1
package/dist/react/sperm-lab.js
CHANGED
|
@@ -415,7 +415,7 @@ 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
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: [controlColumn("left"), _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." })] }), 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." }), 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" })] })] })] }), _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." }), _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" })] }), _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"] })] }), _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 && _jsxs("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." }), _jsx("button", { type: "button", onClick: restore, children: "Return to current settings" })] })] }), controlColumn("right"), _jsxs("section", { className: "sl-readouts", "aria-labelledby": `${prefix}-counts-title`, children: [_jsx("h2", { id: `${prefix}-counts-title`, children: "In this sample" }), _jsx("dl", { children: [
|
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;
|
|
@@ -30,11 +31,16 @@
|
|
|
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; }
|
|
@@ -165,8 +171,6 @@
|
|
|
165
171
|
.sl-prepared-note button { margin-top: 3px; padding-inline: 0; border: 0; text-decoration: underline; text-underline-offset: 3px; }
|
|
166
172
|
@container sperm-lab (max-width: 1000px) {
|
|
167
173
|
.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
174
|
.sl-canvas-wrap { min-height: 280px; }
|
|
171
175
|
.sl-defect-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
172
176
|
}
|
|
@@ -174,8 +178,6 @@
|
|
|
174
178
|
.sl-workbench { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "field field" "readouts readouts" "catalog catalog" "inspector inspector" "left right"; gap: 22px; }
|
|
175
179
|
.sl-defect-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
|
|
176
180
|
.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
181
|
.sl-factor-row input[type="range"] { min-height: 44px; }
|
|
180
182
|
.sl-factor-help summary { min-height: 36px; }
|
|
181
183
|
.sl-canvas-wrap { min-height: 300px; max-height: 450px; aspect-ratio: 1.6; }
|
|
@@ -186,8 +188,6 @@
|
|
|
186
188
|
.sl-workbench { grid-template-columns: minmax(0, 1fr); grid-template-areas: "field" "readouts" "catalog" "inspector" "left" "right"; }
|
|
187
189
|
.sl-defect-catalog { grid-template-columns: minmax(0, 1fr); }
|
|
188
190
|
.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
191
|
.sl-factor-help summary { min-height: 38px; font-size: 11px; }
|
|
192
192
|
.sl-factor-help p, .sl-factor-help a { font-size: 12px; }
|
|
193
193
|
.sl-factor-help a { min-height: 44px; }
|
|
@@ -199,7 +199,6 @@
|
|
|
199
199
|
.sl-mechanisms > ul { grid-template-columns: minmax(0, 1fr); }
|
|
200
200
|
}
|
|
201
201
|
@container sperm-lab (max-width: 330px) {
|
|
202
|
-
.sl-factor-row { grid-template-columns: 104px minmax(50px, 1fr) 26px; gap: 6px; }
|
|
203
202
|
.sl-readouts dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
204
203
|
.sl-sample-tools button { font-size: 10px; }
|
|
205
204
|
}
|
|
@@ -207,5 +206,6 @@
|
|
|
207
206
|
@media (forced-colors: active) {
|
|
208
207
|
.sl-lab { --sl-ink: CanvasText; --sl-accent: LinkText; --sl-rule: CanvasText; }
|
|
209
208
|
.sl-canvas-wrap { border: 1px solid CanvasText; }
|
|
209
|
+
.sl-factor-row input[type="range"] { appearance: auto; -webkit-appearance: auto; }
|
|
210
210
|
}
|
|
211
211
|
@media print { .sl-lab canvas, .sl-actions, .sl-sample-tools, .sl-factor-row input { display: none; } }
|
package/package.json
CHANGED