mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-24 16:03:02 +00:00
35566690e9
- The editor's 'Pick a picture' is the one place a place's picture is set, on the desktop dialog and the phone sheet alike: upload one from the device, keep the current one (now shown as chosen), take an image attached to the place, or one of the sources' photos, or remove it. Nothing is sent before the save: the upload and the attached file are put in place once the place is saved, so Cancel leaves the picture as it was and a new place can get one too. Without the details column the same picker sits in the form. - The view (inspector and phone sheet) shows the picture plainly; a click opens the gallery of its own picture and its sources' photos. - The gallery drops an answer that arrives after the place changed, and its credits link to their source pages. The lightbox is a labelled modal dialog that takes and gives back focus, names its arrows and follows the reading direction. - The picker leaves the details column (PlaceImagePicker), the column reads the shared enrichment cache, and PlaceAvatarUpload and usePlaceImagePick, which only the view used, are gone.
23 lines
886 B
TypeScript
23 lines
886 B
TypeScript
import type { PlacePhotoCandidate } from '@trek/shared';
|
|
|
|
/** The name to put under a picture. Google gives no author, so it gets its own name. */
|
|
export function creditOf(photo: PlacePhotoCandidate): string {
|
|
return photo.attribution || sourceLabelFor(photo.source);
|
|
}
|
|
|
|
/**
|
|
* The provider a picture came from, for the pictures that hand us no author.
|
|
* Proper names, so they are not translated.
|
|
*/
|
|
export function sourceLabelFor(source: PlacePhotoCandidate['source']): string {
|
|
if (source === 'google') return 'Google';
|
|
if (source === 'wikipedia') return 'Wikipedia';
|
|
return 'Wikimedia Commons';
|
|
}
|
|
|
|
/** Author and licence joined for a single-line caption, with a comma as the rest of the app writes it. */
|
|
export function photoCaption(photo: PlacePhotoCandidate): string {
|
|
const credit = creditOf(photo);
|
|
return photo.license ? `${credit}, ${photo.license}` : credit;
|
|
}
|