Skip to content

Commit

Permalink
Update ImageGallery, InlinePicture and SogLink
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-lerch committed Jun 21, 2024
1 parent 690e92d commit d699ef4
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 86 deletions.
20 changes: 9 additions & 11 deletions components/imageGalery.vue → components/ImageGallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div
class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"
@click="$emit('close')"
></div>
/>

<!-- Modal -->
<div class="absolute p-2">
Expand All @@ -30,7 +30,7 @@
/>
</svg>
</div>
<nuxt-picture
<NuxtPicture
:src="`${currentImg.src}`"
:alt="`${currentImg.alt}`"
format="webp"
Expand All @@ -41,13 +41,11 @@
</div>
</template>

<script>
export default {
name: 'InlineGalery',
props: {
open: { type: Boolean, default: false },
currentImg: { type: Object, default: () => {} },
},
}
<script setup lang="ts">
defineProps<{
open: boolean
currentImg: { src: string; alt: string }
}>()
defineEmits(['close'])
</script>
<style></style>
50 changes: 20 additions & 30 deletions components/inlinePicture.vue → components/InlinePicture.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
:alt="`${imgAlt}`"
class="p-2"
>
<nuxt-img
<NuxtImg
:src="`${imgSrc}`"
:alt="`${imgAlt}`"
format="webp"
Expand All @@ -46,7 +46,7 @@
/>
</SogLink>
<div v-else class="cursor-pointer" @click="galery = true">
<nuxt-img
<NuxtImg
:src="`${imgSrc}`"
:alt="`${imgAlt}`"
format="webp"
Expand All @@ -59,41 +59,31 @@
{{ imgSub }}
</div>
</div>
<image-galery
<ImageGallery
:open="galery"
:current-img="{
src: imgSrc,
alt: imgAlt,
}"
@close="closeGalery"
></image-galery>
@close="closeGallery"
/>
</div>
</template>

<script>
import SogLink from '~/components/sogLink'
import ImageGalery from '~/components/imageGalery.vue'
export default {
name: 'InlinePicture',
components: { SogLink, ImageGalery },
props: {
imgSrc: { type: String, default: '' },
imgAlt: { type: String, default: '' },
imgSub: { type: String, default: null },
imgUrl: { type: String, default: '/' },
position: { type: String, default: 'left' },
size: { type: String, default: 'full' },
marginLeft: { type: Boolean, default: true },
},
data: () => ({
galery: false,
}),
methods: {
closeGalery() {
this.galery = false
},
},
<script setup lang="ts">
defineProps({
imgSrc: { type: String, default: '' },
imgAlt: { type: String, default: '' },
imgSub: { type: String, default: null },
imgUrl: { type: String, default: '/' },
position: { type: String, default: 'left' },
size: { type: String, default: 'full' },
marginLeft: { type: Boolean, default: true },
})
const gallery = ref(false)
const closeGallery = () => {
gallery.value = false
}
</script>

<style></style>
29 changes: 29 additions & 0 deletions components/SogLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<div>
<NuxtLink
v-if="dest !== '' && !external"
:to="localePath(`/${dest}`)"
:alt="alt"
>
<slot />
</NuxtLink>
<a
v-else-if="dest !== '' && external"
:href="dest"
:alt="alt"
rel="noopener"
target="_blank"
>
<slot />
</a>
<slot v-else />
</div>
</template>

<script setup lang="ts">
const props = defineProps<{ dest: string, alt: string }>()
const localePath = useLocalePath()
const external = computed(() => props.dest.indexOf('https://') === 0 || props.dest.indexOf('http://') === 0)
</script>
45 changes: 0 additions & 45 deletions components/sogLink.vue

This file was deleted.

0 comments on commit d699ef4

Please sign in to comment.