Skip to content

Commit 16eaa08

Browse files
committed
Make hero, card, and carousel previews easier to maintain
1 parent f398422 commit 16eaa08

18 files changed

Lines changed: 453 additions & 450 deletions
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
icon: credit-card
3+
category: display-data
4+
summary: Arrange records in cards with images, links, or embedded content.
5+
top:
6+
- class
7+
- name: columns
8+
type: INTEGER
9+
description: The number of columns in the grid of cards. This is just a hint, the grid will adjust dynamically
10+
to the user's screen size, rendering fewer columns if needed to fit the contents. To control the size
11+
of cards individually, use the `width` row-level property instead.
12+
- name: description
13+
type: TEXT
14+
description: A short paragraph displayed below the title.
15+
- name: description_md
16+
type: TEXT
17+
description: A short paragraph displayed below the title - formatted using markdown.
18+
- name: title
19+
type: TEXT
20+
description: Text header at the top of the list of cards.
21+
row:
22+
- name: active
23+
type: BOOLEAN
24+
description: Whether this item in the grid is considered "active". Active items are displayed more prominently.
25+
- name: allow
26+
type: TEXT
27+
description: The permissions policy of the iframe embed code, for instance "fullscreen; clipboard-write".
28+
Used only when embed_mode is 'iframe'.
29+
- name: background_color
30+
type: COLOR
31+
description: The background color of the card.
32+
- class
33+
- name: color
34+
type: COLOR
35+
description: The name of a color, to be displayed on the left of the card to highlight it. If the embed
36+
parameter is enabled and you don't have a title or description, this parameter won't apply.
37+
- name: description
38+
type: TEXT
39+
description: |-
40+
The body of the card, where you put the main text contents of the card.
41+
This does not support rich text formatting, only plain text.
42+
If you want to use rich text formatting, use the `description_md` property instead.
43+
- name: description_md
44+
type: TEXT
45+
description: |2-
46+
47+
The body of the card, in Markdown format.
48+
This is useful if you want to display a lot of text in the card, with many options for formatting, such as
49+
line breaks, **bold**, *italics*, lists, #titles, [links](target.sql), ![images](photo.jpg), etc.
50+
- name: embed
51+
type: TEXT
52+
description: |-
53+
A url whose contents will be fetched and injected into the body of this card.
54+
This can be used to inject arbitrary html content, but is especially useful for injecting
55+
the output of other sql files rendered by SQLPage. For the latter case you can pass the
56+
`?_sqlpage_embed` query parameter, which will skip the shell layout.
57+
Components inside the fetched content initialize automatically. Custom scripts that insert
58+
SQLPage fragments should dispatch a bubbling `fragment-loaded` event on the element containing
59+
the new content. Initialization includes that element and its descendants; dispatching the
60+
event on `document` initializes pending components throughout the page. Repeated events
61+
preserve existing form and widget handlers
62+
- name: embed_mode
63+
type: TEXT
64+
description: |-
65+
Set to 'iframe' to embed the target (specified through embed property) in an iframe.
66+
Unless this is explicitly set, the embed target is fetched and injected within the parent page. If embed_mode is set to iframe,
67+
You can also set height and width parameters to configure the appearance and the sandbox and allow parameters to configure
68+
security aspects of the iframe. Refer to the [MDN page](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)
69+
for an explanation of these parameters.
70+
- name: embed_title
71+
type: TEXT
72+
description: Accessible name of the iframe. Defaults to the card title, or Embedded content if no title is set.
73+
- name: footer
74+
type: TEXT
75+
description: Muted text to display at the bottom of the card.
76+
- name: footer_link
77+
type: URL
78+
description: An URL to which the user should be taken when they click on the footer.
79+
- name: footer_md
80+
type: TEXT
81+
description: Muted text to display at the bottom of the card, with rich text formatting in Markdown format.
82+
- name: height
83+
type: INTEGER
84+
description: Height of the iframe embed code, in pixels. Used only when embed_mode is 'iframe'.
85+
- name: icon
86+
type: ICON
87+
description: Name of an icon to display on the right side of the card.
88+
- id
89+
- name: link
90+
type: URL
91+
description: An URL to which the user should be taken when they click on the card.
92+
- name: sandbox
93+
type: TEXT
94+
description: The restrictions to apply to the iframe embed code, for instance "allow-scripts allow-same-origin".
95+
Used only when embed_mode is 'iframe'.
96+
- name: style
97+
type: TEXT
98+
description: 'Inline style property to your iframe embed code. For example "background-color: #FFFFFF"'
99+
- name: target
100+
type: TEXT
101+
description: 'Where the card''s link opens: "_blank" for a new tab, "_self" for the same tab, "_parent"
102+
for the parent frame, or "_top" for the full body of the window.'
103+
- name: title
104+
type: TEXT
105+
required: true
106+
description: Name of the card, displayed at the top.
107+
- name: top_image
108+
type: URL
109+
description: The URL (absolute or relative) of an image to display at the top of the card.
110+
- name: top_image_alt
111+
type: TEXT
112+
description: Alternative text for an informative card image. Leave empty if decorative.
113+
- name: top_image_height
114+
type: INTEGER
115+
description: Specify the top image height, in pixels. Helps prevent layout shifts.
116+
- name: top_image_lazy
117+
type: BOOLEAN
118+
description: Whether the top image must be lazily loaded. Defaults to false, meaning eagerly loaded.
119+
- name: top_image_width
120+
type: INTEGER
121+
description: Specify the top image width, in pixels. Helps prevent layout shifts.
122+
- name: width
123+
type: INTEGER
124+
description: The width of the card, between 1 (smallest) and 12 (full-width). The default width is 3, resulting
125+
in 4 cards per line. When embed_mode is 'iframe', this is used as the width of the iframe instead, and
126+
defaults to 100%.
127+
---
128+
129+
A grid where each element is a small card that displays a piece of data.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
rows:
3+
- component: card
4+
title: Popular SQLPage features
5+
columns: 2
6+
- title: Download as spreadsheet
7+
link: ?component=csv#component
8+
description: Using the CSV component, you can download your data as a spreadsheet.
9+
icon: file-plus
10+
color: green
11+
footer_md: SQLPage can both [read](?component=form#component) and [write](?component=csv#component) **CSV**
12+
files.
13+
- title: Custom components
14+
link: /custom_components.sql
15+
description: If you know some HTML, you can create your own components for your application.
16+
icon: code
17+
color: orange
18+
footer_md: You can look at the [source of the official components](https://github.com/sqlpage/SQLPage/tree/main/sqlpage/templates)
19+
for inspiration.
20+
---
21+
22+
A beautiful card grid with bells and whistles, showing examples of SQLPage features.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
rows:
3+
- component: card
4+
columns: 4
5+
- description_md: '**152** sales today'
6+
active: true
7+
icon: currency-euro
8+
- description_md: '**13** new users'
9+
icon: user-plus
10+
color: green
11+
- description_md: '**2** complaints'
12+
icon: alert-circle
13+
color: danger
14+
link: ?view_complaints
15+
background_color: red-lt
16+
- description_md: '**1** pending support request'
17+
icon: mail-question
18+
color: warning
19+
---
20+
21+
You can use cards to display a dashboard with quick access to important information. Use [markdown](https://www.markdownguide.org/basic-syntax) to format the text.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
rows:
3+
- component: card
4+
title: My favorite animals in pictures
5+
columns: 3
6+
- title: Lynx
7+
description_md: The **lynx** is a medium-sized **wild cat** native to Northern, Central and Eastern Europe
8+
to Central Asia and Siberia, the Tibetan Plateau and the Himalayas.
9+
top_image_alt: A Eurasian lynx
10+
top_image: https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Lynx_lynx_-_05.jpg/330px-Lynx_lynx_-_05.jpg
11+
top_image_width: 330
12+
top_image_height: 495
13+
top_image_lazy: true
14+
icon: star
15+
- title: Squirrel
16+
description_md: The **chipmunk** is a small, striped rodent of the family Sciuridae. Chipmunks are found
17+
in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.
18+
top_image_alt: A squirrel eating a nut
19+
top_image: https://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/American_squirrel_eating_nut%2C_13_Jun_2013.JPG/330px-American_squirrel_eating_nut%2C_13_Jun_2013.JPG
20+
top_image_width: 330
21+
top_image_height: 495
22+
top_image_lazy: true
23+
- title: Spider
24+
description_md: The **jumping spider family** (_Salticidae_) contains more than 600 described genera and
25+
about *6000 described species*, making it the largest family of spiders with about 13% of all species.
26+
top_image_alt: An orb weaver spinning a web
27+
top_image: https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Australian_orb_weaver_spinning_web.jpg/330px-Australian_orb_weaver_spinning_web.jpg
28+
top_image_width: 330
29+
top_image_height: 495
30+
top_image_lazy: true
31+
---
32+
33+
A gallery of images.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
rows:
3+
- component: card
4+
title: Beautifully colored cards
5+
- title: Red card
6+
color: red
7+
background_color: red-lt
8+
description: Penalty! You are out!
9+
icon: play-football
10+
- title: Blue card
11+
color: blue
12+
width: 6
13+
background_color: blue-lt
14+
description: The Blue Card facilitates migration of foreigners to Europe.
15+
icon: currency-euro
16+
- title: Green card
17+
color: green
18+
background_color: green-lt
19+
description: Welcome to the United States of America !
20+
icon: user-dollar
21+
---
22+
23+
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
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
rows:
3+
- component: card
4+
title: Card with embedded remote content
5+
columns: 2
6+
- title: Embedded Chart
7+
embed: /examples/chart.sql?_sqlpage_embed
8+
- title: Embedded Video
9+
embed: https://www.youtube.com/embed/mXdgmSdaXkg
10+
allow: accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share
11+
embed_mode: iframe
12+
height: '350'
13+
---
14+
15+
Cards with remote content
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
icon: carousel-horizontal
3+
since: 0.18.3
4+
category: display-data
5+
summary: Show a slideshow of images with optional captions and controls.
6+
top:
7+
- name: auto
8+
type: BOOLEAN
9+
description: Whether to automatically cycle through the carousel items. Default is false.
10+
- name: center
11+
type: BOOLEAN
12+
description: Whether to center the carousel.
13+
- class
14+
- name: controls
15+
type: BOOLEAN
16+
description: Whether to show the control links to go previous or next item.
17+
- name: delay
18+
type: INTEGER
19+
description: Specify the delay, in milliseconds, between two images.
20+
- name: fade
21+
type: BOOLEAN
22+
description: Whether to apply the fading effect.
23+
- id
24+
- name: indicators
25+
type: TEXT
26+
description: Style of image indicators (square or dot).
27+
- name: title
28+
type: TEXT
29+
description: A name to display at the top of the carousel.
30+
- name: vertical
31+
type: BOOLEAN
32+
description: Whether to use the vertical image indicators.
33+
- name: width
34+
type: INTEGER
35+
description: Width of the component, between 1 and 12. Default is 12.
36+
row:
37+
- name: description
38+
type: TEXT
39+
description: A short paragraph.
40+
- name: description_md
41+
type: TEXT
42+
description: A short paragraph formatted using markdown.
43+
- name: height
44+
type: INTEGER
45+
description: The height of the image, in pixels.
46+
- name: image
47+
type: URL
48+
required: true
49+
description: The URL (absolute or relative) of an image to display in the carousel.
50+
- name: image_alt
51+
type: TEXT
52+
description: Alternative text describing the slide image. Leave empty if the image is decorative or its caption already describes it.
53+
- name: title
54+
type: TEXT
55+
description: Add caption to the slide.
56+
- name: width
57+
type: INTEGER
58+
description: The width of the image, in pixels.
59+
---
60+
61+
A carousel is used to display images. When used with multiple images, it will cycle through them automatically or with controls, creating a slideshow.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
rows:
3+
- component: carousel
4+
name: cats1
5+
title: Famous Database Animals
6+
- image_alt: African elephants at a watering hole
7+
image: https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Elefantes_africanos_de_sabana_%28Loxodonta_africana%29%2C_Elephant_Sands%2C_Botsuana%2C_2018-07-28%2C_DD_114-117_PAN.jpg/1280px-Elefantes_africanos_de_sabana_%28Loxodonta_africana%29%2C_Elephant_Sands%2C_Botsuana%2C_2018-07-28%2C_DD_114-117_PAN.jpg
8+
- image_alt: A panoramic view of Penguin Island
9+
image: https://upload.wikimedia.org/wikipedia/commons/thumb/9/99/Penguin_Island_panorama_with_ferry_and_dolphins_in_foreground%2C_March_2023_06.jpg/1280px-Penguin_Island_panorama_with_ferry_and_dolphins_in_foreground%2C_March_2023_06.jpg
10+
---
11+
12+
A basic example of carousel
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
rows:
3+
- component: carousel
4+
title: SQL web apps
5+
width: 10
6+
center: true
7+
controls: true
8+
auto: true
9+
- image: /sqlpage_cover_image.webp
10+
title: SQLPage is modern
11+
description: Built by engineers who have built so many web applications the old way, they decided they
12+
just wouldn't anymore.
13+
height: 512
14+
- image: /sqlpage_illustration_alien.webp
15+
title: SQLPage is easy
16+
description: SQLPage connects to your database, then it turns your SQL queries into nice websites.
17+
height: 512
18+
---
19+
20+
An advanced example of carousel with controls

0 commit comments

Comments
 (0)