Skip to content

Commit b1684ce

Browse files
moodyjmzclaude
andcommitted
fix(overview): uniform template card sizing, preview fallback, and mimeFallback param
Replace the ratio-based padding-bottom trick in TemplateSection with a fixed 2/3 aspect-ratio so all categories (docs, sheets, presentations) render at the same height. Switch .template-card__preview to flex centering, removing the now-redundant absolute-position rule on the blank card icon. Add an @error handler that sets failedPreviews[fileid] so a broken image falls back to the file-type icon without a broken-image glitch. Use template.previewUrl when the API provides it, otherwise derive the URL from the fileid. In OfficeOverview, fix the preview URL to use mimeFallback=true (boolean string) instead of mimeFallback=1, and update the loadState key to match the renamed initial state ('overview_config'). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
1 parent 0925d33 commit b1684ce

2 files changed

Lines changed: 16 additions & 21 deletions

File tree

src/components/TemplateSection.vue

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
<!-- Blank file card -->
1313
<li class="template-section__item">
1414
<button class="template-card" @click="$emit('select', creator, null)">
15-
<span class="template-card__preview template-card__preview--blank"
16-
:style="previewStyle">
15+
<span class="template-card__preview template-card__preview--blank">
1716
<!-- eslint-disable-next-line vue/no-v-html -->
1817
<span class="template-card__icon" v-html="creator.iconSvgInline" />
1918
</span>
@@ -26,12 +25,14 @@
2625
:key="template.fileid"
2726
class="template-section__item">
2827
<button class="template-card" @click="$emit('select', creator, template)">
29-
<span class="template-card__preview" :style="previewStyle">
30-
<img v-if="template.hasPreview"
28+
<span class="template-card__preview">
29+
<img v-if="template.hasPreview && !failedPreviews[template.fileid]"
3130
:src="templatePreviewUrl(template)"
3231
:alt="nameWithoutExt(template.basename)"
3332
loading="lazy"
34-
class="template-card__image">
33+
class="template-card__image"
34+
@error="failedPreviews = { ...failedPreviews, [template.fileid]: true }">
35+
<!-- eslint-disable-next-line vue/no-v-html -->
3536
<span v-else class="template-card__icon" v-html="creator.iconSvgInline" />
3637
</span>
3738
<span class="template-card__name">{{ nameWithoutExt(template.basename) }}</span>
@@ -56,13 +57,10 @@ export default {
5657
5758
emits: ['select'],
5859
59-
computed: {
60-
previewStyle() {
61-
if (!this.creator.ratio) {
62-
return {}
63-
}
64-
return { paddingBottom: `${(1 / this.creator.ratio) * 100}%` }
65-
},
60+
data() {
61+
return {
62+
failedPreviews: {},
63+
}
6664
},
6765
6866
methods: {
@@ -130,18 +128,15 @@ export default {
130128
.template-card__preview {
131129
position: relative;
132130
width: 100%;
131+
aspect-ratio: 2 / 3;
133132
overflow: hidden;
134133
border: 2px solid var(--color-border);
135134
border-radius: var(--border-radius-large);
136135
background-color: var(--color-main-background);
137136
box-sizing: border-box;
138-
}
139-
140-
.template-card__preview--blank .template-card__icon {
141-
position: absolute;
142-
top: 50%;
143-
left: 50%;
144-
transform: translate(-50%, -50%);
137+
display: flex;
138+
align-items: center;
139+
justify-content: center;
145140
}
146141
147142
.template-card__image {

src/views/OfficeOverview.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default {
180180
loading: false,
181181
error: null,
182182
previewEnabled: loadState('richdocuments', 'previewEnabled', false),
183-
viewMode: loadState('richdocuments', 'config', {}).overview_grid_view ? 'grid' : 'list',
183+
viewMode: loadState('richdocuments', 'overview_config', {}).overview_grid_view ? 'grid' : 'list',
184184
searchQuery: '',
185185
showCreateDialog: false,
186186
newFileName: '',
@@ -237,7 +237,7 @@ export default {
237237
238238
getPreviewUrl(file) {
239239
const etag = (file.attributes?.etag || '').slice(0, 6)
240-
return generateUrl('/core/preview?fileId={fileid}&x={x}&y={y}&v={v}&a=1&mimeFallback=1', {
240+
return generateUrl('/core/preview?fileId={fileid}&x={x}&y={y}&v={v}&a=1&mimeFallback=true', {
241241
fileid: file.fileid,
242242
x: 300,
243243
y: 300,

0 commit comments

Comments
 (0)