Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Settings: long titles and previews wrap instead of losing their end

Duarte Santosf20652b059fe
diff --git a/frontend/src/index.css b/frontend/src/index.css
index dbfb08eec..43ffd9639 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1910,7 +1910,10 @@ body.no-tabbar.resting #toast{bottom:calc(100px + var(--sab))}
min-width:0;max-width:50vw;justify-self:start}
.sp-back span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sp-back .icn{font-size:22px;--icon-stroke:2.2;flex:none}
-.sp-title{text-align:center;font-weight:600;font-size:17px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}
+/* A long title ("Alertas do temporizador", "Megjelenés és Kezdőlap") takes a second line rather
+ than lose its end to an ellipsis next to a whole back label. */
+.sp-title{text-align:center;font-weight:600;font-size:17px;line-height:1.2;margin:0;overflow:hidden;overflow-wrap:anywhere;-webkit-hyphens:auto;hyphens:auto;
+ display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;text-wrap:balance}
.sp-root-title{font-size:34px;line-height:1.06;font-weight:700;letter-spacing:-.028em;margin:2px 0 10px}
@media (max-width:420px){.sp-root-title{font-size:30px}}
.sp-search{margin-bottom:18px}
@@ -1921,6 +1924,19 @@ body.no-tabbar.resting #toast{bottom:calc(100px + var(--sab))}
.sp-acct .lrow-t{font-size:19px;font-weight:600}
.sp-avatar.on{background:var(--acc-soft);color:var(--acc);font-size:24px;font-weight:700}
.sp-version{text-align:center;margin-top:4px;line-height:1.6}
+/* The root rows' previews ("2:00 de descanso · Tarjetas", "Som · Vibração") are two or three facts, and a
+ one-line ellipsis cut all but the first. They wrap instead, up to three lines, and never below
+ their longest word (min-content, since overflow:hidden would make auto mean 0). On the narrowest phones there is no room beside
+ the title at all, so the preview moves under it, like a subtitle. */
+.lrow.sp-root-row .lrow-v{white-space:normal;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;line-clamp:3;
+ min-width:min-content;max-width:62%;line-height:1.25;text-wrap:balance}
+@media (max-width:360px){
+ .lrow.sp-root-row:has(.lrow-v){display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;column-gap:12px;row-gap:1px}
+ .lrow.sp-root-row:has(.lrow-v) .lrow-i{grid-column:1;grid-row:1 / span 2}
+ .lrow.sp-root-row:has(.lrow-v) .lrow-m{grid-column:2;grid-row:1}
+ .lrow.sp-root-row .lrow-v{grid-column:2;grid-row:2;min-width:0;max-width:none;text-align:start;font-size:15px;-webkit-line-clamp:2;line-clamp:2}
+ .lrow.sp-root-row:has(.lrow-v) .lrow-c{grid-column:3;grid-row:1 / span 2}
+}
.lrow.dis .lrow-i,.lrow.dis .lrow-t,.lrow.dis .sw{opacity:.45}
/* a row a search result jumped to: a short accent wash that fades out */
.lrow.sp-flash,.btn.sp-flash{animation:spflash 1.8s ease}
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx
index 0a15d1d01..a4adca325 100644
--- a/frontend/src/views/Settings.jsx
+++ b/frontend/src/views/Settings.jsx
@@ -916,7 +916,7 @@ function SettingsRoot({ ctx, preview, open, user, sync, home, go }) {
{ROOT_GROUPS.map(g => g.filter(id => pageVisible(id, ctx))).filter(g => g.length).map(g => (
<Section key={g[0]}>
{g.map(id => <Row key={id} icon={PAGES[id].icon} iconTint={PAGES[id].tint} title={t(PAGES[id].title)}
- value={preview[id]?.() || null} accessory="chevron" onClick={() => open(id)} />)}
+ value={preview[id]?.() || null} accessory="chevron" onClick={() => open(id)} className="sp-root-row" />)}
</Section>
))}
<div className="dim small sp-version">openGym v{__APP_VERSION__}</div>
diff --git a/frontend/src/views/settings-pages.test.jsx b/frontend/src/views/settings-pages.test.jsx
index 4343827a1..3c3727e17 100644
--- a/frontend/src/views/settings-pages.test.jsx
+++ b/frontend/src/views/settings-pages.test.jsx
@@ -4,6 +4,8 @@
import React, { act } from 'react'
import { createRoot } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { resolve } from 'node:path'
import { PAGES, PAGE_IDS, ROOT_GROUPS, SEARCH, pageVisible, searchSettings, pageTrail, fold } from './settings-pages.js'
globalThis.IS_REACT_ACT_ENVIRONMENT = true
@@ -96,6 +98,22 @@ describe('the root', () => {
expect(rowTitled('About & updates').querySelector('.lrow-v').textContent).toMatch(/^v\d|^vtest/)
})
+ it('marks the page rows so a long preview wraps instead of losing its second half', () => {
+ mount()
+ const rows = ['Workout', 'Timer alerts', 'Plan & schedule', 'Units & language', 'Look & Home'].map(rowTitled)
+ for (const r of rows) expect(r.classList.contains('sp-root-row')).toBe(true)
+ // index.css: the marked rows' value may wrap, and never shrinks below its longest word
+ const css = readFileSync(resolve(process.cwd(), 'src/index.css'), 'utf8')
+ const rule = css.match(/^\.lrow\.sp-root-row \.lrow-v\{([^}]*)\}/m)?.[1] || ''
+ expect(rule).toMatch(/white-space:normal/)
+ expect(rule).toMatch(/line-clamp:3/)
+ expect(rule).toMatch(/min-width:min-content/)
+ // the sub-page title takes a second line rather than an ellipsis ("Alertas do temporizador")
+ const title = css.match(/^\.sp-title\{([^}]*)\}/m)?.[1] || ''
+ expect(title).not.toMatch(/nowrap/)
+ expect(title).toMatch(/line-clamp:2/)
+ })
+
it('previews a rest that was never on the old list, and no timer at all', () => {
mocks.S.restSec = 105
mount()