Skip to content

Commit 67e7c70

Browse files
susnuxbackportbot[bot]
authored andcommitted
fix(unifiedsearch): Simplify and correct thumbnail styles
Ensure that the if a preview is available the maximum sizes are respected (clickable area). Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 7b3daaf commit 67e7c70

File tree

1 file changed

+48
-61
lines changed

1 file changed

+48
-61
lines changed

core/src/components/UnifiedSearch/SearchResult.vue

Lines changed: 48 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
- SPDX-License-Identifier: AGPL-3.0-or-later
44
-->
55
<template>
6-
<NcListItem class="result-items__item"
6+
<NcListItem class="result-item"
77
:name="title"
88
:bold="false"
99
:href="resourceUrl"
1010
target="_self">
1111
<template #icon>
1212
<div aria-hidden="true"
13-
class="result-items__item-icon"
13+
class="result-item__icon"
1414
:class="{
15-
'result-items__item-icon--rounded': rounded,
16-
'result-items__item-icon--no-preview': !isValidIconOrPreviewUrl(thumbnailUrl),
17-
'result-items__item-icon--with-thumbnail': isValidIconOrPreviewUrl(thumbnailUrl),
15+
'result-item__icon--rounded': rounded,
16+
'result-item__icon--no-preview': !isValidIconOrPreviewUrl(thumbnailUrl),
17+
'result-item__icon--with-thumbnail': isValidIconOrPreviewUrl(thumbnailUrl),
1818
[icon]: !isValidIconOrPreviewUrl(icon),
1919
}"
2020
:style="{
@@ -101,72 +101,59 @@ export default {
101101
</script>
102102

103103
<style lang="scss" scoped>
104-
@use "sass:math";
105-
$clickable-area: 44px;
106-
$margin: 10px;
107-
108-
.result-items {
109-
&__item:deep {
110-
111-
a {
112-
border: 2px solid transparent;
113-
border-radius: var(--border-radius-large) !important;
114-
115-
&--focused {
116-
background-color: var(--color-background-hover);
117-
}
118-
119-
&:active,
120-
&:hover,
121-
&:focus {
122-
background-color: var(--color-background-hover);
123-
border: 2px solid var(--color-border-maxcontrast);
124-
}
104+
.result-item {
105+
:deep(a) {
106+
border: 2px solid transparent;
107+
border-radius: var(--border-radius-large) !important;
108+
109+
&:active,
110+
&:hover,
111+
&:focus {
112+
background-color: var(--color-background-hover);
113+
border: 2px solid var(--color-border-maxcontrast);
114+
}
125115
126-
* {
127-
cursor: pointer;
128-
}
116+
* {
117+
cursor: pointer;
118+
}
119+
}
129120
121+
&__icon {
122+
overflow: hidden;
123+
width: var(--default-clickable-area);
124+
height: var(--default-clickable-area);
125+
border-radius: var(--border-radius);
126+
background-repeat: no-repeat;
127+
background-position: center center;
128+
background-size: 32px;
129+
130+
&--rounded {
131+
border-radius: calc(var(--default-clickable-area) / 2);
130132
}
131133
132-
&-icon {
133-
overflow: hidden;
134-
width: $clickable-area;
135-
height: $clickable-area;
136-
border-radius: var(--border-radius);
137-
background-repeat: no-repeat;
138-
background-position: center center;
134+
&--no-preview {
139135
background-size: 32px;
136+
}
140137
141-
&--rounded {
142-
border-radius: math.div($clickable-area, 2);
143-
}
144-
145-
&--no-preview {
146-
background-size: 32px;
147-
}
148-
149-
&--with-thumbnail {
150-
background-size: cover;
151-
}
138+
&--with-thumbnail {
139+
background-size: cover;
140+
}
152141
153-
&--with-thumbnail:not(&--rounded) {
154-
// compensate for border
155-
max-width: $clickable-area - 2px;
156-
max-height: $clickable-area - 2px;
157-
border: 1px solid var(--color-border);
158-
}
142+
&--with-thumbnail:not(#{&}--rounded) {
143+
border: 1px solid var(--color-border);
144+
// compensate for border
145+
max-height: calc(var(--default-clickable-area) - 2px);
146+
max-width: calc(var(--default-clickable-area) - 2px);
147+
}
159148
160-
img {
161-
// Make sure to keep ratio
162-
width: 100%;
163-
height: 100%;
149+
img {
150+
// Make sure to keep ratio
151+
width: 100%;
152+
height: 100%;
164153
165-
object-fit: cover;
166-
object-position: center;
167-
}
154+
object-fit: cover;
155+
object-position: center;
168156
}
169-
170157
}
171158
}
172159
</style>

0 commit comments

Comments
 (0)