Refine blur fallback, update blur documentation
This commit is contained in:
parent
908db18fb0
commit
27dcb06dd3
@ -62,8 +62,8 @@ Installation
|
|||||||
|
|
||||||
### 6. Optional configuration
|
### 6. Optional configuration
|
||||||
|
|
||||||
- `NEXT_PUBLIC_PRO_MODE = 1` enables higher quality image storage
|
- `NEXT_PUBLIC_PRO_MODE = 1` enables higher quality image storage (will result in increased storage usage)
|
||||||
- `NEXT_PUBLIC_BLUR_DISABLED = 1` prevents image blur data being stored and displayed
|
- `NEXT_PUBLIC_BLUR_DISABLED = 1` prevents image blur data being stored and displayed (potentially useful for limiting Postgres usage)
|
||||||
- `NEXT_PUBLIC_GEO_PRIVACY = 1` disables collection/display of location-based data
|
- `NEXT_PUBLIC_GEO_PRIVACY = 1` disables collection/display of location-based data
|
||||||
- `NEXT_PUBLIC_IGNORE_PRIORITY_ORDER = 1` prevents `priority_order` field affecting photo order
|
- `NEXT_PUBLIC_IGNORE_PRIORITY_ORDER = 1` prevents `priority_order` field affecting photo order
|
||||||
- `NEXT_PUBLIC_PUBLIC_API = 1` enables public API available at `/api`
|
- `NEXT_PUBLIC_PUBLIC_API = 1` enables public API available at `/api`
|
||||||
|
|||||||
@ -1,30 +1,22 @@
|
|||||||
'use client';
|
import { BLUR_ENABLED } from '@/site/config';
|
||||||
|
import clsx from 'clsx/lite';
|
||||||
import { BLUR_DISABLED } from '@/site/config';
|
|
||||||
import { useTheme } from 'next-themes';
|
|
||||||
import Image, { ImageProps } from 'next/image';
|
import Image, { ImageProps } from 'next/image';
|
||||||
|
|
||||||
// Based on bg-gray-100/50 (#f9f9fa)
|
|
||||||
// eslint-disable-next-line max-len
|
|
||||||
const BLUR_DATA_LIGHT = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAADElEQVQImWP4+fMXAAXbAu0I+kpzAAAAAElFTkSuQmCC';
|
|
||||||
|
|
||||||
// Based on bg-gray-900/50 (#090c14)
|
|
||||||
// eslint-disable-next-line max-len
|
|
||||||
const BLUR_DATA_DARK = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAADElEQVQImWPg5BEBAABLACpEF6ULAAAAAElFTkSuQmCC';
|
|
||||||
|
|
||||||
export default function ImageBlurFallback(props: ImageProps) {
|
export default function ImageBlurFallback(props: ImageProps) {
|
||||||
const { resolvedTheme } = useTheme();
|
|
||||||
const blueFallback = resolvedTheme === 'dark'
|
|
||||||
? BLUR_DATA_DARK
|
|
||||||
: BLUR_DATA_LIGHT;
|
|
||||||
return (
|
return (
|
||||||
// eslint-disable-next-line jsx-a11y/alt-text
|
// eslint-disable-next-line jsx-a11y/alt-text
|
||||||
<Image {...{
|
<Image {...{
|
||||||
...props,
|
...props,
|
||||||
blurDataURL: !BLUR_DISABLED && props.blurDataURL
|
...BLUR_ENABLED && props.blurDataURL ? {
|
||||||
? props.blurDataURL
|
blurDataURL: props.blurDataURL,
|
||||||
: blueFallback,
|
placeholder: 'blur',
|
||||||
placeholder: 'blur',
|
}: {
|
||||||
|
className: clsx(
|
||||||
|
props.className,
|
||||||
|
'bg-gray-100/50 dark:bg-gray-900/50',
|
||||||
|
),
|
||||||
|
placeholder: 'empty',
|
||||||
|
},
|
||||||
}} />
|
}} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import {
|
|||||||
import { toastSuccess, toastWarning } from '@/toast';
|
import { toastSuccess, toastWarning } from '@/toast';
|
||||||
import { getDimensionsFromSize } from '@/utility/size';
|
import { getDimensionsFromSize } from '@/utility/size';
|
||||||
import ImageBlurFallback from '@/components/ImageBlurFallback';
|
import ImageBlurFallback from '@/components/ImageBlurFallback';
|
||||||
|
import { BLUR_ENABLED } from '@/site/config';
|
||||||
|
|
||||||
const THUMBNAIL_SIZE = 300;
|
const THUMBNAIL_SIZE = 300;
|
||||||
|
|
||||||
@ -97,10 +98,12 @@ export default function PhotoForm({
|
|||||||
const url = formData.url ?? '';
|
const url = formData.url ?? '';
|
||||||
|
|
||||||
const updateBlurData = useCallback((blurData: string) => {
|
const updateBlurData = useCallback((blurData: string) => {
|
||||||
setFormData(data => ({
|
if (BLUR_ENABLED) {
|
||||||
...data,
|
setFormData(data => ({
|
||||||
blurData,
|
...data,
|
||||||
}));
|
blurData,
|
||||||
|
}));
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import {
|
|||||||
MAKE_FUJIFILM,
|
MAKE_FUJIFILM,
|
||||||
} from '@/vendors/fujifilm';
|
} from '@/vendors/fujifilm';
|
||||||
import { FilmSimulation } from '@/simulation';
|
import { FilmSimulation } from '@/simulation';
|
||||||
import { GEO_PRIVACY_ENABLED } from '@/site/config';
|
import { BLUR_ENABLED, GEO_PRIVACY_ENABLED } from '@/site/config';
|
||||||
import { TAG_FAVS, doesTagsStringIncludeFavs } from '@/tag';
|
import { TAG_FAVS, doesTagsStringIncludeFavs } from '@/tag';
|
||||||
|
|
||||||
type VirtualFields = 'favorite';
|
type VirtualFields = 'favorite';
|
||||||
@ -28,8 +28,8 @@ type FormMeta = {
|
|||||||
readOnly?: boolean
|
readOnly?: boolean
|
||||||
validate?: (value?: string) => string | undefined
|
validate?: (value?: string) => string | undefined
|
||||||
capitalize?: boolean
|
capitalize?: boolean
|
||||||
|
hide?: boolean
|
||||||
hideIfEmpty?: boolean
|
hideIfEmpty?: boolean
|
||||||
hideTemporarily?: boolean
|
|
||||||
hideBasedOnCamera?: (make?: string, mode?: string) => boolean
|
hideBasedOnCamera?: (make?: string, mode?: string) => boolean
|
||||||
loadingMessage?: string
|
loadingMessage?: string
|
||||||
checkbox?: boolean
|
checkbox?: boolean
|
||||||
@ -50,7 +50,8 @@ const FORM_METADATA: Record<keyof PhotoFormData, FormMeta> = {
|
|||||||
blurData: {
|
blurData: {
|
||||||
label: 'blur data',
|
label: 'blur data',
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
required: true,
|
required: BLUR_ENABLED,
|
||||||
|
hideIfEmpty: !BLUR_ENABLED,
|
||||||
loadingMessage: 'Generating blur data ...',
|
loadingMessage: 'Generating blur data ...',
|
||||||
},
|
},
|
||||||
url: { label: 'url', readOnly: true },
|
url: { label: 'url', readOnly: true },
|
||||||
@ -70,7 +71,7 @@ const FORM_METADATA: Record<keyof PhotoFormData, FormMeta> = {
|
|||||||
iso: { label: 'ISO' },
|
iso: { label: 'ISO' },
|
||||||
exposureTime: { label: 'exposure time' },
|
exposureTime: { label: 'exposure time' },
|
||||||
exposureCompensation: { label: 'exposure compensation' },
|
exposureCompensation: { label: 'exposure compensation' },
|
||||||
locationName: { label: 'location name', hideTemporarily: true },
|
locationName: { label: 'location name', hide: true },
|
||||||
latitude: { label: 'latitude' },
|
latitude: { label: 'latitude' },
|
||||||
longitude: { label: 'longitude' },
|
longitude: { label: 'longitude' },
|
||||||
takenAt: { label: 'taken at' },
|
takenAt: { label: 'taken at' },
|
||||||
@ -82,7 +83,7 @@ const FORM_METADATA: Record<keyof PhotoFormData, FormMeta> = {
|
|||||||
|
|
||||||
export const FORM_METADATA_ENTRIES =
|
export const FORM_METADATA_ENTRIES =
|
||||||
(Object.entries(FORM_METADATA) as [keyof PhotoFormData, FormMeta][])
|
(Object.entries(FORM_METADATA) as [keyof PhotoFormData, FormMeta][])
|
||||||
.filter(([_, meta]) => !meta.hideTemporarily);
|
.filter(([_, meta]) => !meta.hide);
|
||||||
|
|
||||||
export const convertFormKeysToLabels = (keys: (keyof PhotoFormData)[]) =>
|
export const convertFormKeysToLabels = (keys: (keyof PhotoFormData)[]) =>
|
||||||
keys.map(key => FORM_METADATA[key].label.toUpperCase());
|
keys.map(key => FORM_METADATA[key].label.toUpperCase());
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export interface PhotoDbInsert extends PhotoExif {
|
|||||||
id: string
|
id: string
|
||||||
url: string
|
url: string
|
||||||
extension: string
|
extension: string
|
||||||
blurData: string
|
blurData?: string
|
||||||
title?: string
|
title?: string
|
||||||
tags?: string[]
|
tags?: string[]
|
||||||
locationName?: string
|
locationName?: string
|
||||||
|
|||||||
@ -82,7 +82,7 @@ export const CURRENT_STORAGE: StorageType =
|
|||||||
// SETTINGS
|
// SETTINGS
|
||||||
|
|
||||||
export const PRO_MODE_ENABLED = process.env.NEXT_PUBLIC_PRO_MODE === '1';
|
export const PRO_MODE_ENABLED = process.env.NEXT_PUBLIC_PRO_MODE === '1';
|
||||||
export const BLUR_DISABLED = process.env.NEXT_PUBLIC_BLUR_DISABLED === '1';
|
export const BLUR_ENABLED = process.env.NEXT_PUBLIC_BLUR_DISABLED !== '1';
|
||||||
export const GEO_PRIVACY_ENABLED = process.env.NEXT_PUBLIC_GEO_PRIVACY === '1';
|
export const GEO_PRIVACY_ENABLED = process.env.NEXT_PUBLIC_GEO_PRIVACY === '1';
|
||||||
export const PRIORITY_ORDER_ENABLED =
|
export const PRIORITY_ORDER_ENABLED =
|
||||||
process.env.NEXT_PUBLIC_IGNORE_PRIORITY_ORDER !== '1';
|
process.env.NEXT_PUBLIC_IGNORE_PRIORITY_ORDER !== '1';
|
||||||
@ -121,7 +121,7 @@ export const CONFIG_CHECKLIST_STATUS = {
|
|||||||
showFilmSimulations: SHOW_FILM_SIMULATIONS,
|
showFilmSimulations: SHOW_FILM_SIMULATIONS,
|
||||||
showExifInfo: SHOW_EXIF_DATA,
|
showExifInfo: SHOW_EXIF_DATA,
|
||||||
isProModeEnabled: PRO_MODE_ENABLED,
|
isProModeEnabled: PRO_MODE_ENABLED,
|
||||||
isBlurEnabled: !BLUR_DISABLED,
|
isBlurEnabled: BLUR_ENABLED,
|
||||||
isGeoPrivacyEnabled: GEO_PRIVACY_ENABLED,
|
isGeoPrivacyEnabled: GEO_PRIVACY_ENABLED,
|
||||||
isPriorityOrderEnabled: PRIORITY_ORDER_ENABLED,
|
isPriorityOrderEnabled: PRIORITY_ORDER_ENABLED,
|
||||||
isPublicApiEnabled: PUBLIC_API_ENABLED,
|
isPublicApiEnabled: PUBLIC_API_ENABLED,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user