1
0
Fork 0

reorganization

store components, types, etc in close proximity rather than split by "type"
This commit is contained in:
lightling 2024-03-20 23:50:15 -04:00
parent 643b7d1bee
commit 958f5857fd
17 changed files with 85 additions and 106 deletions

View file

@ -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'
/**

View file

@ -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

View file

@ -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<Template, () => Promise<any>> = {
'markdown': markdownBody,

View file

@ -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 }

View file

@ -1,9 +0,0 @@
import { FilterDefinition, ProjectFilterCategory } from './filter'
export type ProjectList = {
projects: { [key: string]: {
config: string
content: string
}}
filters?: FilterDefinition[] | ProjectFilterCategory[]
}

View file

@ -1,8 +0,0 @@
export type TagDefinition = {
displayName: string
className: string
}
export type Tag =
| TagDefinition
| string

View file

@ -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])
}
}

View file

@ -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[]

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import { computed, defineEmits, defineProps } from 'vue'
import type { GalleryEntry } from 'src/types/galleries/galleryList'
import { getTitleFromEntryOrId } from 'src/utilities/galleries'
import type { GalleryEntry } from './gallery'
import { getTitleFromEntryOrId } from './gallery-utilities'
const props = defineProps<{
entry: GalleryEntry,

View file

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

View file

@ -1,9 +1,9 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import type { GalleryEntry, GalleryList } from 'src/types/galleries/galleryList'
import type { GalleryEntry, GalleryList } from './gallery'
import { type GalleryListDefinition } from 'content/routes.js'
import { amendVariantsWithDefaults, getTitleFromEntryOrId } from 'src/utilities/galleries'
import { amendVariantsWithDefaults, getTitleFromEntryOrId } from './gallery-utilities'
import { fetchAndParseYaml } from 'src/utilities/fetch'
import { getCurrentRoute } from 'src/utilities/vuetils'
import { useRouteStore } from 'src/routes'

View file

@ -1,14 +1,13 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import type { ProjectList } from 'src/types/projects/projectList'
import type { ProjectList, ProjectListingInfo } from './project'
import { type ProjectListDefinition } from 'content/routes.js'
import type { ProjectListingInfo } from 'src/types/projects/project'
import { fetchAndParseYaml } from 'src/utilities/fetch'
import { getCurrentRoute } from 'src/utilities/vuetils'
import { useRouteStore } from 'src/routes'
import ProjectTile from 'src/components/projects/project-tile.vue'
import ProjectTile from './project-tile.vue'
const projectIds = ref([] as string[])
const projects = ref({} as { [key: string]: ProjectListingInfo })

View file

@ -3,7 +3,7 @@ import { computed } from 'vue'
import { marked } from 'marked'
import { getFormattedPeriod } from 'src/utilities/dom'
import type { ProjectListingInfo } from 'src/types/projects/project'
import type { ProjectListingInfo } from './project'
import { getCurrentRoute } from 'src/utilities/vuetils'
const props = defineProps<{

View file

@ -1,9 +1,8 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import type { ProjectList } from 'src/types/projects/projectList'
import type { ProjectList, ProjectListingInfo } from './project'
import { type ProjectListDefinition } from 'content/routes.js'
import type { ProjectListingInfo } from 'src/types/projects/project'
import { fetchAndParseMarkdown, fetchAndParseYaml } from 'src/utilities/fetch'
import { getCurrentRoute } from 'src/utilities/vuetils'
import { useRouteStore } from 'src/routes'

View file

@ -50,3 +50,67 @@ export type ProjectStoreEntry = {
*/
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[]
}