Skip to content

Commit 8ee39f8

Browse files
authored
Merge pull request #3 from devforth/preview-width
feat: add minWidth, minListWidth, and minShowWidth options for previe…
2 parents 2f24dc3 + f7afcdd commit 8ee39f8

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

Diff for: custom/preview.vue

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
v-if="contentType && contentType.startsWith('image')"
66
:src="url"
77
class="rounded-md"
8-
:style="maxWidth"
8+
:style="[maxWidth, minWidth]"
99
ref="img"
1010
data-zoomable
1111
@click.stop="zoom.open()"
@@ -51,12 +51,12 @@
5151
</style>
5252

5353
<style scoped>
54-
img {
54+
/* img {
5555
min-width: 150px;
5656
}
5757
video {
5858
min-width: 200px;
59-
}
59+
} */
6060
</style>
6161
<script setup>
6262
import { ref, computed , onMounted, watch} from 'vue'
@@ -86,6 +86,14 @@ const maxWidth = computed(() => {
8686
return width ? { maxWidth: width } : {};
8787
});
8888
89+
const minWidth = computed(() => {
90+
const isShowPage = route.path.includes('/show/');
91+
const width = isShowPage
92+
? (props.meta.minShowWidth || props.meta.minWidth)
93+
: (props.meta.minListWidth || props.meta.minWidth);
94+
95+
return width ? { minWidth: width } : {};
96+
});
8997
// since we have no way to know the content type of the file, we will try to guess it from extension
9098
// for better experience probably we should check whether user saves content type in the database and use it here
9199
const contentType = computed(() => {

Diff for: index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
129129
maxWidth: this.options.preview?.maxWidth,
130130
maxListWidth: this.options.preview?.maxListWidth,
131131
maxShowWidth: this.options.preview?.maxShowWidth,
132+
minWidth: this.options.preview?.minWidth,
133+
minListWidth: this.options.preview?.minListWidth,
134+
minShowWidth: this.options.preview?.minShowWidth,
132135
};
133136
// define components which will be imported from other components
134137
this.componentPath('imageGenerator.vue');

Diff for: types.ts

+16
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ export type PluginOptions = {
7878
* Maximum width of the preview image in show view
7979
*/
8080
maxShowWidth?: string,
81+
82+
83+
/**
84+
* Minimum width of the preview image
85+
*/
86+
minWidth?: string,
87+
88+
/**
89+
* Minimum width of the preview image in list view
90+
*/
91+
minListWidth?: string,
92+
93+
/**
94+
* Minimum width of the preview image in show view
95+
*/
96+
minShowWidth?: string,
8197

8298
/**
8399
* Used to display preview (if it is image) in list and show views.

0 commit comments

Comments
 (0)