Skip to content

Commit

Permalink
Default search result images to contain rather than cover
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed Jul 4, 2022
1 parent 7a313e4 commit 5f30598
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions docs/content/docs/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ The Pagefind UI is styled using CSS custom properties which can be overridden. T
--pagefind-ui-tag: #eeeeee;
--pagefind-ui-border-width: 2px;
--pagefind-ui-border-radius: 8px;
--pagefind-ui-image-size: cover;
--pagefind-ui-image-ratio: 3 / 2;
----pagefind-ui-image-border-radius: 8px;
--pagefind-ui-image-box-ratio: 3 / 2;
--pagefind-ui-font: sans-serif;
```

Expand Down
29 changes: 11 additions & 18 deletions pagefind_ui/svelte/result.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
{/if}
</div>
{:else}
<div class="pagefind-ui__result-thumb" />
<div class="pagefind-ui__result-thumb pagefind-ui__loading" />
<div class="pagefind-ui__result-inner">
<p class="pagefind-ui__result-title pagefind-ui__loading">
{placeholder(30)}
Expand Down Expand Up @@ -83,28 +83,20 @@
);
max-width: calc(120px * var(--pagefind-ui-scale));
margin-top: calc(10px * var(--pagefind-ui-scale));
aspect-ratio: var(--pagefind-ui-image-ratio);
aspect-ratio: var(--pagefind-ui-image-box-ratio);
position: relative;
border-radius: var(--pagefind-ui-border-radius);
overflow: hidden;
}
.pagefind-ui__result-thumb::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: var(--pagefind-ui-text);
opacity: 0.1;
}
.pagefind-ui__result-image {
display: block;
position: absolute;
left: 50%;
transform: translateX(-50%);
font-size: 0;
width: 100%;
height: 100%;
aspect-ratio: var(--pagefind-ui-image-ratio);
object-fit: var(--pagefind-ui-image-size);
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
border-radius: var(--pagefind-ui-image-border-radius);
}
.pagefind-ui__result-inner {
flex: 1;
Expand Down Expand Up @@ -138,6 +130,7 @@
.pagefind-ui__loading {
color: var(--pagefind-ui-text);
background-color: var(--pagefind-ui-text);
border-radius: var(--pagefind-ui-border-radius);
opacity: 0.1;
pointer-events: none;
}
Expand Down
4 changes: 2 additions & 2 deletions pagefind_ui/svelte/ui.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@
--pagefind-ui-tag: #eeeeee;
--pagefind-ui-border-width: 2px;
--pagefind-ui-border-radius: 8px;
--pagefind-ui-image-size: cover;
--pagefind-ui-image-ratio: 3 / 2;
--pagefind-ui-image-border-radius: 8px;
--pagefind-ui-image-box-ratio: 3 / 2;
--pagefind-ui-font: system, -apple-system, ".SFNSText-Regular",
"San Francisco", "Roboto", "Segoe UI", "Helvetica Neue",
"Lucida Grande", sans-serif;
Expand Down

0 comments on commit 5f30598

Please sign in to comment.