Skip to content

Commit 35ede2b

Browse files
committed
Improvements for table & PreviewImages component
1 parent f5a7017 commit 35ede2b

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

web/src/components/PreviewImages.astro

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ import { marked } from "marked";
55
66
interface Props {
77
images?: any[];
8+
displayImageOnly?: boolean;
89
}
910
10-
const { images } = Astro.props;
11+
const { images, displayImageOnly } = Astro.props;
1112
const maxDimension = 256; // max size of preview image (256x256)
1213
1314
if (images?.length) {
1415
await Promise.all(
1516
images.map(async (imageInfo) => {
1617
const { default: resolvedPath } = await getAssetImagePath(imageInfo.path);
1718
const { width: originalWidth, height: originalHeight, src } = resolvedPath;
19+
const customMax = imageInfo.maxDimension ?? maxDimension;
1820
19-
const scale = Math.min(maxDimension / originalWidth, maxDimension / originalHeight, 1);
21+
const scale = Math.min(customMax / originalWidth, customMax / originalHeight, 1);
2022
2123
Object.assign(imageInfo, {
2224
resolvedPath,
@@ -31,9 +33,11 @@ if (images?.length) {
3133

3234
{images && images.length > 0 && (
3335
<div data-pagefind-ignore id="preview-images-gallery">
34-
<h4>Gallery</h4>
35-
<p>Click on the image to view the full preview along with the description.</p>
36-
36+
{!displayImageOnly && (
37+
<h4>Gallery</h4>
38+
<p>Click on the image to view the full preview along with the description.</p>
39+
)}
40+
3741
<div class="preview-images">
3842
{images.map(({ src, description, resolvedPath, width, height }) => (
3943
<a href={src} class="glightbox" data-description={description ? marked(description) : ""} data-gallery="gallery">

web/src/styles/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ td {
294294
background-color: var(--sl-color-bg-inline-code);
295295
}
296296

297+
tr:nth-child(even) td {
298+
background-color: rgba(255, 255, 255, 0.05);
299+
}
300+
297301
.sl-heading-wrapper {
298302
margin-top: 0.5em;
299303
margin-bottom: 0.5em;

0 commit comments

Comments
 (0)