mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
feat(mobile): swipe the day details to step through days (#2059)
* @ feat(mobile): swipe the day details to step through days The phone shell hangs the days off a chip rail pinned to the top of the screen, which on a large phone is a thin target a thumb cannot reach one handed. The day details fill the rest of the screen and did nothing. They now take a horizontal swipe: left for the next day, right for the previous one, with the panel following the finger, rubber banding at the first and last day and springing back when the swipe falls short. The chip rail is untouched and still the accessible path; a committed swipe announces the day it reached through a live region, and the active chip scrolls itself back into view once the rail overflows. The gesture never calls preventDefault or stops propagation on a touch event and sets no touch-action, so the browser keeps sole ownership of the card scroll and of the header chip strip, and the long press reorder bridge keeps its own 10px self cancel. In edit mode the swipe also refuses to claim a press held past the bridge window. @ * @ fix(mobile): line the map controls up and widen the POI bar The compass sat on its own under the POI bar, centre top, while the locate button floated 42px above the dock on the other end of the screen. Both are one handed controls, so they now share the band just above the dock: compass bottom left, locate bottom right, off the same --bottom-nav-h the map already reads, a dock gap lower than before. That frees the row under the chip rail, so the nearby places bar takes the full width between the screen margins and its segments end up the size of everything else the thumb aims at there. Desktop keeps the floating, content width bar. @
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-COMP-POIPILL-001 to FE-COMP-POIPILL-006
|
||||
// FE-COMP-POIPILL-001 to FE-COMP-POIPILL-008
|
||||
import React from 'react'
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, screen } from '../../../tests/helpers/render'
|
||||
@@ -57,4 +57,22 @@ describe('PoiCategoryPill', () => {
|
||||
fireEvent.click(screen.getByText('Search this area'))
|
||||
expect(onSearchArea).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
// The phone map hands the bar the whole width between the screen margins, so
|
||||
// its segments end up the size of everything else the thumb aims at there.
|
||||
it('FE-COMP-POIPILL-007: fullWidth stretches the bar and spreads the segments', () => {
|
||||
pill({ fullWidth: true })
|
||||
const button = screen.getAllByRole('button')[0]
|
||||
expect(button.style.flexGrow).toBe('1')
|
||||
expect(button.style.width).toBe('auto')
|
||||
expect((button.parentElement as HTMLElement).style.display).toBe('flex')
|
||||
})
|
||||
|
||||
it('FE-COMP-POIPILL-008: without it the bar stays content-width, as the desktop map floats it', () => {
|
||||
pill()
|
||||
const button = screen.getAllByRole('button')[0]
|
||||
expect(button.style.flexGrow).toBe('')
|
||||
expect(button.style.width).toBe('34px')
|
||||
expect((button.parentElement as HTMLElement).style.display).toBe('inline-flex')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -12,12 +12,16 @@ interface Props {
|
||||
/** true when the map moved since the last search → offer "search this area" */
|
||||
moved?: boolean
|
||||
onSearchArea?: () => void
|
||||
/** Stretch the bar across its container and spread the segments evenly.
|
||||
* The phone map gives it the full width between the screen margins; on
|
||||
* desktop it floats, so it stays content-width there. */
|
||||
fullWidth?: boolean
|
||||
}
|
||||
|
||||
// Frosted, icon-only segmented control that floats over the map. Active segments
|
||||
// fill with the category colour (matching their markers); the label shows in a
|
||||
// custom tooltip on hover so the pill stays compact and never needs to scroll.
|
||||
export default function PoiCategoryPill({ active, onToggle, loadingKeys, errorKeys, moved, onSearchArea }: Props) {
|
||||
export default function PoiCategoryPill({ active, onToggle, loadingKeys, errorKeys, moved, onSearchArea, fullWidth }: Props) {
|
||||
const { t } = useTranslation()
|
||||
const anyError = !!errorKeys && Array.from(active).some(k => errorKeys.has(k))
|
||||
|
||||
@@ -29,8 +33,12 @@ export default function PoiCategoryPill({ active, onToggle, loadingKeys, errorKe
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8 }}>
|
||||
<div style={{ display: 'inline-flex', alignItems: 'center', gap: 2, padding: 4, borderRadius: 999, pointerEvents: 'auto', ...frosted }}>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8, width: fullWidth ? '100%' : undefined }}>
|
||||
<div style={{
|
||||
display: fullWidth ? 'flex' : 'inline-flex',
|
||||
alignSelf: fullWidth ? 'stretch' : undefined,
|
||||
alignItems: 'center', gap: 2, padding: 4, borderRadius: 999, pointerEvents: 'auto', ...frosted,
|
||||
}}>
|
||||
{POI_CATEGORIES.map(cat => {
|
||||
const on = active.has(cat.key)
|
||||
// Only an active category can be loading — a deselected one whose fetch
|
||||
@@ -47,7 +55,11 @@ export default function PoiCategoryPill({ active, onToggle, loadingKeys, errorKe
|
||||
style={{
|
||||
position: 'relative',
|
||||
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
||||
width: 34, height: 34, borderRadius: 999, border: 'none', cursor: 'pointer',
|
||||
flexGrow: fullWidth ? 1 : undefined,
|
||||
flexShrink: fullWidth ? 1 : undefined,
|
||||
flexBasis: fullWidth ? 0 : undefined,
|
||||
minWidth: fullWidth ? 0 : undefined,
|
||||
width: fullWidth ? 'auto' : 34, height: 34, borderRadius: 999, border: 'none', cursor: 'pointer',
|
||||
background: on ? cat.color : 'transparent',
|
||||
color: on ? '#fff' : undefined,
|
||||
transition: 'background 0.14s, color 0.14s',
|
||||
|
||||
Reference in New Issue
Block a user