Skip to content

Commit 2aa0eec

Browse files
committed
loop, muted, and nocontrols for videos
1 parent 2bf85bc commit 2aa0eec

File tree

4 files changed

+41
-19
lines changed

4 files changed

+41
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- In the [map](https://sql.ophir.dev/documentation.sql?component=map#component) component, when top-level latitude and longitude properties are omitted, the map will now center on its markers. This makes it easier to create zoomed maps with a single marker.
1515
- In the [button](https://sql.ophir.dev/documentation.sql?component=button#component) component, add a `download` property to make the button download a file when clicked, a `target` property to open the link in a new tab, and a `rel` property to prevent search engines from following the link.
1616
- New `timeout` option in the [sqlpage.fetch](https://sql.ophir.dev/functions.sql?function=fetch#function) function to set a timeout for the request. This is useful when working with slow or unreliable APIs, large payloads, or when you want to avoid waiting too long for a response.
17+
- In the [hero](https://sql.ophir.dev/documentation.sql?component=hero#component) component, add a `poster` property to display a video poster image, a `loop` property to loop the video (useful for short animations), a `muted` property to mute the video, and a `nocontrols` property to hide video controls.
1718

1819
## 0.22.0 (2024-05-29)
1920
- **Important Security Fix:** The behavior of `SET $x` has been modified to match `SELECT $x`.

examples/official-site/index.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SELECT 'hero' as component,
99
1010
Open-source *low-code* web application server' as description_md,
1111
'sqlpage_introduction_video.webm' as video,
12+
TRUE as rounded,
1213
'your-first-sql-website/' as link,
1314
'Build your first SQL website now !' as link_text;
1415

examples/official-site/sqlpage/migrations/02_hero_component.sql

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
-- Hero
2-
INSERT INTO component(name, icon, description)
3-
VALUES (
2+
INSERT INTO
3+
component(name, icon, description)
4+
VALUES
5+
(
46
'hero',
57
'home',
68
'Display a large title and description for your page, with an optional large illustrative image. Useful in your home page, for instance.'
79
);
8-
INSERT INTO parameter(
10+
11+
INSERT INTO
12+
parameter(
913
component,
1014
name,
1115
description,
1216
type,
1317
top_level,
1418
optional
1519
)
16-
SELECT 'hero',
20+
SELECT
21+
'hero',
1722
*
18-
FROM (
19-
VALUES -- top level
23+
FROM
24+
(
25+
VALUES
26+
-- top level
2027
(
2128
'title',
2229
'The title of your page. Will be shown in very large characters at the top.',
@@ -68,11 +75,21 @@ FROM (
6875
),
6976
(
7077
'poster',
71-
'URL of the image to be displayed before the video starts.',
78+
'URL of the image to be displayed before the video starts. Ignored if no video is present.',
7279
'URL',
7380
TRUE,
7481
TRUE
7582
),
83+
(
84+
'nocontrols',
85+
'Hide the video controls (play, pause, volume, etc.), and autoplay the video.',
86+
'BOOLEAN',
87+
TRUE,
88+
TRUE
89+
),
90+
('muted', 'Mute the video', 'BOOLEAN', TRUE, TRUE),
91+
('autoplay', 'Automatically start playing the video', 'BOOLEAN', TRUE, TRUE),
92+
('loop', 'Loop the video', 'BOOLEAN', TRUE, TRUE),
7693
-- item level
7794
(
7895
'title',
@@ -110,8 +127,11 @@ FROM (
110127
TRUE
111128
)
112129
) x;
113-
INSERT INTO example(component, description, properties)
114-
VALUES (
130+
131+
INSERT INTO
132+
example(component, description, properties)
133+
VALUES
134+
(
115135
'hero',
116136
'The simplest possible hero section',
117137
json(
@@ -132,9 +152,6 @@ VALUES (
132152
"description_md": "Documentation for the *SQLPage* low-code web application framework.",
133153
"image": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e4/Lac_de_Zoug.jpg/640px-Lac_de_Zoug.jpg",
134154
"link": "/documentation.sql",
135-
"link_text": "Read Documentation !"},' ||
136-
'{"title": "Fast", "description": "Pages load instantly, even on slow mobile networks.", "icon": "car", "color": "red", "link": "/"},' ||
137-
'{"title": "Beautiful", "description": "Uses pre-defined components that look professional.", "icon": "eye", "color": "green", "link": "/"},' ||
138-
'{"title": "Easy", "description_md": "You can teach yourself enough SQL to use [**SQLPage**](https://sql.ophir.dev) in a weekend.", "icon": "sofa", "color": "blue", "link": "/"}' || ']'
155+
"link_text": "Read Documentation !"},' || '{"title": "Fast", "description": "Pages load instantly, even on slow mobile networks.", "icon": "car", "color": "red", "link": "/"},' || '{"title": "Beautiful", "description": "Uses pre-defined components that look professional.", "icon": "eye", "color": "green", "link": "/"},' || '{"title": "Easy", "description_md": "You can teach yourself enough SQL to use [**SQLPage**](https://sql.ophir.dev) in a weekend.", "icon": "sofa", "color": "blue", "link": "/"}' || ']'
139156
)
140-
);
157+
);

sqlpage/templates/hero.handlebars

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
<img src="{{image}}" alt="{{title}}" class="hero-image img-fluid col-lg-6" />
1616
{{/if}}
1717
{{#if video}}
18-
<video src="{{video}}" alt="{{title}}" class="hero-image img-fluid col-lg-6" controls
19-
{{#if poster}}
20-
preload="none"
21-
poster="{{poster}}"
22-
{{/if}}>
18+
<video src="{{video}}" alt="{{title}}" class="hero-image img-fluid col-lg-6"
19+
{{~#if loop}} loop{{/if~}}
20+
{{~#if muted}} muted{{/if~}}
21+
{{~#if nocontrols}} autoplay{{else}}
22+
{{~#if autoplay}} autoplay{{/if~}}
23+
controls
24+
{{/if~}}
25+
{{~#if poster}} preload="none" poster="{{poster}}"{{/if~}}>
2326
</video>
2427
{{/if}}
2528
</header>

0 commit comments

Comments
 (0)