From 958f5857fd9bcc9c213e31f26401e5fbe8aa9a3f Mon Sep 17 00:00:00 2001 From: Lightling Date: Wed, 20 Mar 2024 23:50:15 -0400 Subject: [PATCH] reorganization store components, types, etc in close proximity rather than split by "type" --- src/components/inflators/descriptionList.ts | 2 +- src/components/inflators/embed.ts | 2 +- src/routes.ts | 10 +-- src/types/projects/filter.ts | 48 -------------- src/types/projects/projectList.ts | 9 --- src/types/projects/tag.ts | 8 --- src/utilities/dom.ts | 19 ------ src/views/{ => gallery}/gallery-list.vue | 6 +- .../gallery}/gallery-tile.vue | 4 +- .../gallery/gallery-utilities.ts} | 5 +- src/views/{ => gallery}/gallery-view.vue | 4 +- .../gallery/gallery.d.ts} | 0 src/views/{ => markdown}/markdown.vue | 0 src/views/{ => project}/project-list.vue | 5 +- .../project}/project-tile.vue | 2 +- src/views/{ => project}/project-view.vue | 3 +- .../project.ts => views/project/project.d.ts} | 64 +++++++++++++++++++ 17 files changed, 85 insertions(+), 106 deletions(-) delete mode 100644 src/types/projects/filter.ts delete mode 100644 src/types/projects/projectList.ts delete mode 100644 src/types/projects/tag.ts rename src/views/{ => gallery}/gallery-list.vue (94%) rename src/{components/galleries => views/gallery}/gallery-tile.vue (85%) rename src/{utilities/galleries.ts => views/gallery/gallery-utilities.ts} (93%) rename src/views/{ => gallery}/gallery-view.vue (94%) rename src/{types/galleries/galleryList.ts => views/gallery/gallery.d.ts} (100%) rename src/views/{ => markdown}/markdown.vue (100%) rename src/views/{ => project}/project-list.vue (85%) rename src/{components/projects => views/project}/project-tile.vue (94%) rename src/views/{ => project}/project-view.vue (91%) rename src/{types/projects/project.ts => views/project/project.d.ts} (51%) diff --git a/src/components/inflators/descriptionList.ts b/src/components/inflators/descriptionList.ts index e932681..2927a44 100644 --- a/src/components/inflators/descriptionList.ts +++ b/src/components/inflators/descriptionList.ts @@ -1,4 +1,4 @@ -import { type ProjectListingInfo } from 'src/types/projects/project' +import type { ProjectListingInfo } from 'src/views/project/project' import { getFormattedPeriod } from 'src/utilities/dom' /** diff --git a/src/components/inflators/embed.ts b/src/components/inflators/embed.ts index 5029a8b..c51a0d2 100644 --- a/src/components/inflators/embed.ts +++ b/src/components/inflators/embed.ts @@ -3,7 +3,7 @@ import { inflateDetailsElements } from './details' import { inflateImageEmbeds } from './image' import { inflateVideoEmbeds } from './video' -import { type ProjectListingInfo } from 'src/types/projects/project' +import type { ProjectListingInfo } from 'src/views/project/project' /** * Inflates various supported embeds diff --git a/src/routes.ts b/src/routes.ts index a75a33e..4106061 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -12,11 +12,11 @@ import { type Template, } from 'content/routes.js' -const markdownBody = () => import ('./views/markdown.vue') -const projectListBody = () => import ('./views/project-list.vue') -const projectViewBody = () => import ('./views/project-view.vue') -const galleryListBody = () => import ('./views/gallery-list.vue') -const galleryViewBody = () => import ('./views/gallery-view.vue') +const markdownBody = () => import ('./views/markdown/markdown.vue') +const projectListBody = () => import ('./views/project/project-list.vue') +const projectViewBody = () => import ('./views/project/project-view.vue') +const galleryListBody = () => import ('./views/gallery/gallery-list.vue') +const galleryViewBody = () => import ('./views/gallery/gallery-view.vue') export const templates: Record Promise> = { 'markdown': markdownBody, diff --git a/src/types/projects/filter.ts b/src/types/projects/filter.ts deleted file mode 100644 index 830eeab..0000000 --- a/src/types/projects/filter.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { type ProjectListingInfo } from 'src/types/projects/project' - -/** - * 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 } diff --git a/src/types/projects/projectList.ts b/src/types/projects/projectList.ts deleted file mode 100644 index 80610ac..0000000 --- a/src/types/projects/projectList.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { FilterDefinition, ProjectFilterCategory } from './filter' - -export type ProjectList = { - projects: { [key: string]: { - config: string - content: string - }} - filters?: FilterDefinition[] | ProjectFilterCategory[] -} diff --git a/src/types/projects/tag.ts b/src/types/projects/tag.ts deleted file mode 100644 index bd00a95..0000000 --- a/src/types/projects/tag.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type TagDefinition = { - displayName: string - className: string -} - -export type Tag = -| TagDefinition -| string diff --git a/src/utilities/dom.ts b/src/utilities/dom.ts index 9765973..d23a4be 100644 --- a/src/utilities/dom.ts +++ b/src/utilities/dom.ts @@ -1,7 +1,6 @@ import rfdc from 'rfdc' import { type DateRange } from 'src/types/shared/dateRange' -import { type FilterState } from 'src/types/projects/filter' export const deepCopy = rfdc() @@ -32,21 +31,3 @@ export const findFirstMatchingChild = ( element: ParentNode, ...selectors: strin export const getFormattedPeriod = (period: DateRange) => { return `${period.from}${!!period.to ? ' - ' + period.to : ''}` } - -/** - * Checks a project's tags to see if any of them match any of the state tags - * @param state the state to check against - * @param tags the tags to check - * @returns - * - `true` if any of the project's tags are `true` in the state - * - `true` if none of the tags in the filter state are `true` (indicating no filters being set in the panel) - * - `false` if the project has no tags or if none of its tags are toggled to `true` in the filters panel - */ -export const doFiltersMatchTags = (state: FilterState, tags?: string[]) => { - const anyIsTrue = !!Object.keys(state).find(tag => !!state[tag]) - if (!anyIsTrue) { - return true - } else { - return !!tags?.find(tag => !!state[tag]) - } -} diff --git a/src/views/gallery-list.vue b/src/views/gallery/gallery-list.vue similarity index 94% rename from src/views/gallery-list.vue rename to src/views/gallery/gallery-list.vue index cd53887..1f8019a 100644 --- a/src/views/gallery-list.vue +++ b/src/views/gallery/gallery-list.vue @@ -2,14 +2,14 @@ import { onMounted, ref } from 'vue' import { type RouteRecordRaw, useRouter } from 'vue-router' -import type { GalleryEntries, GalleryList } from 'src/types/galleries/galleryList' +import type { GalleryEntries, GalleryList } from './gallery' import { type GalleryListDefinition } from 'content/routes.js' -import { amendVariantsWithDefaults } from 'src/utilities/galleries' +import { amendVariantsWithDefaults } from './gallery-utilities' import { fetchAndParseYaml } from 'src/utilities/fetch' import { getCurrentRoute } from 'src/utilities/vuetils' import { useRouteStore } from 'src/routes' -import GalleryTile from 'src/components/galleries/gallery-tile.vue' +import GalleryTile from './gallery-tile.vue' const props = defineProps<{ variants: string[] diff --git a/src/components/galleries/gallery-tile.vue b/src/views/gallery/gallery-tile.vue similarity index 85% rename from src/components/galleries/gallery-tile.vue rename to src/views/gallery/gallery-tile.vue index b69dd7a..b548e52 100644 --- a/src/components/galleries/gallery-tile.vue +++ b/src/views/gallery/gallery-tile.vue @@ -1,8 +1,8 @@