Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions examples/official-site/content/components/card.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
icon: credit-card
category: display-data
summary: Arrange records in cards with images, links, or embedded content.
top:
- class
- name: columns
type: INTEGER
description: The number of columns in the grid of cards. This is just a hint, the grid will adjust dynamically
to the user's screen size, rendering fewer columns if needed to fit the contents. To control the size
of cards individually, use the `width` row-level property instead.
- name: description
type: TEXT
description: A short paragraph displayed below the title.
- name: description_md
type: TEXT
description: A short paragraph displayed below the title - formatted using markdown.
- name: title
type: TEXT
description: Text header at the top of the list of cards.
row:
- name: active
type: BOOLEAN
description: Whether this item in the grid is considered "active". Active items are displayed more prominently.
- name: allow
type: TEXT
description: The permissions policy of the iframe embed code, for instance "fullscreen; clipboard-write".
Used only when embed_mode is 'iframe'.
- name: background_color
type: COLOR
description: The background color of the card.
- class
- name: color
type: COLOR
description: The name of a color, to be displayed on the left of the card to highlight it. If the embed
parameter is enabled and you don't have a title or description, this parameter won't apply.
- name: description
type: TEXT
description: |-
The body of the card, where you put the main text contents of the card.
This does not support rich text formatting, only plain text.
If you want to use rich text formatting, use the `description_md` property instead.
- name: description_md
type: TEXT
description: |2-

The body of the card, in Markdown format.
This is useful if you want to display a lot of text in the card, with many options for formatting, such as
line breaks, **bold**, *italics*, lists, #titles, [links](target.sql), ![images](photo.jpg), etc.
- name: embed
type: TEXT
description: |-
A url whose contents will be fetched and injected into the body of this card.
This can be used to inject arbitrary html content, but is especially useful for injecting
the output of other sql files rendered by SQLPage. For the latter case you can pass the
`?_sqlpage_embed` query parameter, which will skip the shell layout.
Components inside the fetched content initialize automatically. Custom scripts that insert
SQLPage fragments should dispatch a bubbling `fragment-loaded` event on the element containing
the new content. Initialization includes that element and its descendants; dispatching the
event on `document` initializes pending components throughout the page. Repeated events
preserve existing form and widget handlers
- name: embed_mode
type: TEXT
description: |-
Set to 'iframe' to embed the target (specified through embed property) in an iframe.
Unless this is explicitly set, the embed target is fetched and injected within the parent page. If embed_mode is set to iframe,
You can also set height and width parameters to configure the appearance and the sandbox and allow parameters to configure
security aspects of the iframe. Refer to the [MDN page](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)
for an explanation of these parameters.
- name: embed_title
type: TEXT
description: Accessible name of the iframe. Defaults to the card title, or Embedded content if no title is set.
- name: footer
type: TEXT
description: Muted text to display at the bottom of the card.
- name: footer_link
type: URL
description: An URL to which the user should be taken when they click on the footer.
- name: footer_md
type: TEXT
description: Muted text to display at the bottom of the card, with rich text formatting in Markdown format.
- name: height
type: INTEGER
description: Height of the iframe embed code, in pixels. Used only when embed_mode is 'iframe'.
- name: icon
type: ICON
description: Name of an icon to display on the right side of the card.
- id
- name: link
type: URL
description: An URL to which the user should be taken when they click on the card.
- name: sandbox
type: TEXT
description: The restrictions to apply to the iframe embed code, for instance "allow-scripts allow-same-origin".
Used only when embed_mode is 'iframe'.
- name: style
type: TEXT
description: 'Inline style property to your iframe embed code. For example "background-color: #FFFFFF"'
- name: target
type: TEXT
description: 'Where the card''s link opens: "_blank" for a new tab, "_self" for the same tab, "_parent"
for the parent frame, or "_top" for the full body of the window.'
- name: title
type: TEXT
required: true
description: Name of the card, displayed at the top.
- name: top_image
type: URL
description: The URL (absolute or relative) of an image to display at the top of the card.
- name: top_image_alt
type: TEXT
description: Alternative text for an informative card image. Leave empty if decorative.
- name: top_image_height
type: INTEGER
description: Specify the top image height, in pixels. Helps prevent layout shifts.
- name: top_image_lazy
type: BOOLEAN
description: Whether the top image must be lazily loaded. Defaults to false, meaning eagerly loaded.
- name: top_image_width
type: INTEGER
description: Specify the top image width, in pixels. Helps prevent layout shifts.
- name: width
type: INTEGER
description: The width of the card, between 1 (smallest) and 12 (full-width). The default width is 3, resulting
in 4 cards per line. When embed_mode is 'iframe', this is used as the width of the iframe instead, and
defaults to 100%.
---

