Skip to content

Commit ac01921

Browse files
committed
fix(responsive): handle compact screen sizes
1 parent 546d8f1 commit ac01921

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

src/components/common/list/ListItem.vue

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ const props = defineProps({
6262
type: Boolean,
6363
required: false,
6464
},
65+
hidePoster: {
66+
type: Boolean,
67+
required: false,
68+
},
6569
contentHeight: {
6670
type: Number,
6771
required: false,
@@ -215,6 +219,7 @@ const onClick = () => emit('onItemClick', { item: item?.value });
215219
</slot>
216220
<NFlex v-else class="tile" :wrap="false">
217221
<PosterComponent
222+
v-if="!hidePoster"
218223
:item="item as PosterItem"
219224
:poster="poster"
220225
:backdrop="backdrop"

src/components/common/list/ListScroll.vue

+19-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
type VirtualListProps,
1616
type VirtualListRef,
1717
} from '~/models/list-scroll.model';
18+
import { watchMedia } from '~/utils/window.utils';
1819
1920
const listRef = ref<VirtualListRef>();
2021
@@ -43,6 +44,10 @@ const props = defineProps({
4344
type: Boolean,
4445
required: false,
4546
},
47+
hidePoster: {
48+
type: Boolean,
49+
required: false,
50+
},
4651
hideDate: {
4752
type: Boolean,
4853
required: false,
@@ -105,7 +110,8 @@ defineExpose({
105110
list: listRef,
106111
});
107112
108-
const { items, loading, pagination, scrollThreshold, listOptions } = toRefs(props);
113+
const { items, loading, pagination, scrollThreshold, listOptions, backdrop, hidePoster } =
114+
toRefs(props);
109115
110116
const scrolled = ref(false);
111117
@@ -143,7 +149,8 @@ const onLoadMore = (payload: { page: number; pageCount: number; pageSize: number
143149
};
144150
145151
const isEmpty = computed(() => !items.value.length && !loading.value);
146-
const listItemSize = computed(() => listOptions?.value?.itemSize ?? 145);
152+
const defaultSize = computed(() => (hidePoster.value ? 130 : 145));
153+
const listItemSize = computed(() => listOptions?.value?.itemSize ?? defaultSize.value);
147154
148155
const topInset = computed(() => {
149156
const listElementRef = listRef.value?.$el;
@@ -158,6 +165,12 @@ const listPaddingTop = computed(
158165
() => topInset.value + (listOptions?.value?.paddingTop ?? 60),
159166
);
160167
const listPaddingBottom = computed(() => listOptions?.value?.paddingBottom ?? 32);
168+
169+
const isCompact = watchMedia('(max-width: 600px)');
170+
const showBackdrop = computed(() => backdrop?.value && !isCompact.value);
171+
172+
const isTiny = watchMedia('(max-width: 350px)');
173+
const showPoster = computed(() => !hidePoster?.value && !isTiny.value);
161174
</script>
162175

163176
<template>
@@ -192,7 +205,7 @@ const listPaddingBottom = computed(() => listOptions?.value?.paddingBottom ?? 32
192205
vertical
193206
size="small"
194207
:theme-overrides="{ gapSmall: '0' }"
195-
:style="`height: ${listOptions?.itemSize ?? 145}px;`"
208+
:style="`height: ${listOptions?.itemSize ?? defaultSize}px;`"
196209
>
197210
<ListLoadMore
198211
:page="pagination?.page"
@@ -206,12 +219,13 @@ const listPaddingBottom = computed(() => listOptions?.value?.paddingBottom ?? 32
206219
v-else
207220
:key="item.id"
208221
:item="item"
209-
:height="listOptions?.itemSize ?? 145"
222+
:height="listOptions?.itemSize ?? defaultSize"
210223
:size="items.length"
211224
:hide-date="hideDate"
212225
:hide-time="hideTime"
226+
:hide-poster="!showPoster"
227+
:backdrop="showBackdrop"
213228
:content-height="contentHeight"
214-
:backdrop="backdrop"
215229
:hover="hoverDate === item.date?.current?.toDateString()"
216230
:scroll-into-view="scrollIntoView?.includes(item.id)"
217231
:show-progress="showProgress"

src/components/views/settings/SettingsComponent.vue

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import PageLoading from '~/components/common/loading/PageLoading.vue';
99
import { useSimklStoreRefs } from '~/stores/data/simkl.store';
1010
import { useI18n } from '~/utils/i18n.utils';
1111
import lazyComponent from '~/utils/lazy.utils';
12+
import { watchMedia } from '~/utils/window.utils';
1213
1314
const SettingsAccount = lazyComponent(
1415
() => import('~/components/views/settings/SettingsAccount.vue'),
@@ -99,6 +100,8 @@ const onLeave = (section: Section) => {
99100
}
100101
};
101102
103+
const isCompact = watchMedia('(max-width: 600px)');
104+
102105
onDeactivated(() => {
103106
target.value = undefined;
104107
focus.value = undefined;
@@ -116,6 +119,7 @@ onDeactivated(() => {
116119
:native-scrollbar="false"
117120
show-trigger="bar"
118121
inverted
122+
:default-collapsed="isCompact"
119123
>
120124
<NAnchor :show-rail="false" type="block">
121125
<NAnchorLink

0 commit comments

Comments
 (0)