Skip to content

Commit e20f641

Browse files
committed
carousel improvements
Allow setting image width and height in carousels, in order to avoid differently sized images to cause layout janking when going through them.
1 parent cf86a22 commit e20f641

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Add a new optional `database_password` configuration option to set the password for the database connection separately from the connection string. This allows to keep the password separate from the connection string, which can be useful for security purposes, logging, and avoids having to percent-encode the password in the connection string.
99
- New `initial_search_value` property in the table component to pre-fill the search bar with a value. This allows to display the table rows that will initially be filtered out by the search bar.
1010
- Fix autoplay of carousels when embedded in a card.
11+
- Allow setting image width and height in carousels, in order to avoid differently sized images to cause layout janking when going through them.
1112

1213
## 0.29.0 (2024-09-25)
1314
- New columns component: `columns`. Useful to display a comparison between items, or large key figures to an user.

examples/official-site/sqlpage/migrations/34_carousel.sql

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ VALUES
5454
TRUE,
5555
TRUE
5656
),
57-
(
57+
(
5858
'carousel',
5959
'auto',
6060
'Whether to automatically cycle through the carousel items. Default is false.',
@@ -109,6 +109,22 @@ VALUES
109109
'TEXT',
110110
FALSE,
111111
TRUE
112+
),
113+
(
114+
'carousel',
115+
'width',
116+
'The width of the image, in pixels.',
117+
'INTEGER',
118+
FALSE,
119+
TRUE
120+
),
121+
(
122+
'carousel',
123+
'height',
124+
'The height of the image, in pixels.',
125+
'INTEGER',
126+
FALSE,
127+
TRUE
112128
);
113129
-- Insert example(s) for the component
114130
INSERT INTO example(component, description, properties)
@@ -128,9 +144,9 @@ VALUES (
128144
'An advanced example of carousel with controls',
129145
JSON(
130146
'[
131-
{"component":"carousel","title":"Cats","width":6,"center":true,"controls":true,"auto":true},
132-
{"image":"https://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Cat_Sphynx._Kittens._img_11.jpg/1024px-Cat_Sphynx._Kittens._img_11.jpg","title":"A first cat","description":"The cat (Felis catus), commonly referred to as the domestic cat or house cat, is the only domesticated species in the family Felidae."},
133-
{"image":"https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Cat_close-up_2004_b.jpg/1280px-Cat_close-up_2004_b.jpg","title":"Another cat"}
147+
{"component":"carousel","title":"SQL web apps","width":6, "center":true,"controls":true,"auto":true},
148+
{"image":"/sqlpage_cover_image.webp","title":"SQLPage is modern","description":"Built by engineers who have built so many web applications the old way, they decided they just wouldn''t anymore.", "height": 512},
149+
{"image":"/sqlpage_illustration_alien.webp","title":"SQLPage is easy", "description":"SQLPage connects to your database, then it turns your SQL queries into nice websites.", "height": 512}
134150
]'
135151
)
136152
);

sqlpage/templates/carousel.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{{#delay}}
1313
{{flush_delayed}}
1414
<div class="carousel-item {{#if (eq @row_index 0)}}active{{/if}}">
15-
<img class="d-block w-100" alt="{{image}}" src="{{image}}" />
15+
<img class="d-block w-100 object-fit-cover" alt="{{image}}" src="{{image}}" {{#if width}}width="{{width}}"{{/if}} {{#if height}}height="{{height}}"{{/if}} />
1616
{{#if title}}
1717
<div class="carousel-caption-background d-none d-md-block"></div>
1818
<div class="carousel-caption d-none d-md-block">

0 commit comments

Comments
 (0)