feat(dialogs): Vacay, Collections, Atlas and Journey in the new dialog look

Every popup of the four pages moves to the shared dialog frame the trip
uses: head band with its icon, the scrolling body, the footer with its
actions, and ConfirmDialog for the questions.

- Vacay: settings, removing a year (now says so when it fails), the
  fusion request, inviting a person, a person's colour and sharing the
  calendar.
- Collections: new and edited lists, adding a place, importing a file and
  a trip's places, sharing, labels and assigning them, copying to a trip,
  moving or duplicating, saving a trip's places and deleting a list. The
  stylesheet of the old import view goes.
- Atlas: the country popup with the flag in its head, its choices as rows
  and the wishlist step; Dawarich's Atlas dialog and its accept dialog on
  the desktop.
- Journey: creating a journey, its settings, linking a trip, inviting a
  contributor, the entry editor (discarding asks in a dialog) and the
  photo provider picker; the entry card's menu is the shared one.

The phone keeps its own sheets: where a dialog is shared with it
(Dawarich, the contributor invite, the provider picker) only the desktop
frame changes.
This commit is contained in:
Maurice
2026-09-28 16:52:32 +02:00
parent 9064ee57b7
commit acd003ea67
46 changed files with 3338 additions and 2803 deletions
@@ -80,12 +80,15 @@ describe('VacayPersons modals', () => {
openInvite()
const modal = await screen.findByText('Invite another TREK user to share a combined vacation calendar.')
fireEvent.click(modal.closest('.fixed') as HTMLElement)
// The dialog frame only closes on a press that starts and ends on the backdrop.
const backdrop = modal.closest('.fixed') as HTMLElement
fireEvent.mouseDown(backdrop)
fireEvent.click(backdrop)
expect(screen.queryByRole('button', { name: 'Send Invite' })).not.toBeInTheDocument()
openInvite()
const header = (await screen.findByText('Invite User')).closest('.justify-between') as HTMLElement
fireEvent.click(within(header).getByRole('button'))
await screen.findByText('Invite User')
fireEvent.click(screen.getByRole('button', { name: 'Close' }))
expect(screen.queryByRole('button', { name: 'Send Invite' })).not.toBeInTheDocument()
openInvite()
@@ -118,13 +121,15 @@ describe('VacayPersons modals', () => {
render(<VacayPersons />)
fireEvent.click(screen.getByTitle('Change color'))
const heading = await screen.findByText('Change color')
fireEvent.click(within(heading.closest('.justify-between') as HTMLElement).getByRole('button'))
await screen.findByText('Change color')
fireEvent.click(screen.getByRole('button', { name: 'Close' }))
expect(screen.queryByText('Change color', { selector: 'h2' })).not.toBeInTheDocument()
fireEvent.click(screen.getByTitle('Change color'))
const dialog = await screen.findByText('Change color', { selector: 'h2' })
fireEvent.click(dialog.closest('.fixed') as HTMLElement)
const backdrop = dialog.closest('.fixed') as HTMLElement
fireEvent.mouseDown(backdrop)
fireEvent.click(backdrop)
expect(screen.queryByText('Change color', { selector: 'h2' })).not.toBeInTheDocument()
})
})
+80 -69
View File
@@ -1,12 +1,12 @@
import { createPortal } from 'react-dom'
import { useState, useEffect, type HTMLAttributes } from 'react'
import { UserPlus, Check, Loader2, Clock, X } from 'lucide-react'
import { useState, useEffect, useId, type HTMLAttributes } from 'react'
import { UserPlus, Check, Loader2, Clock, Palette } from 'lucide-react'
import { useVacayStore } from '../../store/vacayStore'
import { useAuthStore } from '../../store/authStore'
import { useTranslation } from '../../i18n'
import { getApiErrorMessage } from '../../types'
import { useToast } from '../shared/Toast'
import CustomSelect from '../shared/CustomSelect'
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
import apiClient from '../../api/client'
import VacayBadge from './VacayBadge'
@@ -32,6 +32,8 @@ export default function VacayPersons() {
const [availableUsers, setAvailableUsers] = useState([])
const [selectedInviteUser, setSelectedInviteUser] = useState(null)
const [inviting, setInviting] = useState(false)
const inviteLabelId = useId()
const colorLabelId = useId()
const loadAvailable = async () => {
try {
@@ -61,7 +63,11 @@ export default function VacayPersons() {
setColorEditUserId(null)
}
const editingUserColor = users.find(u => u.id === colorEditUserId)?.color || '#6366f1'
const closeInvite = () => setShowInvite(false)
const closeColorPicker = () => { setShowColorPicker(false); setColorEditUserId(null) }
const editingUser = users.find(u => u.id === colorEditUserId)
const editingUserColor = editingUser?.color || '#6366f1' // theme-lint-disable: a person's own colour, the default one when unset
return (
<div className="vg-card rounded-[22px]" style={{ padding: '14px 18px' }}>
@@ -134,72 +140,77 @@ export default function VacayPersons() {
))}
</div>
{/* Invite Modal — Portal to body to avoid z-index issues */}
{showInvite && createPortal(
<div className="fixed inset-0 flex items-center justify-center px-4 trek-backdrop-enter bg-[rgba(15,23,42,0.5)]" style={{ zIndex: 99990, paddingTop: 70 }}
role="presentation"
onClick={e => { if (e.target === e.currentTarget) setShowInvite(false) }}>
<div className="trek-modal-enter rounded-2xl shadow-2xl w-full max-w-sm bg-surface-card">
<div className="flex items-center justify-between p-5 border-b border-edge-secondary">
<h2 className="text-base font-semibold text-content">{t('vacay.inviteUser')}</h2>
<button type="button" onClick={() => setShowInvite(false)} className="p-1.5 rounded-lg transition-colors text-content-faint">
<X size={16} />
</button>
</div>
<div className="p-5 space-y-4">
<p className="text-xs text-content-muted">{t('vacay.inviteHint')}</p>
{availableUsers.length === 0 ? (
<p className="text-xs text-center py-4 text-content-faint">{t('vacay.noUsersAvailable')}</p>
) : (
<CustomSelect
value={selectedInviteUser}
onChange={setSelectedInviteUser}
options={availableUsers.map(u => ({ value: u.id, label: `${u.username} (${u.email})` }))}
placeholder={t('vacay.selectUser')}
searchable
/>
)}
<div className="flex gap-3 justify-end pt-2">
<button type="button" onClick={() => setShowInvite(false)} className="px-4 py-2 text-sm rounded-lg text-content-muted border border-edge">
{t('common.cancel')}
</button>
<button type="button" onClick={handleInvite} disabled={!selectedInviteUser || inviting}
className="px-4 py-2 text-sm rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-40 bg-content text-surface-card">
{inviting && <Loader2 size={13} className="animate-spin" />}
{t('vacay.sendInvite')}
</button>
</div>
</div>
</div>
</div>,
document.body
)}
<DialogShell
open={showInvite}
onClose={closeInvite}
labelledBy={inviteLabelId}
width="narrow"
header={(
<DialogHeader
tile={<DialogTile><UserPlus size={20} strokeWidth={1.9} className="text-content-muted" /></DialogTile>}
tint={NEUTRAL_TINT}
labelId={inviteLabelId}
onClose={closeInvite}
title={t('vacay.inviteUser')}
sub={t('vacay.inviteHint')}
subWraps
/>
)}
footer={(
<DialogFooter>
<FooterSpacer />
<DialogButton onClick={closeInvite}>{t('common.cancel')}</DialogButton>
<DialogButton variant="primary" onClick={handleInvite} disabled={!selectedInviteUser || inviting}
icon={inviting ? <Loader2 size={14} className="animate-spin" /> : undefined}>
{t('vacay.sendInvite')}
</DialogButton>
</DialogFooter>
)}
>
{availableUsers.length === 0 ? (
<p className="m-0 rounded-[12px] bg-surface-secondary px-4 py-5 text-center text-content-faint" style={fs(12.5, 'body')}>
{t('vacay.noUsersAvailable')}
</p>
) : (
<CustomSelect
value={selectedInviteUser}
onChange={setSelectedInviteUser}
options={availableUsers.map(u => ({ value: u.id, label: `${u.username} (${u.email})` }))}
placeholder={t('vacay.selectUser')}
searchable
/>
)}
</DialogShell>
{/* Color Picker Modal — Portal to body */}
{showColorPicker && createPortal(
<div className="fixed inset-0 flex items-center justify-center px-4 trek-backdrop-enter bg-[rgba(15,23,42,0.5)]" style={{ zIndex: 99990, paddingTop: 70 }}
role="presentation"
onClick={e => { if (e.target !== e.currentTarget) return; setShowColorPicker(false); setColorEditUserId(null) }}>
<div className="trek-modal-enter rounded-2xl shadow-2xl w-full max-w-xs bg-surface-card">
<div className="flex items-center justify-between p-5 border-b border-edge-secondary">
<h2 className="text-base font-semibold text-content">{t('vacay.changeColor')}</h2>
<button type="button" onClick={() => { setShowColorPicker(false); setColorEditUserId(null) }} className="p-1.5 rounded-lg transition-colors text-content-faint">
<X size={16} />
</button>
</div>
<div className="p-5">
<div className="flex flex-wrap gap-2 justify-center">
{PRESET_COLORS.map(c => (
<button type="button" key={c} onClick={() => handleColorChange(c)}
className={`w-8 h-8 rounded-full transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] ${editingUserColor === c ? 'ring-2 ring-offset-2 scale-110' : 'hover:scale-110'}`}
style={{ backgroundColor: c }} />
))}
</div>
</div>
</div>
</div>,
document.body
)}
{/* A pick saves at once and closes, so there is nothing for a footer to confirm. */}
<DialogShell
open={showColorPicker}
onClose={closeColorPicker}
labelledBy={colorLabelId}
width="narrow"
header={(
<DialogHeader
tile={<DialogTile><Palette size={20} strokeWidth={1.9} className="text-content-muted" /></DialogTile>}
tint={NEUTRAL_TINT}
labelId={colorLabelId}
onClose={closeColorPicker}
title={t('vacay.changeColor')}
sub={editingUser?.username}
/>
)}
>
<div role="group" aria-label={t('vacay.color')}
className="grid grid-cols-5 justify-items-center gap-3 rounded-[14px] border border-edge-faint bg-surface-secondary p-4">
{PRESET_COLORS.map(c => {
const on = editingUserColor === c
return (
<button type="button" key={c} onClick={() => handleColorChange(c)} aria-pressed={on}
className={`h-10 w-10 rounded-full transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] ${on ? 'scale-110' : 'hover:scale-110'}`}
style={{ backgroundColor: c, outline: on ? '2px solid var(--text-primary)' : '2px solid transparent', outlineOffset: 2 }} />
)
})}
</div>
</DialogShell>
</div>
)
}
@@ -2,7 +2,7 @@
import React from 'react'
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
import { http, HttpResponse } from 'msw'
import { render, screen, fireEvent, waitFor, within } from '../../../tests/helpers/render'
import { render, screen, fireEvent, waitFor } from '../../../tests/helpers/render'
import { server } from '../../../tests/helpers/msw/server'
import { resetAllStores } from '../../../tests/helpers/store'
import { useVacayStore } from '../../store/vacayStore'
@@ -98,12 +98,15 @@ describe('VacaySharedCalendars errors', () => {
fireEvent.click(screen.getByTitle('Share calendar'))
const hint = await screen.findByRole('button', { name: 'Share' })
fireEvent.click(hint.closest('.fixed') as HTMLElement)
// The dialog frame only closes on a press that starts and ends on the backdrop.
const backdrop = hint.closest('.fixed') as HTMLElement
fireEvent.mouseDown(backdrop)
fireEvent.click(backdrop)
expect(screen.queryByRole('button', { name: 'Share' })).not.toBeInTheDocument()
fireEvent.click(screen.getByTitle('Share calendar'))
const header = (await screen.findByText('Share calendar')).closest('.justify-between') as HTMLElement
fireEvent.click(within(header).getByRole('button'))
await screen.findByText('Share calendar')
fireEvent.click(screen.getByRole('button', { name: 'Close' }))
expect(screen.queryByRole('button', { name: 'Share' })).not.toBeInTheDocument()
fireEvent.click(screen.getByTitle('Share calendar'))
@@ -1,11 +1,11 @@
import { createPortal } from 'react-dom'
import { useState } from 'react'
import { useId, useState } from 'react'
import { Share2, Eye, EyeOff, Loader2, X } from 'lucide-react'
import { useVacayStore } from '../../store/vacayStore'
import { useTranslation } from '../../i18n'
import { getApiErrorMessage } from '../../types'
import { useToast } from '../shared/Toast'
import CustomSelect from '../shared/CustomSelect'
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
import apiClient from '../../api/client'
import VacayBadge from './VacayBadge'
@@ -23,6 +23,7 @@ export default function VacaySharedCalendars() {
const [availableUsers, setAvailableUsers] = useState<{ id: number; username: string }[]>([])
const [selectedUser, setSelectedUser] = useState<number | null>(null)
const [sharing, setSharing] = useState(false)
const shareLabelId = useId()
const loadAvailable = async () => {
try {
@@ -55,6 +56,8 @@ export default function VacaySharedCalendars() {
removeShare(id).catch((err: unknown) => toast.error(getApiErrorMessage(err, t('vacay.shareFailed'))))
}
const closeShare = () => setShowShare(false)
const empty = incomingShares.length === 0 && outgoingShares.length === 0
return (
@@ -132,48 +135,47 @@ export default function VacaySharedCalendars() {
</div>
)}
{/* Share Modal — Portal to body to avoid z-index issues */}
{showShare && createPortal(
<div className="fixed inset-0 flex items-center justify-center px-4 trek-backdrop-enter bg-[rgba(15,23,42,0.5)]" style={{ zIndex: 99990, paddingTop: 70 }}
role="presentation"
onClick={() => setShowShare(false)}>
<div className="trek-modal-enter rounded-2xl shadow-2xl w-full max-w-sm bg-surface-card"
role="presentation"
onClick={e => e.stopPropagation()}>
<div className="flex items-center justify-between p-5 border-b border-edge-secondary">
<h2 className="text-base font-semibold text-content">{t('vacay.shareCalendar')}</h2>
<button type="button" onClick={() => setShowShare(false)} className="p-1.5 rounded-lg transition-colors text-content-faint">
<X size={16} />
</button>
</div>
<div className="p-5 space-y-4">
<p className="text-xs text-content-muted">{t('vacay.shareCalendarHint')}</p>
{availableUsers.length === 0 ? (
<p className="text-xs text-center py-4 text-content-faint">{t('vacay.noUsersAvailable')}</p>
) : (
<CustomSelect
value={selectedUser}
onChange={v => setSelectedUser(Number(v))}
options={availableUsers.map(u => ({ value: u.id, label: u.username }))}
placeholder={t('vacay.selectUser')}
searchable
/>
)}
<div className="flex gap-3 justify-end pt-2">
<button type="button" onClick={() => setShowShare(false)} className="px-4 py-2 text-sm rounded-lg text-content-muted border border-edge">
{t('common.cancel')}
</button>
<button type="button" onClick={handleShare} disabled={!selectedUser || sharing}
className="px-4 py-2 text-sm rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-40 bg-content text-surface-card">
{sharing && <Loader2 size={13} className="animate-spin" />}
{t('vacay.share')}
</button>
</div>
</div>
</div>
</div>,
document.body
)}
<DialogShell
open={showShare}
onClose={closeShare}
labelledBy={shareLabelId}
width="narrow"
header={(
<DialogHeader
tile={<DialogTile><Share2 size={20} strokeWidth={1.9} className="text-content-muted" /></DialogTile>}
tint={NEUTRAL_TINT}
labelId={shareLabelId}
onClose={closeShare}
title={t('vacay.shareCalendar')}
sub={t('vacay.shareCalendarHint')}
subWraps
/>
)}
footer={(
<DialogFooter>
<FooterSpacer />
<DialogButton onClick={closeShare}>{t('common.cancel')}</DialogButton>
<DialogButton variant="primary" onClick={handleShare} disabled={!selectedUser || sharing}
icon={sharing ? <Loader2 size={14} className="animate-spin" /> : undefined}>
{t('vacay.share')}
</DialogButton>
</DialogFooter>
)}
>
{availableUsers.length === 0 ? (
<p className="m-0 rounded-[12px] bg-surface-secondary px-4 py-5 text-center text-content-faint" style={fs(12.5, 'body')}>
{t('vacay.noUsersAvailable')}
</p>
) : (
<CustomSelect
value={selectedUser}
onChange={v => setSelectedUser(Number(v))}
options={availableUsers.map(u => ({ value: u.id, label: u.username }))}
placeholder={t('vacay.selectUser')}
searchable
/>
)}
</DialogShell>
</div>
)
}