Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(journey): the Dawarich button clears the card rail, and the settings switches read in the dark

Mauriced18077d171ec
diff --git a/client/src/components/Journey/JourneyDetailPageSettingsDialog.tsx b/client/src/components/Journey/JourneyDetailPageSettingsDialog.tsx
index ac83ed463..ee641f212 100644
--- a/client/src/components/Journey/JourneyDetailPageSettingsDialog.tsx
+++ b/client/src/components/Journey/JourneyDetailPageSettingsDialog.tsx
@@ -11,6 +11,7 @@ import type { JourneyDetail } from '../../store/journeyStore'
import { pickGradient } from '../../pages/journeyDetail/JourneyDetailPage.helpers'
import { AddTripDialog } from './JourneyDetailPageAddTripDialog'
import { normalizeImageFile } from '../../utils/convertHeic'
+import ToggleSwitch from '../Settings/ToggleSwitch'
export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite, onRefresh, onRestoreSuggestions }: {
journey: JourneyDetail
@@ -188,25 +189,17 @@ export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite,
{/* Trip GPX tracks on the journey map (#2194) */}
<div>
<label className="text-[10px] font-semibold tracking-[0.12em] uppercase text-zinc-500 block mb-1.5">{t('journey.settings.tracks')}</label>
- <button
- type="button"
- role="switch"
- aria-checked={!!journey.show_trip_tracks}
- disabled={savingTracks}
- onClick={handleTracksToggle}
- className="w-full flex items-center gap-3 px-3.5 py-2.5 border border-zinc-200 dark:border-zinc-700 rounded-xl bg-white dark:bg-zinc-800 text-left disabled:opacity-60"
- >
+ <div className={`w-full flex items-center gap-3 px-3.5 py-2.5 border border-edge rounded-xl bg-surface-card text-left${savingTracks ? ' opacity-60' : ''}`}>
<span className="flex-1 min-w-0">
- <span className="block text-[14px] text-zinc-900 dark:text-white">{t('journey.settings.showTripTracks')}</span>
- <span className="block text-[11px] text-zinc-500">{t('journey.settings.showTripTracksHint')}</span>
- </span>
- <span
- aria-hidden="true"
- className={`w-9 h-5 rounded-full flex-shrink-0 p-0.5 transition-colors ${journey.show_trip_tracks ? 'bg-emerald-500' : 'bg-zinc-300 dark:bg-zinc-600'}`}
- >
- <span className={`block w-4 h-4 rounded-full bg-white transition-transform ${journey.show_trip_tracks ? 'translate-x-4' : ''}`} />
+ <span className="block text-[14px] text-content-primary">{t('journey.settings.showTripTracks')}</span>
+ <span className="block text-[11px] text-content-faint">{t('journey.settings.showTripTracksHint')}</span>
</span>
- </button>
+ <ToggleSwitch
+ on={!!journey.show_trip_tracks}
+ onToggle={() => { if (!savingTracks) handleTracksToggle() }}
+ label={t('journey.settings.showTripTracks')}
+ />
+ </div>
</div>
{/* The three fields a journey may put away (discussion #2299) */}
@@ -221,21 +214,17 @@ export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite,
] as const).map(([field, label]) => {
const on = journey[field] !== 0
return (
- <button
+ <div
key={field}
- type="button"
- role="switch"
- aria-checked={on}
- aria-label={label}
- disabled={savingField !== null}
- onClick={() => handleFieldToggle(field)}
- className="w-full flex items-center gap-3 px-3.5 py-2.5 border border-zinc-200 dark:border-zinc-700 rounded-xl bg-white dark:bg-zinc-800 text-left disabled:opacity-60"
+ className={`w-full flex items-center gap-3 px-3.5 py-2.5 border border-edge rounded-xl bg-surface-card text-left${savingField !== null ? ' opacity-60' : ''}`}
>
- <span className="flex-1 min-w-0 text-[14px] text-zinc-900 dark:text-white">{label}</span>
- <span aria-hidden="true" className={`w-9 h-5 rounded-full flex-shrink-0 p-0.5 transition-colors ${on ? 'bg-emerald-500' : 'bg-zinc-300 dark:bg-zinc-600'}`}>
- <span className={`block w-4 h-4 rounded-full bg-white transition-transform ${on ? 'translate-x-4' : ''}`} />
- </span>
- </button>
+ <span className="flex-1 min-w-0 text-[14px] text-content-primary">{label}</span>
+ <ToggleSwitch
+ on={on}
+ onToggle={() => { if (savingField === null) handleFieldToggle(field) }}
+ label={label}
+ />
+ </div>
)
})}
</div>
diff --git a/client/src/mobile/screens/journey/MJourneyDetail.tsx b/client/src/mobile/screens/journey/MJourneyDetail.tsx
index 3ca4485a8..e0a707cc7 100644
--- a/client/src/mobile/screens/journey/MJourneyDetail.tsx
+++ b/client/src/mobile/screens/journey/MJourneyDetail.tsx
@@ -204,8 +204,31 @@ export default function MJourneyDetail() {
const [pickerProvider, setPickerProvider] = useState<string | null>(null)
const dawarichEnabled = useAddonStore(state => state.isEnabled)('dawarich')
const [dawarichOpen, setDawarichOpen] = useState(false)
+ /**
+ * How tall the card rail over the dock currently is.
+ *
+ * Measured rather than written down: the rail is a day scrubber over a row of covers,
+ * and a cover grows from 152 to 180px when it becomes the active one. The Dawarich
+ * button above it used to clear a hard-coded 128px, which was short of the rail on any
+ * screen and left the button sitting over the cards. Zero while there is no rail, which
+ * is also the empty-journal case, and the button then sits straight above the dock.
+ */
+ const [railHeight, setRailHeight] = useState(0)
+ const railRef = useRef<HTMLDivElement>(null)
const [uploading, setUploading] = useState(false)
+ useEffect(() => {
+ const node = railRef.current
+ if (!node) { setRailHeight(0); return }
+ // Observed rather than read once: the rail changes height when the active card grows,
+ // and a height read at mount would be the wrong one from the first swipe onwards.
+ if (typeof ResizeObserver === 'undefined') { setRailHeight(node.offsetHeight); return }
+ const observer = new ResizeObserver(() => setRailHeight(node.offsetHeight))
+ observer.observe(node)
+ setRailHeight(node.offsetHeight)
+ return () => observer.disconnect()
+ }, [view, entries.length])
+
const openUpload = useCallback(() => {
if (availableProviders.length > 0) setShowUploadMenu(true)
else galleryFileRef.current?.click()
@@ -450,7 +473,10 @@ export default function MJourneyDetail() {
type="button"
onClick={() => setDawarichOpen(true)}
aria-label={t('dawarich.suggestions.title')}
- className="absolute right-4 z-[9] flex h-[46px] w-[46px] items-center justify-center overflow-hidden rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-sheet)] shadow-[0_6px_18px_-8px_rgba(0,0,0,.35)] bottom-[calc(var(--bottom-nav-h,84px)+16px+128px)]"
+ className="absolute right-4 z-[9] flex h-[46px] w-[46px] items-center justify-center overflow-hidden rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-sheet)] shadow-[0_6px_18px_-8px_rgba(0,0,0,.35)]"
+ // The rail's own offset over the dock, its measured height, then a gap. The 128px
+ // this used to guess at was short of the rail, so the button lay on the cards.
+ style={{ bottom: `calc(var(--bottom-nav-h, 84px) + 2px + ${railHeight}px + 12px)` }}
>
<DawarichIcon size={46} />
</button>
@@ -487,7 +513,7 @@ export default function MJourneyDetail() {
nothing between the cards and it; two pixels keeps a hair of daylight and
gives the strip the rest. */}
{view === 'timeline' && entries.length > 0 && (
- <div className="absolute left-0 right-0 z-[8] bottom-[calc(var(--bottom-nav-h,84px)+2px)]">
+ <div ref={railRef} className="absolute left-0 right-0 z-[8] bottom-[calc(var(--bottom-nav-h,84px)+2px)]">
<JourneyDayScrubber
days={scrubberDays}
activeDate={entries[activeIndex]?.entry_date ?? null}