convert gallery-list types to use embedded/fetched entry pattern

- currently amendVariants no longer works
This commit is contained in:
lightling 2024-06-27 18:43:59 -04:00
parent e4da36a23c
commit 15ed807d8c
6 changed files with 91 additions and 62 deletions

View file

@ -1,4 +1,5 @@
import type { EntryTagCollection } from '../entryTag'
import type { ListWithEntries } from './shared'
/**
* A partial definition of a {@link GalleryEntry}
@ -54,7 +55,7 @@ export type GalleryEntryInheritedProperties = {
* Defines an entry in a gallery that can be displayed in a tiled manner
* and can be clicked by a visitor to display its variants or the entry itself if there are none
*/
export type GalleryEntry = GalleryEntryInheritedProperties & {
export type GalleryEntryProperties = GalleryEntryInheritedProperties & {
/**
* the url to the thumbnail to show for the entry in the gallery tile
*/
@ -63,34 +64,16 @@ export type GalleryEntry = GalleryEntryInheritedProperties & {
* the url to the entry itself
*/
url?: string
/**
* optional variants for the entry;
* this is a recursive definition of {@link GalleryEntry entries}
* which can be navigated deeper into in a gallery
* in a manner like a folder in a file-based operating system
*/
variants?: GalleryEntries
}
/**
* Defines the list of entries in a gallery,
* a key-value object where the value is the entry,
* and the key represents the id of a piece;
* it is important for this to be uniquely defined at minimum within
* the scope of the entry in relation to surrounding variants
* in order for the app to properly navigate through variants
* and ultimately the view page displaying the entry
*/
export type GalleryEntries = { [idOrTitle: string]: GalleryEntry }
export type GalleryEntry =
& GalleryEntryProperties
& ListWithEntries<GalleryEntryProperties>
/**
* Defines the model of the `GalleryList` template
*/
export type GalleryList = {
/**
* the entries to display in a gallery-list template
*/
entries: GalleryEntries
/**
* the tags to use for filtering entries
*/
@ -101,4 +84,4 @@ export type GalleryList = {
* in order to manually style (CSS filtering/opacity/etc.)
*/
removeFromView?: boolean
}
} & ListWithEntries<GalleryEntry>

View file

@ -4,14 +4,14 @@
* and the value is the entry config itself
* (defined as `T` based on the type of the entries in the implemented list)
*/
export type ListEntry<T> = { [key: string]: T }
export type ListEntries<T> = { [key: string]: T }
/**
* Defines entries that are fetched from remote config files.
* Stored in key-value format where the key is the id of the entry,
* and the value is the url to the config file.
*/
export type ListRemoteEntries<T> = { [key: string]: string }
export type ListRemoteEntries = { [key: string]: string }
/**
* Defines a list-type template that has config entries defined by id.
@ -29,5 +29,12 @@ export type ListWithEntries<T> = {
/**
* Entries that are embedded directly in the list config
*/
embeddedEntries?: ListEntry
embeddedEntries?: ListEntries<T>
}
export type ListEntriesWithNestedEntries<T> = { [key: string]: T & ListWithEntries<T> }
export type ListWithNestedEntries<T> = {
entries?: ListRemoteEntries
embeddedEntries?: ListEntriesWithNestedEntries<T>
}