migrate types to lib/types

This commit is contained in:
lightling 2024-05-03 17:19:14 -04:00
parent 531fb2fc4b
commit f48118122b
20 changed files with 60 additions and 32 deletions

View file

@ -1,4 +1,5 @@
import type { ProjectListingInfo } from 'src/views/project/project'
import type { ProjectListingInfo } from '@goldenwere/static-web-templates-types'
import { getFormattedPeriod } from 'src/utilities/dom'
/**

View file

@ -1,10 +1,10 @@
import type { ProjectListingInfo } from '@goldenwere/static-web-templates-types'
import { inflateDescriptionListEmbeds } from './descriptionList'
import { inflateDetailsElements } from './details'
import { inflateImageEmbeds } from './image'
import { inflateVideoEmbeds } from './video'
import type { ProjectListingInfo } from 'src/views/project/project'
/**
* Inflates various supported embeds
* @param _window the reference to the window

View file

@ -1,4 +0,0 @@
export type DateRange = {
from: string
to: string
}

View file

@ -1,5 +0,0 @@
export interface Link {
caption?: string
href: string
target?: '_blank' | '_parent' | '_self' | '_top'
}

View file

@ -1,6 +1,8 @@
import rfdc from 'rfdc'
import { type DateRange } from 'src/types/shared/dateRange'
import type {
DateRange,
} from '@goldenwere/static-web-templates-types'
export const deepCopy = rfdc()

View file

@ -1,9 +1,12 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { type GalleryListDefinition } from '@goldenwere/static-web-templates-types'
import type {
GalleryEntry,
GalleryList,
GalleryListDefinition,
} from '@goldenwere/static-web-templates-types'
import { type RouteRecordRaw, useRouter } from 'vue-router'
import type { GalleryDisplayedEntries, GalleryList } from './gallery'
import { amendVariantsWithDefaults } from './gallery-utilities'
import { fetchAndParseYaml, storage } from 'src/utilities/fetch'
import { getCurrentRoute } from 'src/utilities/vuetils'
@ -11,6 +14,17 @@ import { useRouteStore } from 'src/routes'
import GalleryTile from './gallery-tile.vue'
/**
* A wrapper around {@link GalleryEntries} for the app's use only which adds additional fields
* in order for the app to effectively display the entries.
*/
type GalleryDisplayedEntries = { [idOrTitle: string]: GalleryEntry & {
/**
* specifies whether the entry is hidden by the tags selected by a visitor
*/
hidden?: boolean
}}
const props = defineProps<{
variants: string[]
}>()

View file

