Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit a692df7

Browse files
feat: center snippet preview + remove devtools ui components
1 parent bf80166 commit a692df7

File tree

6 files changed

+40
-139
lines changed

6 files changed

+40
-139
lines changed

client/components/MediaPreviewImage.vue

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useKeyPath } from '~~/composables/keys'
88
const route = useRoute()
99
1010
const imageRef = ref()
11+
const previewRef = ref()
1112
const mode = ref<'scale' | 'real'>('scale')
1213
const config = inject<any>('mediaViewerConfig')
1314
@@ -19,7 +20,7 @@ const isImage = computed(() => previewState?.stats?.mimetype?.startsWith('image/
1920
2021
const dragging = ref(false)
2122
const offsetX = ref(0)
22-
const offsetY = ref(0)
23+
const offsetY = ref(75)
2324
const initialX = ref(0)
2425
const initialY = ref(0)
2526
@@ -55,16 +56,20 @@ onBeforeUnmount(() => {
5556
imageRef.value?.removeEventListener('mousedown', onMousedown)
5657
})
5758
58-
watch(mode, () => {
59+
watch([mode, () => previewState?.targetWidth], () => {
60+
const viewportWidth = previewRef.value?.clientWidth ?? 0
61+
const mediaWidth = previewState?.targetWidth ?? 0
62+
const centerX = (viewportWidth - mediaWidth) / 2
63+
5964
initialX.value = 0
6065
initialY.value = 0
61-
offsetX.value = 0
62-
offsetY.value = 0
66+
offsetX.value = centerX
67+
offsetY.value = 75
6368
})
6469
</script>
6570

6671
<template>
67-
<div class="relative overflow-hidden rounded-l n-border-base border-r preview flex items-center justify-center">
72+
<div ref="previewRef" class="relative overflow-hidden rounded-l n-border-base border-r preview flex items-center justify-center">
6873
<div v-if="!isImage" class="rounded flex flex-col justify-center border select-none pointer-events-none n-border-base w-[150px] h-[150px] n-bg-base object-scale-down">
6974
<div class="truncate w-full text-center">
7075
{{ previewState?.stats?.name }}
@@ -92,13 +97,13 @@ watch(mode, () => {
9297
class="prevent-drag block object-scale-down w-full max-w-full max-h-full"
9398
tabindex="0"
9499
>
95-
<div class="absolute left-4 right-4 top-4 flex justify-between gap-2">
100+
<div class="absolute actions w-full px-4 top-4 flex justify-between gap-2">
96101
<NButton
97102
to="/"
98-
icon="carbon:arrow-left"
99103
class="n-bg-base"
100104
>
101-
<span>Back</span>
105+
<NIcon icon="carbon:arrow-left" />
106+
<span class="hide-small ml-1">Back <kbd class="text-xs">esc</kbd></span>
102107
</NButton>
103108
<div>
104109
<NButton
@@ -119,7 +124,7 @@ watch(mode, () => {
119124
:disabled="!isImage"
120125
@click="mode = 'real'"
121126
>
122-
Real-size preview
127+
Snippet preview
123128
</NButton>
124129
</div>
125130

@@ -128,7 +133,8 @@ watch(mode, () => {
128133
target="_blank"
129134
class="n-bg-base"
130135
>
131-
Open in new tab
136+
<span class="hide-small mr-1">Open</span>
137+
<NIcon icon="carbon:image-reference" />
132138
</NButton>
133139
</div>
134140
</div>
@@ -150,4 +156,23 @@ watch(mode, () => {
150156
-o-user-drag: none;
151157
user-drag: none;
152158
}
159+
160+
.actions {
161+
container-type: inline-size;
162+
container-name: actions;
163+
}
164+
.hide-small {
165+
display: initial;
166+
}
167+
.only-small {
168+
display: none;
169+
}
170+
@container actions (max-width: 600px) {
171+
.hide-small {
172+
display: none;
173+
}
174+
.only-small {
175+
display: initial;
176+
}
177+
}
153178
</style>

client/components/NIconTitle.vue

Lines changed: 0 additions & 15 deletions
This file was deleted.

client/components/NSectionBlock.vue

Lines changed: 0 additions & 73 deletions
This file was deleted.

client/components/NSelect.vue

Lines changed: 0 additions & 36 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"release:publish": "git push --follow-tags origin main && npm publish"
2929
},
3030
"dependencies": {
31-
"@nuxt/devtools-ui-kit": "^0.2.3",
31+
"@nuxt/devtools-ui-kit": "npm:@nuxt/devtools-ui-kit-edge",
3232
"@vueuse/core": "^9.2.0",
3333
"@vueuse/nuxt": "^9.2.0",
3434
"consola": "^2.15.3",

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)