Skip to content

Commit f88cfd3

Browse files
cursoragentlovasoa
andcommitted
Fix: Update card image height to use pixels and improve styling
Co-authored-by: contact <contact@ophir.dev>
1 parent ac969f6 commit f88cfd3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +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),
21+
('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),
2222
('footer', 'Muted text to display at the bottom of the card.', 'TEXT', FALSE, TRUE),
2323
('footer_md', 'Muted text to display at the bottom of the card, with rich text formatting in Markdown format.', 'TEXT', FALSE, TRUE),
2424
('link', 'An URL to which the user should be taken when they click on the card.', 'URL', FALSE, TRUE),
@@ -59,9 +59,9 @@ INSERT INTO example(component, description, properties) VALUES
5959
('card', 'A gallery of images.',
6060
json('[
6161
{"component":"card", "title":"My favorite animals in pictures", "columns": 3},
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" }
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": 220, "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": 220 },
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": 220 }
6565
]')),
6666
('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',
6767
json('[

sqlpage/templates/card.handlebars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
{{/if}}
4040
{{#if top_image}}
4141
<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}} />
42+
class="card-img-top{{#if image_height}} mw-100 w-auto h-auto mx-auto{{/if}}"
43+
{{#if image_height}}style="max-height: {{image_height}}px;"{{/if}} />
4444
{{/if}}
4545
{{#if color}}
4646
{{#if (not embed)}}

0 commit comments

Comments
 (0)