@ -1,7 +1,9 @@
<script setup lang="ts">
import { computed } from 'vue'
import type {
GalleryEntry,
} from '@goldenwere/static-web-templates-types'
import type { GalleryEntry } from './gallery'
import { getTitleFromEntryOrId } from './gallery-utilities'
const props = defineProps<{

View file

@ -1,6 +1,9 @@
import { deepCopy } from 'src/utilities/dom'
import type {
GalleryEntry,
GalleryEntryInheritedProperties,
} from '@goldenwere/static-web-templates-types'
import type { GalleryEntry, GalleryEntryInheritedProperties } from './gallery'
import { deepCopy } from 'src/utilities/dom'
export const getTitleFromEntryOrId = (entry: GalleryEntry, id: string) => (
entry.title !== undefined

View file

@ -1,8 +1,11 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { type GalleryListDefinition } from '@goldenwere/static-web-templates-types'
import type {
GalleryEntry,
GalleryList,
GalleryListDefinition,
} from '@goldenwere/static-web-templates-types'
import type { GalleryEntry, GalleryList } from './gallery'
import { amendVariantsWithDefaults, getTitleFromEntryOrId } from './gallery-utilities'
import { fetchAndParseYaml } from 'src/utilities/fetch'
import { getCurrentRoute } from 'src/utilities/vuetils'

View file

@ -1,137 +0,0 @@
/**
* A partial definition of a {@link GalleryEntry}
* which defines the properties of an entry
* that can be passed down from a top-level entry down to its variants
*/
export type GalleryEntryInheritedProperties = {
/**
* css background applied to the image (useful for transparent images)
*/
background?: string
/**
* [SUPPORTS MARKDOWN] a place for the siteowner to describe the entry
*/
description?: string
/**
* a key-value pair set of general-purpose fields to additionally describe the entry
* @example entry.fields = {
* 'date': '1960/01/01',
* 'rating': 'general',
* }
*/
fields?: Record<string, string>
/**
* array of tag-ids that apply to the art;
* this is used to allow a visitor to filter out entries of a specific tag
* @see {@link GalleryList.tags}
*/
tags: string[]
/**
* css background applied to the thumbnail (useful for transparent images)
*/
thumbnailBackground?: string
/**
* the position of the thumbnail;
* this will be applied as css `object-position`
*/
thumbnailPosition?: string
/**
* the title of the entry
*/
title: string | null | undefined
/**
* any content warnings that apply to the entry,
* which will be used to apply the `.warning` classname
* to the DOM of a gallery tile
* and will be displayed with the tile
*/
warning?: string
}
/**
* 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 & {
/**
* the url to the thumbnail to show for the entry in the gallery tile
*/
thumbnailUrl?: string
/**
* 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 }
/**
* A wrapper around {@link GalleryEntries} for the app's use only which adds additional fields
* in order for the app to effectively display the entries.
*/
export type GalleryDisplayedEntries = { [idOrTitle: string]: GalleryEntry & {
/**
* specifies whether the entry is hidden by the tags selected by a visitor
*/
hidden?: boolean
}}
/**
* Defines a tag used by entries in a gallery
* used for filtering entries from view
*/
export type GalleryTag = {
/**
* specifies a category that the tag belongs to
* in order to optionally organize them in the view;
* if category is not specified, tags will be assigned
* "NoCategory" and organized into a section without a heading
* placed before any other sections formed by categories (if any)
*/
category?: string
/**
* specifies the name that the tag will appear as in the DOM;
* if not specified, the id of the tag will be used in its place
*/
displayName?: string
}
/**
* Defines the list of tags in a gallery,
* a key-value object where the value is the entry,
* and the key represents the id of a tag;
* the id of a tag must be unique,
* and the ids specified in a gallery entry must match
* the ids specified in `GalleryTags` in order for them to work effectively
*/
export type GalleryTags = { [id: string]: GalleryTag }
/**
* 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
*/
tags: GalleryTags
}

View file

@ -1,8 +1,11 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { type ProjectListDefinition } from '@goldenwere/static-web-templates-types'
import type {
ProjectList,
ProjectListingInfo,
ProjectListDefinition,
} from '@goldenwere/static-web-templates-types'
import type { ProjectList, ProjectListingInfo } from './project'
import { fetchAndParseYaml } from 'src/utilities/fetch'
import { getCurrentRoute } from 'src/utilities/vuetils'
import { useRouteStore } from 'src/routes'

View file

@ -1,9 +1,11 @@
<script setup lang="ts">
import { computed } from 'vue'
import { marked } from 'marked'
import type {
ProjectListingInfo,
} from '@goldenwere/static-web-templates-types'
import { getFormattedPeriod } from 'src/utilities/dom'
import type { ProjectListingInfo } from './project'
import { getCurrentRoute } from 'src/utilities/vuetils'
const props = defineProps<{

View file

@ -1,8 +1,11 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { type ProjectListDefinition } from '@goldenwere/static-web-templates-types'
import type {
ProjectList,
ProjectListingInfo,
ProjectListDefinition,
} from '@goldenwere/static-web-templates-types'
import type { ProjectList, ProjectListingInfo } from './project'
import { fetchAndParseMarkdown, fetchAndParseYaml } from 'src/utilities/fetch'
import { getCurrentRoute } from 'src/utilities/vuetils'
import { useRouteStore } from 'src/routes'

View file

@ -1,116 +0,0 @@
import { DateRange } from 'src/types/shared/dateRange'
/**
* This describes aditional information about a project.
* to display when listing the project on the portfolio page.
* At minimum, the title should be specified.
*/
export type ProjectListingInfo = {
/**[Supports Markdown]
* Caption displayed below the title of the project on the projects page
*/
caption?: string
/**
* When defined, the period will be displayed as {from} - {to}
*/
period?: DateRange
/**[Supports Markdown]
* Information to summarize a project
*/
summary?: string
/**
* Tags that correspond to project filters on the portfolio page if defined
*/
tags?: string[]
/**[Supports Markdown]
* The title of the project
*/
title: string
/**[CSS:background]
* Background image, repeat, attachment, and position for the project
*/
thumbnailBackground?: string
/**[CSS:background-size]
* Background image size
*/
thumbnailBackgroundSize?: string
}
/**
* This concatenates project files for entry within the store.
*/
export type ProjectStoreEntry = {
/**
* Content pulled from the projects' markdown (.md) file
*/
content?: string
/**
* Listing information pulled from the projects' yaml (.yml) file
*/
listing?: ProjectListingInfo
}
/**
* Defines a filter category in the filters panel
*/
export type ProjectFilterCategory = {
/**
* The heading of the category
*/
heading: string
/**
* The filters associated with the category, or more categories
*/
filters: FilterDefinition[] | ProjectFilterCategory[]
}
/**
* Defines a filter for a project
*/
export type FilterDefinition = {
/**
* The name to display in the filters panel
*/
displayName: string
/**
* The tag which the filter corresponds to for when defined in {@link ProjectListingInfo.tags}
*/
tag: string
}
/**
* Whenever a filter is toggled in the filters panel, this holds the data regarding that change
*/
export type FilterChangeEvent = {
/**
* The tag that the filter is associated with
*/
tag: string
/**
* The toggle state of the filter
*/
value: boolean
}
/**
* Defines the state of the filters panel
*/
export type FilterState = { [tag: string]: boolean }
export type TagDefinition = {
displayName: string
className: string
}
export type Tag =
| TagDefinition
| string
export type ProjectList = {
projects: { [key: string]: {
config: string
content: string
}}
filters?: FilterDefinition[] | ProjectFilterCategory[]
}