Skip to content

Commit da28d11

Browse files
committed
dumili: Improve calculation and display of story search result images
1 parent 01fad24 commit da28d11

File tree

5 files changed

+51
-21
lines changed

5 files changed

+51
-21
lines changed

apps/dumili/.eslintrc-auto-import.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"ComputedRef": true,
1616
"Condition": true,
1717
"CopyStateWithUndefined": true,
18-
"CoverSearchResults": true,
1918
"DirectiveBinding": true,
2019
"EdgeWithStringCreationDate": true,
2120
"EditSubscription": true,
@@ -145,6 +144,7 @@
145144
"useDmSocket": true,
146145
"useI18n": true,
147146
"useId": true,
147+
"useLayout": true,
148148
"useLink": true,
149149
"useMedal": true,
150150
"useModel": true,

apps/dumili/src/components/EntryStoryKindTooltip.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
})) || []
3939
"
4040
><template #empty>{{ $t("Aucune case détectée") }}</template>
41-
<template #cell(storyKindRows)="row">
41+
<template #cell(kind)="row">
4242
<story-kind-badge
4343
:kind="row.item.storyKindRows?.kind" /></template></b-table
4444
><br />

apps/dumili/src/components/suggestions/StorySuggestionList.vue

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
>
1111
<template #default="{ suggestion, location }">
1212
<b-row class="w-100" style="height: 100px">
13-
<b-col cols="6" class="d-flex justify-content-center">
14-
<b-img
15-
v-if="storyUrls[suggestion.storycode]"
16-
class="w-75"
17-
:src="
18-
inducksCoverRoot.replace('f_auto', 'c_crop,h_0.5,x_0,w_1') +
19-
storyUrls[suggestion.storycode]
20-
"
21-
/></b-col>
13+
<b-col
14+
cols="6"
15+
class="d-flex justify-content-center story-first-page"
16+
:style="{
17+
backgroundImage: `url(${inducksCoverRoot.replace('f_auto', 'c_crop,h_0.5,x_0,w_1') + storyUrls[suggestion.storycode]})`,
18+
}"
19+
@mousemove="handleImageMouseMove"
20+
@mouseleave="handleImageLeave"
21+
>
22+
</b-col>
2223
<b-col
2324
cols="6"
2425
class="d-flex flex-column justify-content-center text-wrap"
@@ -183,10 +184,37 @@ const acceptStory = async (storycode: storySuggestion["storycode"] | null) => {
183184
}
184185
};
185186
187+
const handleImageMouseMove = (event: MouseEvent) => {
188+
const target = event.currentTarget as HTMLElement;
189+
const rect = target.getBoundingClientRect();
190+
const mouseY = event.clientY - rect.top;
191+
const elementHeight = rect.height;
192+
193+
// Calculate percentage from top (0 = top, 1 = bottom)
194+
const percentage = Math.max(0, Math.min(1, mouseY / elementHeight));
195+
196+
// Convert percentage to background position (0% = top, 100% = bottom)
197+
const backgroundPosition = `center ${percentage * 100}%`;
198+
target.style.backgroundPosition = backgroundPosition;
199+
};
200+
201+
const handleImageLeave = (event: Event) => {
202+
const target = event.target as HTMLElement;
203+
target.style.backgroundPosition = "top center";
204+
};
205+
186206
watch(
187207
() => entry.value.acceptedStory?.storycode || null,
188208
(storycode) => {
189209
acceptStory(storycode);
190210
},
191211
);
192-
</script>
212+
</script>
213+
214+
<style scoped lang="scss">
215+
.story-first-page {
216+
background-size: cover;
217+
background-repeat: no-repeat;
218+
background-position: top center;
219+
}
220+
</style>

apps/web/src/components/menus/BookcaseMenu.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<script setup lang="ts">
66
const { t: $t } = useI18n();
77
const items = [
8-
{ route: "/bookcase/show/[[username]]", text: $t("Ma bibliothèque") },
8+
{ route: "/bookcase/show/[username]", text: $t("Ma bibliothèque") },
99
{ route: "/bookcase/options", text: $t("Options de la bibliothèque") },
1010
{ route: "/bookcase/contributors", text: $t("Contributeurs") },
1111
] as const;

packages/api/services/coa/stories/index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ export default {
1919
},
2020
}),
2121
prismaCoa.$queryRaw<{ storycode: string; url: string }[]>`
22-
select s.storycode, CONCAT('webusers/webusers/', url) AS url
23-
from inducks_story s
24-
inner join coa.inducks_storyversion sv on s.originalstoryversioncode = sv.storyversioncode
25-
inner join coa.inducks_entry e using (storyversioncode)
26-
inner join coa.inducks_entryurl eu using (entrycode)
27-
where s.storycode IN (${Prisma.join(storycodes)})
28-
and eu.sitecode = 'webusers'
29-
group by s.storycode`,
22+
SELECT s.storycode,
23+
MIN(CONCAT('webusers/webusers/', eu.url)) AS url
24+
FROM inducks_story s
25+
INNER JOIN coa.inducks_storyversion sv ON s.storycode = sv.storycode
26+
INNER JOIN coa.inducks_entry e USING (storyversioncode)
27+
INNER JOIN coa.inducks_entryurl eu USING (entrycode)
28+
WHERE sv.storycode = s.storycode
29+
AND s.storycode IN (${Prisma.join(storycodes)})
30+
AND eu.sitecode = 'webusers'
31+
GROUP BY s.storycode`,
3032
])
3133
.then(([stories, storyUrls]) => ({
3234
stories: stories.groupBy("storycode"),

0 commit comments

Comments
 (0)