A grid where each element is a small card that displays a piece of data.
22 changes: 22 additions & 0 deletions examples/official-site/content/components/card/examples/01-grid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
rows:
- component: card
title: Popular SQLPage features
columns: 2
- title: Download as spreadsheet
link: ?component=csv#component
description: Using the CSV component, you can download your data as a spreadsheet.
icon: file-plus
color: green
footer_md: SQLPage can both [read](?component=form#component) and [write](?component=csv#component) **CSV**
files.
- title: Custom components
link: /custom_components.sql
description: If you know some HTML, you can create your own components for your application.
icon: code
color: orange
footer_md: You can look at the [source of the official components](https://github.com/sqlpage/SQLPage/tree/main/sqlpage/templates)
for inspiration.
---

A beautiful card grid with bells and whistles, showing examples of SQLPage features.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
rows:
- component: card
columns: 4
- description_md: '**152** sales today'
active: true
icon: currency-euro
- description_md: '**13** new users'
icon: user-plus
color: green
- description_md: '**2** complaints'
icon: alert-circle
color: danger
link: ?view_complaints
background_color: red-lt
- description_md: '**1** pending support request'
icon: mail-question
color: warning
---

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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
rows:
- component: card
title: My favorite animals in pictures
columns: 3
- 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_alt: A Eurasian lynx
top_image: https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Lynx_lynx_-_05.jpg/330px-Lynx_lynx_-_05.jpg
top_image_width: 330
top_image_height: 495
top_image_lazy: true
icon: star
- 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_alt: A squirrel eating a nut
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
top_image_width: 330
top_image_height: 495
top_image_lazy: true
- 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_alt: An orb weaver spinning a web
top_image: https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Australian_orb_weaver_spinning_web.jpg/330px-Australian_orb_weaver_spinning_web.jpg
top_image_width: 330
top_image_height: 495
top_image_lazy: true
---

A gallery of images.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
rows:
- component: card
title: Beautifully colored cards
- title: Red card
color: red
background_color: red-lt
description: Penalty! You are out!
icon: play-football
- title: Blue card
color: blue
width: 6
background_color: blue-lt
description: The Blue Card facilitates migration of foreigners to Europe.
icon: currency-euro
- title: Green card
color: green
background_color: green-lt
description: Welcome to the United States of America !
icon: user-dollar
---

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
rows:
- component: card
title: Card with embedded remote content
columns: 2
- title: Embedded Chart
embed: /examples/chart.sql
- title: Embedded Video
embed: https://www.youtube.com/embed/mXdgmSdaXkg
allow: accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share
embed_mode: iframe
height: '350'
---

The first card embeds a SQLPage chart as a page fragment. The second embeds a video player in an iframe with its own `height` and `allow` attributes.
61 changes: 61 additions & 0 deletions examples/official-site/content/components/carousel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
icon: carousel-horizontal
since: 0.18.3
category: display-data
summary: Show a slideshow of images with optional captions and controls.
top:
- name: auto
type: BOOLEAN
description: Whether to automatically cycle through the carousel items. Default is false.
- name: center
type: BOOLEAN
description: Whether to center the carousel.
- class
- name: controls
type: BOOLEAN
description: Whether to show the control links to go previous or next item.
- name: delay
type: INTEGER
description: Specify the delay, in milliseconds, between two images.
- name: fade
type: BOOLEAN
description: Whether to apply the fading effect.
- id
- name: indicators
type: TEXT
description: Style of image indicators (square or dot).
- name: title
type: TEXT
description: A name to display at the top of the carousel.
- name: vertical
type: BOOLEAN
description: Whether to use the vertical image indicators.
- name: width
type: INTEGER
description: Width of the component, between 1 and 12. Default is 12.
row:
- name: description
type: TEXT
description: A short paragraph.
- name: description_md
type: TEXT
description: A short paragraph formatted using markdown.
- name: height
type: INTEGER
description: The height of the image, in pixels.
- name: image
type: URL
required: true
description: The URL (absolute or relative) of an image to display in the carousel.
- name: image_alt
type: TEXT
description: Alternative text describing the slide image. Leave empty if the image is decorative or its caption already describes it.
- name: title
type: TEXT
description: Add caption to the slide.
- name: width
type: INTEGER
description: The width of the image, in pixels.
---

A carousel is used to display images. When used with multiple images, it will cycle through them automatically or with controls, creating a slideshow.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
rows:
- component: carousel
name: cats1
title: Famous Database Animals
- image_alt: African elephants at a watering hole
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
- image_alt: A panoramic view of Penguin Island
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
---

A basic example of carousel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
rows:
- component: carousel
title: SQL web apps
width: 10
center: true
controls: true
auto: true
- 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
- 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
---

An advanced example of carousel with controls
Loading
Loading