From 9df9c06f64fd88525cb1ec2606e31a498bd2a019 Mon Sep 17 00:00:00 2001 From: Lucie <25330882+lihbr@users.noreply.github.com> Date: Fri, 25 Nov 2022 13:13:44 -0500 Subject: [PATCH] feat: image previews (#104) Co-authored-by: lihbr --- components/account/AccountHeader.vue | 22 +++++++++++++++------- components/modal/ModalContainer.vue | 5 ++++- components/status/StatusAttachment.vue | 7 ++++++- composables/dialog.ts | 15 +++++++++++---- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/components/account/AccountHeader.vue b/components/account/AccountHeader.vue index eade033f..c8648f19 100644 --- a/components/account/AccountHeader.vue +++ b/components/account/AccountHeader.vue @@ -43,19 +43,27 @@ function getFieldNameIcon(fieldName: string) { if (fieldNameIcons[name]) return fieldNameIcons[name] } + +function previewHeader() { + openImagePreviewDialog({ src: account.header, alt: `${account.username}'s profile header` }) +} + +function previewAvatar() { + openImagePreviewDialog({ src: account.avatar, alt: account.username }) +} diff --git a/composables/dialog.ts b/composables/dialog.ts index 429af5db..848b8a51 100644 --- a/composables/dialog.ts +++ b/composables/dialog.ts @@ -1,6 +1,7 @@ import type { Draft } from './statusDrafts' import { STORAGE_KEY_FIRST_VISIT, STORAGE_KEY_ZEN_MODE } from '~/constants' +export const imagePreview = ref({ src: '', alt: '' }) export const isFirstVisit = useLocalStorage(STORAGE_KEY_FIRST_VISIT, true) export const isZenMode = useLocalStorage(STORAGE_KEY_ZEN_MODE, false) export const toggleZenMode = useToggle(isZenMode) @@ -8,6 +9,7 @@ export const toggleZenMode = useToggle(isZenMode) export const isUserSwitcherOpen = ref(false) export const isSigninDialogOpen = ref(false) export const isPublishDialogOpen = ref(false) +export const isImagePreviewDialogOpen = ref(false) export const isPreviewHelpOpen = ref(isFirstVisit.value) export function openUserSwitcher() { @@ -19,10 +21,6 @@ export function openSigninDialog() { isUserSwitcherOpen.value = false } -export function openPreviewHelp() { - isPreviewHelpOpen.value = true -} - export function openPublishDialog(draft?: Draft) { if (draft) dialogDraft.draft.value = draft @@ -34,3 +32,12 @@ if (isPreviewHelpOpen.value) { isFirstVisit.value = false }) } + +export function openImagePreviewDialog(image: { src: string; alt: string }) { + imagePreview.value = image + isImagePreviewDialogOpen.value = true +} + +export function openPreviewHelp() { + isPreviewHelpOpen.value = true +}