styles on thumbnails/images
- thumbnail and image background - apply thumbnail position as object-position directly
This commit is contained in:
parent
a9470dd088
commit
e915258517
4 changed files with 33 additions and 4 deletions
|
@ -15,6 +15,14 @@ defineEmits<{
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const title = computed(() => getTitleFromEntryOrId(props.entry, props.id))
|
const title = computed(() => getTitleFromEntryOrId(props.entry, props.id))
|
||||||
|
const styles = computed(() => {
|
||||||
|
const stylesReturn: Record<string, string> = {}
|
||||||
|
if (!!props.entry.thumbnailBackground) {
|
||||||
|
stylesReturn.background = props.entry.thumbnailBackground
|
||||||
|
}
|
||||||
|
stylesReturn['object-position'] = props.entry.thumbnailPosition || 'center center'
|
||||||
|
return stylesReturn
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
|
@ -27,7 +35,7 @@ const title = computed(() => getTitleFromEntryOrId(props.entry, props.id))
|
||||||
img(
|
img(
|
||||||
:src='entry.thumbnailUrl || entry.url'
|
:src='entry.thumbnailUrl || entry.url'
|
||||||
:alt='entry.description || id'
|
:alt='entry.description || id'
|
||||||
:data-thumbnail-position='entry.thumbnailPosition || "center center"'
|
:style='styles'
|
||||||
)
|
)
|
||||||
.caption-wrapper
|
.caption-wrapper
|
||||||
p.variants(
|
p.variants(
|
||||||
|
|
|
@ -38,6 +38,12 @@ export const _amendVariantWithDefaults = (parent: GalleryEntryInheritedPropertie
|
||||||
if (!variant.thumbnailPosition && !!parent.thumbnailPosition) {
|
if (!variant.thumbnailPosition && !!parent.thumbnailPosition) {
|
||||||
variant.thumbnailPosition = parent.thumbnailPosition
|
variant.thumbnailPosition = parent.thumbnailPosition
|
||||||
}
|
}
|
||||||
|
if (!variant.thumbnailBackground && !!parent.thumbnailBackground) {
|
||||||
|
variant.thumbnailBackground = parent.thumbnailBackground
|
||||||
|
}
|
||||||
|
if (!variant.background && !!parent.background) {
|
||||||
|
variant.background = parent.background
|
||||||
|
}
|
||||||
|
|
||||||
return variant
|
return variant
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
|
|
||||||
import type { GalleryEntry, GalleryList } from './gallery'
|
import type { GalleryEntry, GalleryList } from './gallery'
|
||||||
import { type GalleryListDefinition } from 'content/routes.js'
|
import { type GalleryListDefinition } from 'content/routes.js'
|
||||||
|
@ -27,6 +27,13 @@ const routeStore = useRouteStore()
|
||||||
const routeConfig = routeStore._routes[currentRoute.path.substring(0, currentRoute.path.length - 5)] as GalleryListDefinition
|
const routeConfig = routeStore._routes[currentRoute.path.substring(0, currentRoute.path.length - 5)] as GalleryListDefinition
|
||||||
const routeSubConfig = routeStore._routes[currentRoute.path]
|
const routeSubConfig = routeStore._routes[currentRoute.path]
|
||||||
const title = ref('')
|
const title = ref('')
|
||||||
|
const styles = computed(() => {
|
||||||
|
const stylesReturn: Record<string, string> = {}
|
||||||
|
if (!!entry.value.background) {
|
||||||
|
stylesReturn.background = entry.value.background
|
||||||
|
}
|
||||||
|
return stylesReturn
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
config.value = await fetchAndParseYaml<GalleryList>(routeConfig.config)
|
config.value = await fetchAndParseYaml<GalleryList>(routeConfig.config)
|
||||||
|
@ -51,6 +58,7 @@ onMounted(async () => {
|
||||||
.view-outlet
|
.view-outlet
|
||||||
img(
|
img(
|
||||||
:src='entry.url || entry.thumbnailUrl'
|
:src='entry.url || entry.thumbnailUrl'
|
||||||
|
:style='styles'
|
||||||
)
|
)
|
||||||
.view-content
|
.view-content
|
||||||
p {{ title }}
|
p {{ title }}
|
||||||
|
|
11
src/views/gallery/gallery.d.ts
vendored
11
src/views/gallery/gallery.d.ts
vendored
|
@ -4,6 +4,10 @@
|
||||||
* that can be passed down from a top-level entry down to its variants
|
* that can be passed down from a top-level entry down to its variants
|
||||||
*/
|
*/
|
||||||
export type GalleryEntryInheritedProperties = {
|
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
|
* [SUPPORTS MARKDOWN] a place for the siteowner to describe the entry
|
||||||
*/
|
*/
|
||||||
|
@ -22,10 +26,13 @@ export type GalleryEntryInheritedProperties = {
|
||||||
* @see {@link GalleryList.tags}
|
* @see {@link GalleryList.tags}
|
||||||
*/
|
*/
|
||||||
tags: string[]
|
tags: string[]
|
||||||
|
/**
|
||||||
|
* css background applied to the thumbnail (useful for transparent images)
|
||||||
|
*/
|
||||||
|
thumbnailBackground?: string
|
||||||
/**
|
/**
|
||||||
* the position of the thumbnail;
|
* the position of the thumbnail;
|
||||||
* reflects this as a dataset attribute that can be targeted by CSS selectors
|
* this will be applied as css `object-position`
|
||||||
* for the purpose of positioning the thumbnail
|
|
||||||
*/
|
*/
|
||||||
thumbnailPosition?: string
|
thumbnailPosition?: string
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue