Skip to content

Commit ac969f6

Browse files
cursoragentlovasoa
andcommitted
Add image_height to card component
Co-authored-by: contact <contact@ophir.dev>
1 parent d8e6a28 commit ac969f6

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

CHANGELOG.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# CHANGELOG.md
22

3-
## v0.39.1 (2025-11-08)
4-
- More precise server timing tracking to debug performance issues
5-
- Fix missing server timing header in some cases
6-
- Implement nice error messages for some header-related errors such as invalid header values.
7-
- `compress_responses` is now set to `false` by default in the configuration.
8-
- When response compression is enabled, additional buffering is needed. Users reported a better experience with pages that load more progressively, reducing the time before the pages' shell is rendered.
9-
- When SQLPage is deployed behind a reverse proxy, compressing responses between sqlpage and the proxy is wasteful.
10-
- In the table component, allow simple objects in custom_actions instead of requiring arrays of objects.
11-
- Fatser icon loading. Previously, even a page containing a single icon required downloading and parsing a ~2MB file. This resulted in a delay where pages initially appeared with a blank space before icons appeared. Icons are now inlined inside pages and appear instantaneously.
12-
- Updated tabler icons to 3.35
13-
- Fix inaccurate ODBC warnings
14-
- Added support for Microsoft SQL Server named instances: `mssql://user:pass@localhost/db?instance_name=xxx`
15-
- Added a detailed [performance guide](https://sql-page.com/blog?post=Performance+Guide) to the docs.
3+
## v0.39.1 (2025-11-08)
4+
- More precise server timing tracking to debug performance issues
5+
- Fix missing server timing header in some cases
6+
- Implement nice error messages for some header-related errors such as invalid header values.
7+
- `compress_responses` is now set to `false` by default in the configuration.
8+
- When response compression is enabled, additional buffering is needed. Users reported a better experience with pages that load more progressively, reducing the time before the pages' shell is rendered.
9+
- When SQLPage is deployed behind a reverse proxy, compressing responses between sqlpage and the proxy is wasteful.
10+
- In the table component, allow simple objects in custom_actions instead of requiring arrays of objects.
11+
- Fatser icon loading. Previously, even a page containing a single icon required downloading and parsing a ~2MB file. This resulted in a delay where pages initially appeared with a blank space before icons appeared. Icons are now inlined inside pages and appear instantaneously.
12+
- Updated tabler icons to 3.35
13+
- Fix inaccurate ODBC warnings
14+
- Added support for Microsoft SQL Server named instances: `mssql://user:pass@localhost/db?instance_name=xxx`
15+
- Added a detailed [performance guide](https://sql-page.com/blog?post=Performance+Guide) to the docs.
16+
- Added an `image_height` property to the card component so top images can be capped without stretching or upscaling.
1617

1718
## v0.39.0 (2025-10-28)
1819
- Ability to execute sql for URL paths with another extension. If you create sitemap.xml.sql, it will be executed for example.com/sitemap.xml

examples/official-site/sqlpage/migrations/31_card_docs_update.sql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
1818
This is useful if you want to display a lot of text in the card, with many options for formatting, such as
1919
line breaks, **bold**, *italics*, lists, #titles, [links](target.sql), ![images](photo.jpg), etc.', 'TEXT', FALSE, TRUE),
2020
('top_image', 'The URL (absolute or relative) of an image to display at the top of the card.', 'URL', FALSE, TRUE),
21+
('image_height', 'Maximum height for the top image. The image will scale down to fit this height without distorting or upscaling.', 'TEXT', FALSE, TRUE),
2122
('footer', 'Muted text to display at the bottom of the card.', 'TEXT', FALSE, TRUE),
2223
('footer_md', 'Muted text to display at the bottom of the card, with rich text formatting in Markdown format.', 'TEXT', FALSE, TRUE),
2324
('link', 'An URL to which the user should be taken when they click on the card.', 'URL', FALSE, TRUE),
@@ -58,9 +59,9 @@ INSERT INTO example(component, description, properties) VALUES
5859
('card', 'A gallery of images.',
5960
json('[
6061
{"component":"card", "title":"My favorite animals in pictures", "columns": 3},
61-
{"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" },
62-
{"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" },
63-
{"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" }
62+
{"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": "12rem", "icon":"star" },
63+
{"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": "12rem" },
64+
{"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": "12rem" }
6465
]')),
6566
('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',
6667
json('[

sqlpage/sqlpage.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ td > p {
2222
margin-bottom: 0 !important;
2323
}
2424

25+
.card-img-top-constrained {
26+
width: auto;
27+
max-width: 100%;
28+
height: auto;
29+
max-height: var(--sqlpage-card-image-height, none);
30+
display: block;
31+
margin-left: auto;
32+
margin-right: auto;
33+
object-fit: scale-down;
34+
}
35+
2536
.text-secondary a {
2637
color: inherit;
2738
text-decoration: underline;

sqlpage/templates/card.handlebars

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
<a href="{{link}}" style="text-decoration: inherit; color: inherit">
3939
{{/if}}
4040
{{#if top_image}}
41-
<img src="{{top_image}}" class="card-img-top" />
41+
<img src="{{top_image}}"
42+
class="card-img-top{{#if image_height}} card-img-top-constrained mx-auto{{/if}}"
43+
{{#if image_height}}style="--sqlpage-card-image-height: {{image_height}};"{{/if}} />
4244
{{/if}}
4345
{{#if color}}
4446
{{#if (not embed)}}

0 commit comments

Comments
 (0)