fix: stack exercise progress selector value
This commit is contained in:
1 parent
7d2460c2c2
commit
bcbde6245c
4 files changed
+22
-3
No files matched your search
@@ -248,7 +248,7 @@ export function Row({ icon, iconTint, title, subtitle, value, accessory = 'none'
|
||||
// theme entirely — on dark mode it flashes a white sheet — and can't show more
|
||||
// than a bare label per option. This opens our own sheet with a checkmark on the
|
||||
// current value, which is also how iOS itself handles a long option list.
|
||||
export function SelectRow({ icon, iconTint, title, value, options, onChange, sheetTitle }) {
|
||||
export function SelectRow({ icon, iconTint, title, value, options, onChange, sheetTitle, stackedValue = false }) {
|
||||
const cur = options.find(o => o.value === value)
|
||||
const open = () => {
|
||||
const { openSheet } = require_ui()
|
||||
@@ -270,7 +270,8 @@ export function SelectRow({ icon, iconTint, title, value, options, onChange, she
|
||||
return h
|
||||
}
|
||||
return (
|
||||
<Row icon={icon} iconTint={iconTint} title={title} value={cur ? cur.label : value} accessory="chevron" onClick={open} />
|
||||
<Row icon={icon} iconTint={iconTint} title={title} value={cur ? cur.label : value} accessory="chevron" onClick={open}
|
||||
className={stackedValue ? 'lrow-stack-value' : ''} />
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -241,6 +241,13 @@ h4.sec{
|
||||
.lrow-c{color:var(--label);font-size:15px;flex:none;--icon-stroke:2.4}
|
||||
.lrow-k{color:var(--acc);font-size:17px;flex:none;--icon-stroke:2.4}
|
||||
.lrow.danger,.lrow.danger .lrow-t{color:var(--red)}
|
||||
/* The Stats exercise name gets its own line so long names cannot run into the title. */
|
||||
.lrow.lrow-stack-value{
|
||||
display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto auto;
|
||||
}
|
||||
.lrow.lrow-stack-value .lrow-m{grid-column:1;grid-row:1}
|
||||
.lrow.lrow-stack-value .lrow-v{grid-column:1;grid-row:2;text-align:left}
|
||||
.lrow.lrow-stack-value .lrow-c{grid-column:2;grid-row:1 / span 2;align-self:center}
|
||||
/* an (i) before a row's control: painted small and dim so the control stays the loud thing,
|
||||
but with a finger-sized target like everything else — the padding is the hit area and the
|
||||
vertical negative margin keeps it from making the row taller. The horizontal ones pull the
|
||||
|
||||
@@ -401,7 +401,7 @@ export default function Stats() {
|
||||
<h2>{t('Exercise progress')}</h2>
|
||||
{exHist.length ? <>
|
||||
<div className="sect-b" style={{ marginBottom: 10 }}>
|
||||
<SelectRow title={t('Exercise')} sheetTitle={t('Exercise progress')} value={curEx} onChange={setExId}
|
||||
<SelectRow title={t('Exercise')} sheetTitle={t('Exercise progress')} value={curEx} onChange={setExId} stackedValue
|
||||
options={exHist.map(id => ({ value: id, label: nameOf(id) + (exCurrent[id].mx ? ' ' + '—' + ' ' + fmtNum(exCurrent[id].mx) + ' ' + exCurrent[id].unit : '') }))} />
|
||||
</div>
|
||||
{exOpts.length > 1 && <Segmented className="seg-range" value={onEff ? 'effort' : onE1 ? 'e1rm' : 'top'} onChange={setExMetric} options={exOpts} />}
|
||||
|
||||
@@ -3,6 +3,8 @@ import { readFileSync } from 'node:fs'
|
||||
import { bestWeightForEntry, metricModeForEntry, metricRowsForEntry } from '../lib/history.js'
|
||||
|
||||
const source = readFileSync(new URL('./Stats.jsx', import.meta.url), 'utf8')
|
||||
const uiSource = readFileSync(new URL('../components/ui.jsx', import.meta.url), 'utf8')
|
||||
const cssSource = readFileSync(new URL('../index.css', import.meta.url), 'utf8')
|
||||
|
||||
describe('Stats mixed-entry metric contract', () => {
|
||||
it('selects authoritative reps rows before timed rows without stale topW', () => {
|
||||
@@ -27,4 +29,13 @@ describe('Stats mixed-entry metric contract', () => {
|
||||
expect(source).not.toContain('const loggedMode = entryMode(en)')
|
||||
expect(source).not.toContain('(en.topW || 0)')
|
||||
})
|
||||
|
||||
it('stacks the Stats exercise selector value without changing shared SelectRow defaults', () => {
|
||||
expect(source).toContain("onChange={setExId} stackedValue")
|
||||
expect(uiSource).toContain('sheetTitle, stackedValue = false')
|
||||
expect(uiSource).toContain("className={stackedValue ? 'lrow-stack-value' : ''}")
|
||||
expect(cssSource).toContain('.lrow.lrow-stack-value .lrow-m{grid-column:1;grid-row:1}')
|
||||
expect(cssSource).toContain('.lrow.lrow-stack-value .lrow-v{grid-column:1;grid-row:2;text-align:left}')
|
||||
expect(cssSource).toContain('overflow:hidden;text-overflow:ellipsis;white-space:nowrap')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user