mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
fix(journey): refine dialog and gallery controls
This commit is contained in:
@@ -37,7 +37,6 @@ export default function DawarichDayDialog({
|
||||
onClose={onClose}
|
||||
labelledBy={labelId}
|
||||
width="detail"
|
||||
align="top"
|
||||
header={
|
||||
<DialogHeader
|
||||
tile={
|
||||
|
||||
@@ -154,7 +154,7 @@ export default function JourneyDayRecordingButton({
|
||||
className={ROUND}
|
||||
style={{ background: 'var(--vg-surf2)' }}
|
||||
>
|
||||
<DawarichIcon size={15} />
|
||||
<DawarichIcon className="size-3.5 rounded-full" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
<ContextMenu menu={menu.menu} onClose={menu.close} />
|
||||
|
||||
@@ -234,7 +234,7 @@ export function EntryEditor({ entry, journeyId, tripDates, galleryPhotos, trips,
|
||||
<>
|
||||
{/* Pinned at the top: the photo panels, the verdict rows and the photo
|
||||
strip all change the body's height while an entry is being written. */}
|
||||
<DialogShell onClose={handleClose} labelledBy={labelId} width="wide" align="top" blocked={confirmDiscard} header={header} footer={footer}>
|
||||
<DialogShell onClose={handleClose} labelledBy={labelId} width="wide" blocked={confirmDiscard} header={header} footer={footer}>
|
||||
<div className="grid grid-cols-1 items-stretch gap-x-6 gap-y-5 md:grid-cols-2">
|
||||
<div className="flex min-w-0 flex-col gap-5">
|
||||
<div>
|
||||
|
||||
@@ -69,11 +69,6 @@ export function GalleryView({ entries, gallery, journeyId, userId, trips, canEdi
|
||||
// Deleting is final on the server and takes the photo out of every entry that
|
||||
// uses it too, so the tile only asks; the dialog does the deleting (#2593).
|
||||
const [deleteTarget, setDeleteTarget] = useState<GalleryPhoto | null>(null)
|
||||
const [showFromPhotos, setShowFromPhotos] = useState(false)
|
||||
const coverOf = (galleryPhotoId: number) => {
|
||||
const photo = allPhotos.find(p => p.id === galleryPhotoId)
|
||||
return photo && !posterlessVideo(photo) ? photoUrl(photo, 'thumbnail') : null
|
||||
}
|
||||
|
||||
const handleDeletePhoto = async (galleryPhotoId: number) => {
|
||||
const store = useJourneyStore.getState()
|
||||
@@ -90,31 +85,11 @@ export function GalleryView({ entries, gallery, journeyId, userId, trips, canEdi
|
||||
<div>
|
||||
<input ref={galleryFileRef} type="file" accept="image/*,video/*" multiple onChange={handleGalleryUpload} className="hidden" />
|
||||
|
||||
{/* Header — the provider buttons live in the page header next to Upload */}
|
||||
<div className="flex items-center justify-between mb-4 flex-wrap gap-2">
|
||||
<div className="mb-4">
|
||||
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-[0.07em]" style={{ background: 'var(--vg-surf2)', color: 'var(--vg-ink3)' }}>
|
||||
<Camera size={11} /> {allPhotos.length} {t('journey.detail.photos', { count: allPhotos.length })}
|
||||
</span>
|
||||
{/* #1920: the gallery's loose photos as drafts, grouped by day and place. */}
|
||||
{canEdit && allPhotos.length > 0 && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowFromPhotos(true)}
|
||||
className="inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-caption font-semibold transition-colors hover:bg-surface-hover"
|
||||
style={{ background: 'var(--vg-surf2)', color: 'var(--vg-ink)' }}
|
||||
>
|
||||
<NotebookPen size={13} /> {t('journey.fromPhotos.title')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{showFromPhotos && (
|
||||
<JourneyFromPhotosDialog
|
||||
journeyId={journeyId}
|
||||
coverOf={coverOf}
|
||||
onCreated={onRefresh}
|
||||
onClose={() => setShowFromPhotos(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{allPhotos.length === 0 ? (
|
||||
<EmptyState scene="journey" title={t('journey.detail.noPhotos')} />
|
||||
@@ -212,3 +187,38 @@ export function GalleryView({ entries, gallery, journeyId, userId, trips, canEdi
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function CreateEntriesFromPhotosButton({ journeyId, gallery, onCreated, className }: {
|
||||
journeyId: number
|
||||
gallery: GalleryPhoto[]
|
||||
onCreated: () => void
|
||||
className: string
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOpen(true)}
|
||||
className={className}
|
||||
style={{ background: 'var(--vg-surf2)', color: 'var(--vg-ink)' }}
|
||||
>
|
||||
<NotebookPen size={16} strokeWidth={2.4} />
|
||||
{t('journey.fromPhotos.title')}
|
||||
</button>
|
||||
{open && (
|
||||
<JourneyFromPhotosDialog
|
||||
journeyId={journeyId}
|
||||
coverOf={galleryPhotoId => {
|
||||
const photo = gallery.find(p => p.id === galleryPhotoId)
|
||||
return photo && !posterlessVideo(photo) ? photoUrl(photo, 'thumbnail') : null
|
||||
}}
|
||||
onCreated={onCreated}
|
||||
onClose={() => setOpen(false)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ export default function JourneyMapLayerControl({
|
||||
style={FROSTED_SHELL}
|
||||
role="group"
|
||||
aria-label={t('journey.map.layers')}
|
||||
className="max-w-full gap-0.5 overflow-x-auto"
|
||||
className="max-w-full gap-1 overflow-x-auto"
|
||||
>
|
||||
{layers.controls.map((control) => (
|
||||
<LayerToggle
|
||||
@@ -289,7 +289,7 @@ export default function JourneyMapLayerControl({
|
||||
compact={compact}
|
||||
/>
|
||||
))}
|
||||
<span aria-hidden className="mx-0.5 h-5 w-px flex-none bg-edge" />
|
||||
<span aria-hidden className="h-5 w-px flex-none bg-edge" />
|
||||
<KeyButton />
|
||||
<span role="status" aria-live="polite" className="sr-only">
|
||||
{live}
|
||||
|
||||
@@ -26,7 +26,7 @@ import { computeJourneyLifecycle } from '../utils/journeyLifecycle'
|
||||
import { useJourneyDetail, type JourneyDetailOptions } from './journeyDetail/useJourneyDetail'
|
||||
import { createDraftJourneyEntry, pickGradient, groupByDate, formatDate, photoUrl, matchJourneyEntries } from './journeyDetail/JourneyDetailPage.helpers'
|
||||
import { EntryCard, SkeletonCard, CheckinCard } from '../components/Journey/JourneyDetailPageEntryCard'
|
||||
import { GalleryView } from '../components/Journey/JourneyDetailPageGalleryView'
|
||||
import { CreateEntriesFromPhotosButton, GalleryView } from '../components/Journey/JourneyDetailPageGalleryView'
|
||||
import { EntryEditor } from '../components/Journey/JourneyDetailPageEntryEditor'
|
||||
import { AddTripDialog } from '../components/Journey/JourneyDetailPageAddTripDialog'
|
||||
import { JourneySettingsDialog } from '../components/Journey/JourneyDetailPageSettingsDialog'
|
||||
@@ -34,6 +34,8 @@ import HelpAnchor from '../components/Help/HelpAnchor'
|
||||
import JourneyDayJump from '../components/Journey/JourneyDayJump'
|
||||
import { MemberEntryComments } from '../components/Journey/JourneyEntryComments'
|
||||
|
||||
const GALLERY_ACTION_BUTTON = 'inline-flex h-9 items-center gap-1.5 whitespace-nowrap rounded-full px-4 text-[13px] font-semibold transition-transform hover:-translate-y-0.5'
|
||||
|
||||
export default function JourneyDetailPage() {
|
||||
// ViewportRoute in App.tsx picks the branch now, so the phone screen is a
|
||||
// chunk of its own instead of a dead limb in this one.
|
||||
@@ -147,12 +149,12 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
// the gallery takes the actions over there instead. Exactly one host renders
|
||||
// them, never both.
|
||||
const galleryActions = canEditEntries && view === 'gallery' ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||
{galleryProviders.map(p => (
|
||||
<button type="button"
|
||||
key={p.id}
|
||||
onClick={() => galleryBrowseRef.current?.(p.id)}
|
||||
className="inline-flex items-center gap-1.5 h-9 px-4 rounded-full text-[13px] font-semibold transition-transform hover:-translate-y-0.5"
|
||||
className={GALLERY_ACTION_BUTTON}
|
||||
style={{ background: 'var(--vg-ink)', color: 'var(--vg-bg)' }}
|
||||
>
|
||||
<Image size={16} strokeWidth={2.4} />
|
||||
@@ -162,7 +164,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
<button type="button"
|
||||
onClick={() => galleryUploadRef.current?.()}
|
||||
disabled={galleryUploadProgress !== null}
|
||||
className="inline-flex items-center gap-1.5 h-9 px-4 rounded-full text-[13px] font-semibold transition-transform hover:-translate-y-0.5 disabled:opacity-70 disabled:hover:translate-y-0"
|
||||
className={`${GALLERY_ACTION_BUTTON} disabled:opacity-70 disabled:hover:translate-y-0`}
|
||||
style={{ background: 'var(--vg-ink)', color: 'var(--vg-bg)' }}
|
||||
>
|
||||
{galleryUploadProgress ? (
|
||||
@@ -177,6 +179,14 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
{!!current.gallery?.length && (
|
||||
<CreateEntriesFromPhotosButton
|
||||
journeyId={current.id}
|
||||
gallery={current.gallery}
|
||||
onCreated={() => loadJourney(Number(id))}
|
||||
className={GALLERY_ACTION_BUTTON}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
) : null
|
||||
|
||||
@@ -456,7 +466,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
value={query}
|
||||
onChange={e => setQuery(e.target.value)}
|
||||
placeholder={t('journey.detail.searchPlaceholder')}
|
||||
className="min-w-0 flex-1 bg-transparent text-[12.5px] outline-none"
|
||||
className="min-w-0 flex-1 !bg-transparent text-[12.5px] outline-none"
|
||||
style={{ color: 'var(--vg-ink)' }}
|
||||
/>
|
||||
{query && (
|
||||
|
||||
@@ -353,8 +353,7 @@ function CreateJourneyDialog({ title, onTitleChange, subtitle, onSubtitleChange,
|
||||
)
|
||||
|
||||
return (
|
||||
// Pinned at the top: the trips arrive after the dialog opens and grow the body.
|
||||
<DialogShell onClose={onClose} labelledBy={labelId} width="detail" align="top" header={header} footer={footer}>
|
||||
<DialogShell onClose={onClose} labelledBy={labelId} width="detail" header={header} footer={footer}>
|
||||
<EditorField label={t('journey.settings.subtitle')} htmlFor={`${labelId}-subtitle`}>
|
||||
<input
|
||||
id={`${labelId}-subtitle`}
|
||||
|
||||
Reference in New Issue
Block a user