Skip to content

Commit 9fcbdde

Browse files
committed
fix: cropper style
1 parent f6c229d commit 9fcbdde

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

src/components/Vendor/Cropper/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createAsyncComponent } from '@/utils/factory/asyncComponent'
33
export default createAsyncComponent(() => import('./index.vue'))
44

55
export interface WCropperInst {
6+
onRefresh: () => void
67
onGetCropperBlob: () => Promise<Blob>
78
}
89

src/components/Vendor/Cropper/index.vue

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,16 @@ const buttons = [
164164
165165
defineExpose({
166166
onGetCropperBlob: () => blobRef.value ?? absImageRef.value?.onGetBlob(),
167+
onRefresh: onReset,
167168
})
168169
</script>
169170

170171
<template>
171172
<!-- eslint-disable vue/component-name-in-template-casing -->
172-
<n-grid :x-gap="20" :cols="24">
173-
<n-gi :span="16">
174-
<cropper-canvas background :disabled="disabled" style="width: 100%; height: 400px">
173+
<div class="h-full w-full flex items-start justify-center gap-4 p-4">
174+
<!-- main -->
175+
<div class="h-[60vh] max-h-[700px] max-w-[900px] w-[60vw] flex flex-shrink-0 items-center justify-center bg-black">
176+
<cropper-canvas background :disabled="disabled" class="h-full w-full">
175177
<cropper-image
176178
v-if="src"
177179
ref="cropperImageRef"
@@ -183,12 +185,9 @@ defineExpose({
183185
:translatable="src"
184186
cross-origin="anonymous"
185187
/>
186-
187188
<cropper-shade hidden />
188-
189189
<cropper-handle action="select" plain />
190190
<cropper-handle action="move" plain />
191-
192191
<cropper-selection
193192
:id="selectionId"
194193
ref="cropperSelectionRef"
@@ -202,7 +201,6 @@ defineExpose({
202201
>
203202
<cropper-grid role="grid" bordered covered />
204203
<cropper-crosshair centered />
205-
206204
<cropper-handle action="move" theme-color="rgba(255, 255, 255, 0.35)" />
207205
<cropper-handle action="n-resize" />
208206
<cropper-handle action="e-resize" />
@@ -214,29 +212,39 @@ defineExpose({
214212
<cropper-handle action="sw-resize" />
215213
</cropper-selection>
216214
</cropper-canvas>
217-
</n-gi>
218-
219-
<n-gi :span="8" class="vstack">
220-
<WScrollbar height="360px">
221-
<n-space vertical size="large">
222-
<cropper-viewer class="border-1 border-bodyColor" :selection="`#${selectionId}`" style="height: 200px" />
223-
224-
<n-grid :x-gap="10" :cols="24">
225-
<n-gi :span="12">
226-
<cropper-viewer class="border-1 border-bodyColor" :selection="`#${selectionId}`" style="height: 80px" />
227-
</n-gi>
228-
229-
<n-gi :span="8">
230-
<cropper-viewer class="border-1 border-bodyColor" :selection="`#${selectionId}`" style="height: 60px" />
231-
</n-gi>
232-
233-
<n-gi :span="4">
234-
<cropper-viewer class="border-1 border-light-50" :selection="`#${selectionId}`" style="height: 40px" />
235-
</n-gi>
236-
</n-grid>
237-
</n-space>
238-
</WScrollbar>
215+
</div>
216+
217+
<!-- right -->
218+
<div class="max-w-[400px] w-[25vw] flex flex-shrink-0 flex-col gap-4">
219+
<!-- main thumbnail -->
220+
<cropper-viewer
221+
class="h-[25vh] max-h-[200px] w-full border border-bodyColor"
222+
:selection="`#${selectionId}`"
223+
/>
224+
225+
<!-- grid thumbnail -->
226+
<div class="grid grid-cols-24 gap-x-2.5">
227+
<div class="col-span-12">
228+
<cropper-viewer
229+
class="h-[80px] w-full border border-bodyColor"
230+
:selection="`#${selectionId}`"
231+
/>
232+
</div>
233+
<div class="col-span-8">
234+
<cropper-viewer
235+
class="h-[60px] w-full border border-bodyColor"
236+
:selection="`#${selectionId}`"
237+
/>
238+
</div>
239+
<div class="col-span-4">
240+
<cropper-viewer
241+
class="h-[40px] w-full border border-light-50"
242+
:selection="`#${selectionId}`"
243+
/>
244+
</div>
245+
</div>
239246

247+
<!-- button area -->
240248
<n-space>
241249
<WAbsImage ref="absImageRef" @change="onUploadChange">
242250
<WIconButton
@@ -256,6 +264,6 @@ defineExpose({
256264
:tooltip-msg="item.helpMessage"
257265
/>
258266
</n-space>
259-
</n-gi>
260-
</n-grid>
267+
</div>
268+
</div>
261269
</template>

0 commit comments

Comments
 (0)