Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# CHANGELOG.md

## unrelease
## unreleased
- add support for postgres range types
- Added an `image_height` property to the card component so top images can be capped without stretching or upscaling.


## v0.39.1 (2025-11-08)
- More precise server timing tracking to debug performance issues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
This is useful if you want to display a lot of text in the card, with many options for formatting, such as
line breaks, **bold**, *italics*, lists, #titles, [links](target.sql), ![images](photo.jpg), etc.', 'TEXT', FALSE, TRUE),
('top_image', 'The URL (absolute or relative) of an image to display at the top of the card.', 'URL', FALSE, TRUE),
('image_height', 'Maximum height in pixels for the top image. The image will scale down to fit this height without distorting or upscaling.', 'INTEGER', FALSE, TRUE),
('footer', 'Muted text to display at the bottom of the card.', 'TEXT', FALSE, TRUE),
('footer_md', 'Muted text to display at the bottom of the card, with rich text formatting in Markdown format.', 'TEXT', FALSE, TRUE),
('link', 'An URL to which the user should be taken when they click on the card.', 'URL', FALSE, TRUE),
Expand Down Expand Up @@ -58,9 +59,9 @@ INSERT INTO example(component, description, properties) VALUES
('card', 'A gallery of images.',
json('[
{"component":"card", "title":"My favorite animals in pictures", "columns": 3},
{"title": "Lynx", "description_md": "The **lynx** is a medium-sized **wild cat** native to Northern, Central and Eastern Europe to Central Asia and Siberia, the Tibetan Plateau and the Himalayas.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Lynx_lynx-4.JPG/640px-Lynx_lynx-4.JPG", "icon":"star" },
{"title": "Squirrel", "description_md": "The **chipmunk** is a small, striped rodent of the family Sciuridae. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Tamias-rufus-001.jpg/640px-Tamias-rufus-001.jpg" },
{"title": "Spider", "description_md": "The **jumping spider family** (_Salticidae_) contains more than 600 described genera and about *6000 described species*, making it the largest family of spiders with about 13% of all species.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/Jumping_spiders_%28Salticidae%29.jpg/640px-Jumping_spiders_%28Salticidae%29.jpg" }
{"title": "Lynx", "description_md": "The **lynx** is a medium-sized **wild cat** native to Northern, Central and Eastern Europe to Central Asia and Siberia, the Tibetan Plateau and the Himalayas.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Lynx_lynx-4.JPG/640px-Lynx_lynx-4.JPG", "image_height": 220, "icon":"star" },
{"title": "Squirrel", "description_md": "The **chipmunk** is a small, striped rodent of the family Sciuridae. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Tamias-rufus-001.jpg/640px-Tamias-rufus-001.jpg", "image_height": 220 },
{"title": "Spider", "description_md": "The **jumping spider family** (_Salticidae_) contains more than 600 described genera and about *6000 described species*, making it the largest family of spiders with about 13% of all species.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/Jumping_spiders_%28Salticidae%29.jpg/640px-Jumping_spiders_%28Salticidae%29.jpg", "image_height": 220 }
]')),
('card', 'Beautifully colored cards with variable width. The blue card (width 6) takes half the screen, whereas of the red and green cards have the default width of 3',
json('[
Expand Down
11 changes: 11 additions & 0 deletions sqlpage/sqlpage.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ td > p {
margin-bottom: 0 !important;
}

.card-img-top-constrained {
width: auto;
max-width: 100%;
height: auto;
max-height: var(--sqlpage-card-image-height, none);
display: block;
margin-left: auto;
margin-right: auto;
object-fit: scale-down;
}

.text-secondary a {
color: inherit;
text-decoration: underline;
Expand Down
4 changes: 3 additions & 1 deletion sqlpage/templates/card.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
<a href="{{link}}" style="text-decoration: inherit; color: inherit">
{{/if}}
{{#if top_image}}
<img src="{{top_image}}" class="card-img-top" />
<img src="{{top_image}}"
class="card-img-top{{#if image_height}} mw-100 w-auto h-auto mx-auto{{/if}}"
{{#if image_height}}style="max-height: {{image_height}}px;"{{/if}} />
{{/if}}
{{#if color}}
{{#if (not embed)}}
Expand Down