From db4a8be76c8cb5931d7c0c8263b591ea897e22a1 Mon Sep 17 00:00:00 2001 From: Ophir Lojkine Date: Sun, 22 Nov 2026 23:32:36 +0000 Subject: [PATCH] Give each component one reference page for its parameters --- .../official-site/content/components/alert.md | 49 ++++ .../content/components/authentication.md | 55 ++++ .../content/components/big_number.md | 61 +++++ .../content/components/breadcrumb.md | 26 ++ .../content/components/button.md | 78 ++++++ .../official-site/content/components/card.md | 123 +++++++++ .../content/components/carousel.md | 58 ++++ .../official-site/content/components/chart.md | 134 +++++++++ .../official-site/content/components/code.md | 29 ++ .../content/components/columns.md | 52 ++++ .../content/components/cookie.md | 54 ++++ .../official-site/content/components/csv.md | 43 +++ .../content/components/datagrid.md | 55 ++++ .../official-site/content/components/debug.md | 9 + .../content/components/divider.md | 34 +++ .../content/components/download.md | 48 ++++ .../content/components/dynamic.md | 13 + .../content/components/empty_state.md | 46 ++++ .../official-site/content/components/facet.md | 74 +++++ .../content/components/foldable.md | 37 +++ .../official-site/content/components/form.md | 257 ++++++++++++++++++ .../official-site/content/components/hero.md | 70 +++++ .../official-site/content/components/html.md | 29 ++ .../content/components/http_header.md | 44 +++ .../official-site/content/components/json.md | 39 +++ .../official-site/content/components/list.md | 73 +++++ .../official-site/content/components/log.md | 26 ++ .../official-site/content/components/login.md | 95 +++++++ .../official-site/content/components/map.md | 87 ++++++ .../official-site/content/components/modal.md | 67 +++++ .../content/components/pagination.md | 104 +++++++ .../content/components/redirect.md | 43 +++ .../official-site/content/components/rss.md | 128 +++++++++ .../official-site/content/components/shell.md | 145 ++++++++++ .../content/components/status_bar.md | 37 +++ .../content/components/status_code.md | 36 +++ .../official-site/content/components/steps.md | 40 +++ .../official-site/content/components/tab.md | 43 +++ .../official-site/content/components/table.md | 149 ++++++++++ .../official-site/content/components/text.md | 72 +++++ .../content/components/timeline.md | 41 +++ .../official-site/content/components/title.md | 21 ++ .../official-site/content/components/toast.md | 47 ++++ .../content/components/tracking.md | 44 +++ .../content/shared-parameters.yaml | 10 + 45 files changed, 2825 insertions(+) create mode 100644 examples/official-site/content/components/alert.md create mode 100644 examples/official-site/content/components/authentication.md create mode 100644 examples/official-site/content/components/big_number.md create mode 100644 examples/official-site/content/components/breadcrumb.md create mode 100644 examples/official-site/content/components/button.md create mode 100644 examples/official-site/content/components/card.md create mode 100644 examples/official-site/content/components/carousel.md create mode 100644 examples/official-site/content/components/chart.md create mode 100644 examples/official-site/content/components/code.md create mode 100644 examples/official-site/content/components/columns.md create mode 100644 examples/official-site/content/components/cookie.md create mode 100644 examples/official-site/content/components/csv.md create mode 100644 examples/official-site/content/components/datagrid.md create mode 100644 examples/official-site/content/components/debug.md create mode 100644 examples/official-site/content/components/divider.md create mode 100644 examples/official-site/content/components/download.md create mode 100644 examples/official-site/content/components/dynamic.md create mode 100644 examples/official-site/content/components/empty_state.md create mode 100644 examples/official-site/content/components/facet.md create mode 100644 examples/official-site/content/components/foldable.md create mode 100644 examples/official-site/content/components/form.md create mode 100644 examples/official-site/content/components/hero.md create mode 100644 examples/official-site/content/components/html.md create mode 100644 examples/official-site/content/components/http_header.md create mode 100644 examples/official-site/content/components/json.md create mode 100644 examples/official-site/content/components/list.md create mode 100644 examples/official-site/content/components/log.md create mode 100644 examples/official-site/content/components/login.md create mode 100644 examples/official-site/content/components/map.md create mode 100644 examples/official-site/content/components/modal.md create mode 100644 examples/official-site/content/components/pagination.md create mode 100644 examples/official-site/content/components/redirect.md create mode 100644 examples/official-site/content/components/rss.md create mode 100644 examples/official-site/content/components/shell.md create mode 100644 examples/official-site/content/components/status_bar.md create mode 100644 examples/official-site/content/components/status_code.md create mode 100644 examples/official-site/content/components/steps.md create mode 100644 examples/official-site/content/components/tab.md create mode 100644 examples/official-site/content/components/table.md create mode 100644 examples/official-site/content/components/text.md create mode 100644 examples/official-site/content/components/timeline.md create mode 100644 examples/official-site/content/components/title.md create mode 100644 examples/official-site/content/components/toast.md create mode 100644 examples/official-site/content/components/tracking.md create mode 100644 examples/official-site/content/shared-parameters.yaml diff --git a/examples/official-site/content/components/alert.md b/examples/official-site/content/components/alert.md new file mode 100644 index 000000000..d65119c08 --- /dev/null +++ b/examples/official-site/content/components/alert.md @@ -0,0 +1,49 @@ +--- +icon: alert-triangle +category: forms-and-feedback +summary: Draw attention to a message with a color and an icon. +top: + - class + - name: color + type: COLOR + description: The color theme for the alert message. + - name: description + type: TEXT + description: Detailed description or content of the alert message. + - name: description_md + type: TEXT + description: Detailed description or content of the alert message, in Markdown format, allowing you to + use rich text formatting, including `**bold**` and `*italic*` text. + - name: dismissible + type: BOOLEAN + description: Whether the user can close the alert message. + - name: icon + type: TEXT + description: Icon name (from tabler-icons.io) to display next to the alert message. + - id + - name: important + type: BOOLEAN + description: Set this to TRUE to make the alert message more prominent. + - name: link + type: URL + description: A URL to link to from the alert message. + - name: link_text + type: TEXT + description: Customize the text of the link in the alert message. The default is "Ok". + - name: title + type: TEXT + required: true + description: Title of the alert message. +row: + - name: color + type: COLOR + description: Customize the color of the link. + - name: link + type: URL + description: A URL to link to from the alert message. + - name: title + type: TEXT + description: Customize the text of the link in the alert message. The default is "Ok". +--- + +A visually distinctive message or notification. diff --git a/examples/official-site/content/components/authentication.md b/examples/official-site/content/components/authentication.md new file mode 100644 index 000000000..0d37d500a --- /dev/null +++ b/examples/official-site/content/components/authentication.md @@ -0,0 +1,55 @@ +--- +icon: lock +since: 0.7.2 +category: server-logic +summary: Restrict access by checking a password against a stored hash. +top: + - name: link + type: TEXT + description: The URL to redirect the user to if they are not logged in. If this parameter is not specified, + the user will stay on the current page, but be asked to log in using a popup in their browser (HTTP basic + authentication). + - name: password + type: TEXT + description: The password that was sent by the user. You can set this to :password if you have a login + form leading to your page. + - name: password_hash + type: TEXT + description: The hash of the password that you stored for the user that is currently trying to log in. + These hashes can be generated ahead of time using a tool like https://argon2.online/. +--- + +Create pages with password-restricted access. + + +When you want to add user authentication to your SQLPage application, +you have two main options: + +1. The `authentication` component: + - lets you manage usernames and passwords yourself + - does not require any external service + - gives you fine-grained control over + - which pages and actions are protected + - the look of the [login form](?component=login) + - the duration of the session + - the permissions of each user +2. [**Single sign-on**](/sso) + - lets users log in with their existing accounts (like Google, Microsoft, or your organization's own identity provider) + - requires setting up an external service (Google, Microsoft, etc.) + - frees you from implementing a lot of features like password reset, account creation, user management, etc. + +This page describes the first option. + +When used, this component has to be at the top of your page, +because once the page has begun being sent to the browser, +it is too late to restrict access to it. + +The authentication component checks if the user has sent the correct password, +and if not, redirects them to the URL specified in the link parameter. + +If you don't want to re-check the password on every page (which is an expensive operation), +you can check the password only once and store a session token in your database +(see the session example below). + +You can use the [cookie component](?component=cookie) to set the session token cookie in the client browser, +and then check whether the token matches what you stored in subsequent pages. diff --git a/examples/official-site/content/components/big_number.md b/examples/official-site/content/components/big_number.md new file mode 100644 index 000000000..a0b9b96a0 --- /dev/null +++ b/examples/official-site/content/components/big_number.md @@ -0,0 +1,61 @@ +--- +icon: chart-area +since: 0.28.0 +category: display-data +summary: Highlight a metric with a trend or progress indicator. +top: + - class + - name: columns + type: INTEGER + description: The number of columns to display the big numbers in (default is one column per item). + - id + - name: wrap + type: BOOLEAN + description: Wrap long titles and descriptions onto multiple lines. By default, they are truncated with + an ellipsis. +row: + - name: change_percent + type: INTEGER + description: The percentage change in value (e.g., 7 for 7% increase, -8 for 8% decrease). + - class + - name: color + type: COLOR + description: The color of the card background and its main value. + - name: description + type: TEXT + description: A description or additional context for the big number. + - name: dropdown_item + type: JSON + description: A list of JSON objects containing links. e.g. {"label":"This week", "link":"?days=7"} + - id + - name: progress_color + type: TEXT + description: The color of the progress bar (e.g., "primary", "success", "danger"). + - name: progress_percent + type: INTEGER + description: The value of the progress (0-100). + - name: title + type: TEXT + description: The title or label for the big number. + - name: title_link + type: TEXT + description: A link for the Big Number title. If set, the entire title becomes clickable. + - name: title_link_new_tab + type: BOOLEAN + description: If true, the title link will open in a new tab/window. + - name: unit + type: TEXT + description: The unit of measurement for the value. + - name: value + type: TEXT + required: true + description: The main value to be displayed prominently. + - name: value_link + type: TEXT + description: A link for the Big Number value. If set, the entire value becomes clickable. + - name: value_link_new_tab + type: BOOLEAN + description: If true, the value link will open in a new tab/window. +--- + +A component to display key metrics or statistics with optional description, change indicator, and progress bar. Useful in dashboards. diff --git a/examples/official-site/content/components/breadcrumb.md b/examples/official-site/content/components/breadcrumb.md new file mode 100644 index 000000000..4f7630508 --- /dev/null +++ b/examples/official-site/content/components/breadcrumb.md @@ -0,0 +1,26 @@ +--- +icon: dots +since: 0.18.0 +category: navigation +summary: Link the current page to its parent pages. +top: + - class + - id +row: + - name: active + type: TEXT + description: Whether the link is active or not. Defaults to false. + - name: description + type: TEXT + description: Description of the link. This is displayed when the user hovers over the link. + - name: link + type: TEXT + description: Link to the page to display when the link is clicked. By default, the link refers to the current + page, with a 'link' parameter set to the link's title. + - name: title + type: TEXT + required: true + description: Hyperlink text to display. +--- + +A secondary navigation aid that helps users understand their location on a website or mobile application. diff --git a/examples/official-site/content/components/button.md b/examples/official-site/content/components/button.md new file mode 100644 index 000000000..9a8116ec7 --- /dev/null +++ b/examples/official-site/content/components/button.md @@ -0,0 +1,78 @@ +--- +icon: hand-click +since: 0.14.0 +category: forms-and-feedback +summary: Follow a link, download a file, or submit a form. +top: + - class + - name: justify + type: TEXT + description: The horizontal alignment of the button list (e.g., start, end, center, between). + - name: shape + type: TEXT + description: Shape of the buttons (e.g., pill, square) + - name: size + type: TEXT + description: The size of the buttons (e.g., sm, lg). +row: + - name: color + type: COLOR + description: The color of the button (e.g., red, green, blue, but also primary, warning, danger, etc.). + Only base color names are supported, not variations like "blue-lt" or "gray-300". Use a custom CSS stylesheet + to further customize the colors. + - name: disabled + type: BOOLEAN + description: Whether the button is disabled or not. + - name: download + type: TEXT + description: If defined, the link will download the target instead of navigating to it. Set the value to + the desired name of the downloaded file. + - name: form + type: TEXT + description: Identifier (id) of the form to which the button should submit. + - name: icon + type: ICON + description: Name of an icon to be displayed on the left side of the button. + - name: icon_after + type: ICON + description: Name of an icon to display after the text in the button + - name: id + type: TEXT + description: HTML Identifier to add to the button element. + - name: image + type: TEXT + description: Path to image file (relative. relative to web root or URL) to be displayed on the button. + - name: link + type: URL + description: The URL to which the button should navigate when clicked. If the form attribute is specified, + then this overrides the page to which the form is submitted. + - name: modal + type: TEXT + description: Display the modal window corresponding to the specified ID. + - name: narrow + type: BOOLEAN + description: Whether to trim horizontal padding. + - name: outline + type: COLOR + description: Outline color of the button (e.g. red, purple, ...) + - name: rel + type: TEXT + description: '"nofollow" when the contents of the target link are not endorsed, "noopener" when the target + is not trusted, and "noreferrer" to hide where the user came from when they open the link.' + - name: space_after + type: BOOLEAN + description: Whether there should be extra space to the right of the button. In a line of buttons, this + will put the buttons before this one on the left, and the ones after on the right. + - name: target + type: TEXT + description: '"_blank" to open the link in a new tab, "_self" to open it in the same tab, "_parent" to + open it in the parent frame, or "_top" to open it in the full body of the window.' + - name: title + type: TEXT + description: The text displayed on the button. + - name: tooltip + type: TEXT + description: Text displayed when the user hovers over the button. +--- + +Displays one or more buttons that follow links, download files, or submit a form. diff --git a/examples/official-site/content/components/card.md b/examples/official-site/content/components/card.md new file mode 100644 index 000000000..79ab2d0ad --- /dev/null +++ b/examples/official-site/content/components/card.md @@ -0,0 +1,123 @@ +--- +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: 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_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. diff --git a/examples/official-site/content/components/carousel.md b/examples/official-site/content/components/carousel.md new file mode 100644 index 000000000..3a92401fa --- /dev/null +++ b/examples/official-site/content/components/carousel.md @@ -0,0 +1,58 @@ +--- +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: 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. diff --git a/examples/official-site/content/components/chart.md b/examples/official-site/content/components/chart.md new file mode 100644 index 000000000..4af99e84c --- /dev/null +++ b/examples/official-site/content/components/chart.md @@ -0,0 +1,134 @@ +--- +icon: timeline +category: display-data +summary: Plot query results as line, area, bar, or pie charts. +top: + - class + - name: color + type: COLOR + description: The name of a color in which to display the chart. If there are multiple series in the chart, + this parameter can be repeated multiple times. + - name: height + type: INTEGER + description: 'Height of the chart, in pixels. By default: 250' + - name: horizontal + type: BOOLEAN + description: Displays a bar chart with horizontal bars instead of vertical ones. + - id + - name: labels + type: BOOLEAN + description: Whether to show the data labels on the chart or not. + - name: logarithmic + type: BOOLEAN + description: Display the y-axis in logarithmic scale. + - name: marker + type: REAL + description: Marker size + - name: show_legend + type: BOOLEAN + description: Whether to display the legend listing all chart series. Defaults to true. + - name: stacked + type: BOOLEAN + description: Whether to cumulate values from different series. Supported by the "line", "area" and "bar" + chart types, and ignored by the others. Series are aligned on their x values, and a series that has no + value for a given x counts as zero there. + - name: time + type: BOOLEAN + description: Whether the x-axis represents time. If set to true, the x values will be parsed and formatted + as dates for the user. + - name: title + type: TEXT + description: The name of the chart. + - name: toolbar + type: BOOLEAN + description: Whether to display a toolbar at the top right of the chart, that offers downloading the data + as CSV. + - name: type + type: TEXT + required: true + description: 'The type of chart. One of: "line", "area", "bar", "column", "pie", "scatter", "bubble", "heatmap", + "rangeBar". "column" is a synonym of "bar".' + - name: xmax + type: TEXT + description: The maximum value for the x-axis. When time is true, this can be a date or timestamp. + - name: xmin + type: TEXT + description: The minimal value for the x-axis. When time is true, this can be a date or timestamp. + - name: xticks + type: INTEGER + description: Number of intervals used to generate a numeric x-axis, normally producing one more tick position. + On category and time axes, this is a target for label density, so the visible label count may differ. + - name: xtitle + type: TEXT + description: Title of the x axis, displayed below it. + - name: ymax + type: REAL + description: The maximum value for the y-axis. + - name: ymin + type: REAL + description: The minimal value for the y-axis. + - name: ystep + type: REAL + description: Step between ticks on the y axis. + - name: yticks + type: INTEGER + description: Number of ticks on the y axis. + - name: ytitle + type: TEXT + description: Title of the y axis, displayed to its left. + - name: ztitle + type: TEXT + description: Title of the z axis, displayed in tooltips. +row: + - name: color + type: COLOR + description: 'The name of a color for what this row draws: the bar, slice or point it plots, or the reference + line it draws. Defaults to the color of the series for a data point, and to grey for a reference line.' + - name: label + type: TEXT + description: An alias for parameter "x". On a row that draws a reference line, the text to display next + to the line. Labels are plain text; HTML markup is displayed literally. + - name: link + type: URL + description: A URL to open when the data point is clicked. The tooltip value also links to the point, as + does a text x value when shown as the tooltip title. + - name: series + type: TEXT + description: If multiple series are represented and share the same y-axis, this parameter can be used to + distinguish between them. Series names are plain text; HTML markup is displayed literally. + - name: value + type: REAL + description: An alias for parameter "y" + - name: x + type: REAL + required: true + description: The value of the point on the horizontal axis. Numeric values use continuous, proportionate + positioning; text values are evenly spaced categories. Set the top-level time property for dates and + timestamps. + - name: xline + type: TEXT + description: Draws a reference line across the chart at this position of the x axis instead of plotting + a point, to mark an event such as a deployment. A date or a timestamp when time is set, otherwise one + of the x values. + - name: xline_end + type: TEXT + description: Makes the xline a band instead of a line, reaching to this value. + - name: y + type: REAL + required: true + description: The value of the point on the vertical axis + - name: yline + type: REAL + description: Draws a reference line across the chart at this value of the y axis instead of plotting a + point, to show a limit such as a quota or an alarm threshold. Not drawn if it falls outside of the axis, + so set ymax when the limit is above the data. + - name: yline_end + type: REAL + description: Makes the yline a band instead of a line, reaching to this value. + - name: z + type: REAL + description: A third value carried by the point. Used as the bubble radius in a bubble chart, and shown + in the tooltip under the name given by the top-level "ztitle". +--- + +A component that plots data. Line, area, bar, and pie charts are all supported. Each item in the component is a data point in the graph. diff --git a/examples/official-site/content/components/code.md b/examples/official-site/content/components/code.md new file mode 100644 index 000000000..677e403ed --- /dev/null +++ b/examples/official-site/content/components/code.md @@ -0,0 +1,29 @@ +--- +icon: code +since: 0.19.0 +category: page-layout +summary: Display source code with syntax highlighting. +top: + - class + - id +row: + - name: contents + type: TEXT + required: true + description: A block of code. + - name: description + type: TEXT + description: Description of the snipet of code. + - name: description_md + type: TEXT + description: Rich text in the markdown format. Among others, this allows you to write bold text using `**bold**`, + italics using `*italics*`, and links using `[text](https://example.com)`. + - name: language + type: TEXT + description: Set the programming language name. + - name: title + type: TEXT + description: Set the heading level (default level is 1) +--- + +Displays one or many blocks of code from a programming language or formated text as XML or JSON. diff --git a/examples/official-site/content/components/columns.md b/examples/official-site/content/components/columns.md new file mode 100644 index 000000000..d23fbc6b4 --- /dev/null +++ b/examples/official-site/content/components/columns.md @@ -0,0 +1,52 @@ +--- +icon: columns +since: 0.29.0 +category: page-layout +summary: Compare plans, features, or options in side-by-side cards. +row: + - name: button_color + type: TEXT + description: Optional color for the button. + - name: button_text + type: TEXT + description: Text for the button. + - name: description + type: TEXT + description: A brief description of the item. + - name: description_md + type: TEXT + description: A brief description of the item, formatted using markdown. + - name: icon + type: ICON + description: Optional icon to display in a ribbon. + - name: icon_color + type: TEXT + description: Color for the icon in the ribbon. + - name: item + type: JSON + description: A list of bullet points associated with the columns, represented either as text, or as a json + object with "icon", "color", and "description" or "description_md" fields. + - name: link + type: TEXT + description: A link associated with the item. + - name: size + type: INTEGER + description: Size of the column, affecting layout. + - name: small_text + type: TEXT + description: Optional small text to display after the value. + - name: target + type: TEXT + description: Optional target for the button. Set to "_blank" to open links in a new tab. + - name: title + type: TEXT + description: The title or label for the item. + - name: value + type: TEXT + description: The value associated with the item. + - name: value_color + type: TEXT + description: Color for the value text. +--- + +A component to display various items in a card layout, allowing users to choose options. Useful for showcasing different features or services, or KPIs. See also the big_number component. diff --git a/examples/official-site/content/components/cookie.md b/examples/official-site/content/components/cookie.md new file mode 100644 index 000000000..4b5076d36 --- /dev/null +++ b/examples/official-site/content/components/cookie.md @@ -0,0 +1,54 @@ +--- +icon: cookie +category: http-responses +summary: Set a cookie in the visitor's browser. +top: + - name: domain + type: TEXT + description: The domain for which the cookie will be sent. If not specified, the cookie will be sent for + all domains. + - name: expires + type: TIMESTAMP + description: The date at which the cookie expires (either a timestamp or a date object). If not specified, + the cookie will expire when the browser is closed. + - name: http_only + type: BOOLEAN + description: Whether the cookie should only be accessible via HTTP and not via client-side scripts. If + explicitly set to false, the cookie will be accessible via both HTTP and client-side scripts. + - name: max_age + type: INTEGER + description: The maximum age of the cookie in seconds. number of seconds until the cookie expires. If both + Expires and Max-Age are set, Max-Age has precedence. + - name: name + type: TEXT + required: true + description: The name of the cookie to set. + - name: path + type: TEXT + description: The path for which the cookie will be sent. If not specified, the cookie will be sent for + all paths. + - name: remove + type: BOOLEAN + description: Set to TRUE to remove the cookie from the client browser. When specified, other parameters + are ignored. + - name: same_site + type: TEXT + description: Whether the cookie should only be sent for requests originating from the same site. See owasp.org/www-community/SameSite. + `strict` is the recommended and default value, but you may want to set it to `lax` if you want your users + to keep their session when they click on a link to your site from an external site. + - name: secure + type: BOOLEAN + description: Whether the cookie should only be sent over a secure (HTTPS) connection. Defaults to TRUE. + - name: value + type: TEXT + description: The value of the cookie to set. +--- + +Sets a cookie in the client browser, used for session management and storing user-related information. + +This component creates a single cookie. Since cookies need to be set before the response body is sent to the client, +this component should be **placed at the top of the page**, before any other components that generate output. + +After being set, a cookie can be accessed anywhere in your SQL code using the `sqlpage.cookie('cookie_name')` pseudo-function. + +Note that if your site is accessed over HTTP (and not HTTPS), you have to set `false as secure` to force browsers to accept your cookies. diff --git a/examples/official-site/content/components/csv.md b/examples/official-site/content/components/csv.md new file mode 100644 index 000000000..61481c179 --- /dev/null +++ b/examples/official-site/content/components/csv.md @@ -0,0 +1,43 @@ +--- +icon: download +category: http-responses +summary: Export query rows as a downloadable CSV file. +top: + - name: bom + type: BOOLEAN + description: Whether to include a Byte Order Mark (a special character indicating the character encoding) + at the beginning of the file. This is useful for Excel compatibility. + - class + - name: color + type: COLOR + description: Color of the button. Ignored when used as a header component. + - name: filename + type: TEXT + description: The name of the file that should be downloaded (without the extension). + - name: icon + type: ICON + description: Name of the icon (from tabler-icons.io) to display in the button. Ignored when used as a header + component. + - id + - name: separator + type: TEXT + description: How individual values should be separated in the CSV. "," by default, set it to "\t" for tab-separated + values. + - name: size + type: TEXT + description: The size of the button (e.g., sm, lg). Ignored when used as a header component. + - name: title + type: TEXT + required: true + description: The text displayed on the download button. +--- + +Lets the user download data as a CSV file. +Each column from the items in the component will map to a column in the resulting CSV. + +When `csv` is used as a **header component** (without a [shell](?component=shell)), it will trigger a download of the CSV file directly on page load. +If the csv file to download is large, we recommend using this approach. + +When used inside a page (after calling the shell component), this will add a button to the page that lets the user download the CSV file. +The button will need to load the entire contents of the CSV file in memory, inside the browser, even if the user does not click on it. +If the csv file to download is large, we recommend using this component without a shell component in order to efficiently stream the data to the browser. diff --git a/examples/official-site/content/components/datagrid.md b/examples/official-site/content/components/datagrid.md new file mode 100644 index 000000000..c29817693 --- /dev/null +++ b/examples/official-site/content/components/datagrid.md @@ -0,0 +1,55 @@ +--- +icon: grid-dots +category: display-data +summary: Lay out labeled values in a compact grid. +top: + - class + - 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: icon + type: ICON + description: Name of an icon to display on the left side of the title. + - id + - name: image_url + type: URL + description: URL of an image to display on the left side of the title. + - name: title + type: TEXT + description: Text header at the top of the data grid. +row: + - name: active + type: BOOLEAN + description: Whether this item in the grid is considered "active". Active items are displayed more prominently. + - name: color + type: COLOR + description: If set to a color name, the value will be displayed in a pill of that color. + - name: description + type: TEXT + description: Value to display below the name. + - name: footer + type: TEXT + description: Muted text to display below the value. + - name: icon + type: ICON + description: An icon name (from tabler-icons.io) to display on the left side of the value. + - id + - name: image_url + type: URL + description: URL of a small image (such as an avatar) to display on the left side of the value. + - name: link + type: URL + description: A target URL to which the user should be taken when they click on the value. + - name: title + type: TEXT + required: true + description: Name of the piece of information. + - name: tooltip + type: TEXT + description: A tooltip to display when the user passes their mouse over the value. +--- + +Display small pieces of information in a clear and readable way. Each item has a name and is associated with a value. diff --git a/examples/official-site/content/components/debug.md b/examples/official-site/content/components/debug.md new file mode 100644 index 000000000..1d4d1732f --- /dev/null +++ b/examples/official-site/content/components/debug.md @@ -0,0 +1,9 @@ +--- +icon: bug +category: server-logic +summary: Inspect the values passed to a component as JSON. +--- + +Visualize any set of values as JSON. +Can be used to display all the parameters passed to the component. +Useful for debugging: just replace the name of the component you want to debug with 'debug', and see all the top-level and row-level parameters that are passed to it, and their types. diff --git a/examples/official-site/content/components/divider.md b/examples/official-site/content/components/divider.md new file mode 100644 index 000000000..f68c22c66 --- /dev/null +++ b/examples/official-site/content/components/divider.md @@ -0,0 +1,34 @@ +--- +icon: separator +since: 0.18.0 +category: page-layout +summary: Separate sections with a horizontal rule. +top: + - name: bold + type: BOOLEAN + description: Whether the text is bold. + - class + - name: color + type: COLOR + description: The name of a color for this span of text. + - name: contents + type: TEXT + description: A text in the divider. + - name: italics + type: BOOLEAN + description: Whether the text is italicized. + - name: link + type: URL + description: URL of the link for the divider text. Available only when contents is present. + - name: position + type: TEXT + description: Position of the text (e.g. left, right). + - name: size + type: INTEGER + description: The size of the divider text, from 1 to 6. + - name: underline + type: BOOLEAN + description: Whether the text is underlined. +--- + +Dividers help organize content and make the interface layout clear and uncluttered. diff --git a/examples/official-site/content/components/download.md b/examples/official-site/content/components/download.md new file mode 100644 index 000000000..10a36ef7a --- /dev/null +++ b/examples/official-site/content/components/download.md @@ -0,0 +1,48 @@ +--- +icon: download +since: 0.37.0 +category: http-responses +summary: Send a file directly to the visitor. +top: + - name: data_url + type: TEXT + required: true + description: 'The file content to send, written as a data URL (for example: data:text/plain,Hello%20world + or data:application/octet-stream;base64,SGVsbG8h). The part before the comma declares the content type + and whether the data is base64-encoded. The part after the comma is the actual data.' + - name: filename + type: TEXT + description: 'The suggested name of the file to save (for example: report.csv). When set, the browser will + download the file as an attachment with this name. When omitted, many browsers may try to display the + file inline depending on its content type.' +--- + +The *download* component lets a page immediately return a file to the visitor. + +Instead of showing a web page, it sends the file's bytes as the whole response, +so it should be used **at the very top of your SQL page** (before the shell or any other page contents). +It is an error to use this component after another component that would display content. + +## Sending a file + +- You provide the file content using a [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs). +A data URL is just a text string that contains both the file type and the actual data. +- Optionally, you provide a "filename" so the browser shows a proper Save As name. +If you do not provide a filename, many browsers will try to display the file inline (for example images or JSON), depending on the content type. +- You link to the page that uses the download component from another page, using the [button](/component.sql?component=button) component for example. + +## Data URL format + +- It looks like this: `data:[content-type][;base64],DATA` +- Examples: + - Plain text (URL-encoded): `data:text/plain,Hello%20world` + - JSON (URL-encoded): `data:application/json,%7B%22message%22%3A%22Hi%22%7D` + - Binary data (Base64): `data:application/octet-stream;base64,SGVsbG8h` + +Tips: +- Use URL encoding when you have textual data. You can use [`sqlpage.url_encode(source_text)`](/functions?function=url_encode) to encode the data. +- Use Base64 when you have binary data (images, PDFs, or content that may include special characters). +- Use [`sqlpage.read_file_as_data_url(file_path)`](/functions?function=read_file_as_data_url) to read a file from the server and return it as a data URL. + +> Keep in mind that large files are better served from disk or object storage. Data URLs are best for small to medium files. +There is a big performance penalty for loading large files as data URLs, so it is not recommended. diff --git a/examples/official-site/content/components/dynamic.md b/examples/official-site/content/components/dynamic.md new file mode 100644 index 000000000..69246e50d --- /dev/null +++ b/examples/official-site/content/components/dynamic.md @@ -0,0 +1,13 @@ +--- +icon: repeat +category: server-logic +summary: Render SQLPage components described by JSON data. +top: + - name: properties + type: JSON + description: A json object or array that contains the names and properties of other components. +--- + +Renders other components, given their properties as JSON. +If you are looking for a way to run FOR loops, to share similar code between pages of your site, +or to render multiple components for every line returned by your SQL query, then this is the component to use diff --git a/examples/official-site/content/components/empty_state.md b/examples/official-site/content/components/empty_state.md new file mode 100644 index 000000000..8b511fe90 --- /dev/null +++ b/examples/official-site/content/components/empty_state.md @@ -0,0 +1,46 @@ +--- +icon: info-circle +since: 0.35.0 +category: forms-and-feedback +summary: Explain an empty view and offer the reader a next step. +top: + - class + - name: description + type: TEXT + description: A short text displayed below the title. + - name: description_md + type: TEXT + description: A short text displayed below the title, formatted using markdown. + - name: header + type: TEXT + description: Text displayed on the top of the empty state. + - name: icon + type: ICON + description: Name of an icon to be displayed on the top of the empty state. + - id + - name: image + type: URL + description: The URL (absolute or relative) of an image to display at the top of the empty state. + - name: link + type: URL + required: true + description: The URL to which the button should navigate when clicked. + - name: link_icon + type: ICON + required: true + description: Name of an icon to be displayed on the left side of the button. + - name: link_text + type: TEXT + required: true + description: The text displayed on the button. + - name: title + type: TEXT + required: true + description: Description of the empty state. +--- + +Displays a large placeholder message to communicate a single information to the user and invite them to take action. + +Typically includes a title, an optional icon/image, descriptive text (rich text formatting and images supported via Markdown), and a call-to-action button. + +Ideal for first-use screens, empty data sets, "no results" pages, or error messages. diff --git a/examples/official-site/content/components/facet.md b/examples/official-site/content/components/facet.md new file mode 100644 index 000000000..4ecbfbe22 --- /dev/null +++ b/examples/official-site/content/components/facet.md @@ -0,0 +1,74 @@ +--- +icon: filter +since: 0.46.0 +category: navigation +summary: Let readers choose filters for a dataset. +top: + - name: all_active + type: BOOLEAN + description: Whether the link that clears the filter is active. Defaults to false. + - name: all_link + type: URL + description: URL that clears the filter. If omitted, no All link is displayed. + - name: all_title + type: TEXT + description: Text for the link that clears the filter. Defaults to "ALL". + - name: center + type: BOOLEAN + description: Whether to center the facet selector + - class + - name: compact + type: BOOLEAN + description: Displays the facets in a dropdown instead of links. + - name: description + type: TEXT + description: The facet category label. + - name: dropdown_title + type: TEXT + description: Text shown on the compact-mode dropdown button when no facet is selected. Defaults to `Choose + facet`. + - id + - name: selected_facet + type: TEXT + description: An alias for `dropdown_title`. +row: + - name: active + type: BOOLEAN + description: Whether the link is active or not. Defaults to false. + - name: link + type: URL + required: true + description: URL for the facet. + - name: title + type: TEXT + required: true + description: Facet title. +--- + +Navigation links for filtering a dataset by a category, status, owner, or other attribute. + +This component only renders the filter navigation. **Your SQL query is responsible for filtering the data** based on the URL parameter selected by the user. + +Use it alongside a [table](?component=table), [list](?component=list), or [card](?component=card). The links use GET parameters, so the selected filter can be bookmarked and shared. + +Set `compact` to display the facets in a dropdown, which is useful for a moderate number of choices or on narrow screens. Use `selected_facet` to show the active facet in the closed dropdown. `all_link` and `all_title` add a link that clears the filter. + +The following portable pattern filters a table by category. `sqlpage.link` preserves the current page path while safely generating the URL. + +```sql +select 'table' as component; +select title, category +from my_table +where $category is null or category = $category; + +select 'facet' as component, + 'Category' as description, + sqlpage.link(sqlpage.path(), json_object('category', null)) as all_link, + $category is null as all_active; +select category as title, + sqlpage.link(sqlpage.path(), json_object('category', category)) as link, + category = $category as active +from my_table +group by category +order by category; +``` diff --git a/examples/official-site/content/components/foldable.md b/examples/official-site/content/components/foldable.md new file mode 100644 index 000000000..feccb9a1a --- /dev/null +++ b/examples/official-site/content/components/foldable.md @@ -0,0 +1,37 @@ +--- +icon: chevrons-down +since: 0.29.0 +category: page-layout +summary: Let readers expand individual sections to see their contents. +top: + - name: class + type: TEXT + description: CSS class(es) to add to the foldable container. When set at the top level, applies to the + entire foldable component. + - name: id + type: TEXT + description: ID attribute added to the container in HTML. Used for targeting through CSS or for scrolling + via links. When set at the top level, applies to the entire foldable component. +row: + - name: class + type: TEXT + description: CSS class(es) to add to individual foldable items. + - name: description + type: TEXT + description: Plain text description of the item, displayed when expanded. + - name: description_md + type: TEXT + description: Markdown description of the item, displayed when expanded. + - name: expanded + type: BOOLEAN + description: If set to TRUE, the foldable item starts in an expanded state. Defaults FALSE + - name: id + type: TEXT + description: ID attribute added to individual foldable items. Used for targeting through CSS or for scrolling + via links. + - name: title + type: TEXT + description: Title of the foldable item, displayed on the button. +--- + +A foldable list of elements which can be expanded individually. diff --git a/examples/official-site/content/components/form.md b/examples/official-site/content/components/form.md new file mode 100644 index 000000000..6a496178b --- /dev/null +++ b/examples/official-site/content/components/form.md @@ -0,0 +1,257 @@ +--- +icon: cursor-text +category: forms-and-feedback +summary: Collect input with text fields, file uploads, and other controls. +top: + - name: action + type: TEXT + description: An optional link to a target page that will handle the results of the form. By default the + target page is the current page with the id of the form (if passed) used as hash - this will bring us + back to the location of the form after submission. Setting it to the name of a different sql file will + load that file when the user submits the form. + - name: auto_submit + type: BOOLEAN + description: Automatically submit the form when the user changes any of its fields, and remove the validation + button. + - class + - name: enctype + type: TEXT + description: |2 + + When ``method="post"``, this specifies how the form-data should be encoded + when submitting it to the server. + - name: id + type: TEXT + description: A unique identifier for the form, which can then be used to validate the form from a button + outside of the form. + - name: method + type: TEXT + description: Set this to 'GET' to pass the form contents directly as URL parameters. If the user enters + a value v in a field named x, submitting the form will load target.sql?x=v. If target.sql contains SELECT + $x, it will display the value v. + - name: narrow + type: BOOLEAN + description: Whether to trim the horizontal padding between the icon and the label of the validation and + reset buttons. + - name: reset + type: TEXT + description: The text to display in the button at the bottom of the form that resets the form to its original + state. Omit this property not to show a reset button at all. + - name: reset_color + type: COLOR + description: The color of the button at the bottom of the form that resets the form to its original state. + Omit this property to use the default color. + - name: reset_icon + type: ICON + description: Name of an icon to be displayed on the left side of the reset button. + - name: reset_outline + type: COLOR + description: A color to outline the reset button. + - name: reset_shape + type: TEXT + description: The shape of the reset button (e.g., pill, square). + - name: reset_size + type: TEXT + description: The size of the reset button (e.g., sm, lg). + - name: title + type: TEXT + description: A name to display at the top of the form. It will be displayed in a larger font size at the + top of the form. + - name: validate + type: TEXT + description: The text to display in the button at the bottom of the form that submits the values. Omit + this property to let the browser display the default form validation text, or set it to the empty string + to remove the button completely. + - name: validate_color + type: COLOR + description: The color of the button at the bottom of the form that submits the values. Omit this property + to use the default color. + - name: validate_icon + type: ICON + description: Name of an icon to be displayed on the left side of the submit button. + - name: validate_outline + type: COLOR + description: A color to outline the validation button. + - name: validate_shape + type: TEXT + description: The shape of the validation button (e.g., pill, square). + - name: validate_size + type: TEXT + description: The size of the validation button (e.g., sm, lg). +row: + - name: accept + type: TEXT + description: Used only for inputs of type "file". A comma-separated list of the file types the user can + pick, given as extensions (".pdf,.png") or as MIME types ("image/*"). + - name: autocomplete + type: BOOLEAN + description: Whether the browser should suggest previously entered values for this field. + - name: autofocus + type: BOOLEAN + description: Automatically focus the field when the page is loaded + - name: checked + type: BOOLEAN + description: Used only for checkboxes and radio buttons. Indicates whether the checkbox should appear as + already checked. + - name: class + type: TEXT + description: A CSS class to apply to the form element. + - name: create_new + type: BOOLEAN + description: In a multiselect with a dropdown, this option allows the user to enter new values, that are + not in the list of options. + - name: description + type: TEXT + description: A helper text to display near the input field. + - name: description_md + type: TEXT + description: A helper text to display near the input field - formatted using markdown. + - name: disabled + type: BOOLEAN + description: Makes the field non-editable, non-focusable, and not submitted with the form. Use readonly + instead for simple non-editable fields. + - name: dropdown + type: BOOLEAN + description: An alias for "searchable". + - name: empty_option + type: TEXT + description: Only for inputs of type `select`. Adds an empty option with the given label before the ones + defined in `options`. Useful when generating other options from a database table. + - name: formaction + type: TEXT + description: When type is "submit", this specifies the URL of the file that will handle the form submission. + Useful when you need multiple submit buttons. + - name: formenctype + type: TEXT + description: |2 + + When ``type`` is ``submit`` or ``image``, this specifies how the form-data + should be encoded when submitting it to the server. + + Takes precedence over any ``enctype`` set on the ``form`` element. + + NOTE: when a ``file`` type input is present, then ``formenctype="multipart/form-data"`` + is automatically applied to the default validate button. + - name: formmethod + type: TEXT + description: When type is "submit", the HTTP method to submit the form with. Takes precedence over the + form's own "method". + - name: formnovalidate + type: BOOLEAN + description: When type is "submit", skips the browser's validation of the other fields when this button + submits the form. + - name: formtarget + type: TEXT + description: 'When type is "submit", where to display the response. Takes the same values as a link target: + "_blank" to open a new tab, "_self" to stay in the same one.' + - name: id + type: TEXT + description: A unique identifier for the input, which can then be used to select and manage the field with + Javascript code. Usefull for advanced using as setting client side event listeners, interactive control + of input field (disabled, visibility, read only, e.g.) and AJAX requests. + - name: label + type: TEXT + description: A friendly name for the text field to show to the user. + - name: list + type: TEXT + description: The id of a datalist element holding the suggestions to show for this field. The datalist + itself has to be rendered by the "html" component. + - name: max + type: REAL + description: The maximum value to accept for an input of type number + - name: maxlength + type: INTEGER + description: Maximum length of text allowed in the field. + - name: min + type: REAL + description: The minimum value to accept for an input of type number + - name: minlength + type: INTEGER + description: Minimum length of text allowed in the field. + - name: multiple + type: BOOLEAN + description: 'For select elements, indicates that multiple elements can be selected simultaneously. When + using multiple, you should add square brackets after the variable name: ''my_variable[]'' as name. For + file inputs, lets the user select several files at once: save them all with [sqlpage.persist_uploaded_files](functions.sql?function=persist_uploaded_files).' + - name: name + type: TEXT + required: true + description: The name of the input field, that you can use in the target page to get the value the user + entered for the field. + - name: options + type: JSON + description: A json array of objects containing the label and value of initial options of a select field. + Used only when type=select. JSON objects in the array can contain the properties "label", "value" and + "selected". + - name: options_source + type: URL + description: Only for inputs of type `select`. URL of a SQL file that returns JSON search results for the + dropdown. The SQL file receives the search text as `$search` and must return an array of objects with + exactly `label` and `value`. Use `options` for options that should be available before the user searches. + - name: pattern + type: TEXT + description: A regular expression that the value must match. For instance, [0-9]{3} will only accept 3 + digits. + - name: placeholder + type: TEXT + description: A placeholder text that will be shown in the field when is is empty. + - name: prefix + type: TEXT + description: Text to display on the left side of the input field, on the same line. + - name: prefix_icon + type: ICON + description: Icon to display on the left side of the input field, on the same line. + - name: readonly + type: BOOLEAN + description: Set to true to prevent the user from modifying the value of the input field. + - name: required + type: BOOLEAN + description: Set this to true to prevent the form contents from being sent if this field is left empty + by the user. + - name: rows + type: INTEGER + description: Number of rows to display for a textarea. Defaults to 3. + - name: searchable + type: BOOLEAN + description: For select and multiple-select elements, displays them with a nice dropdown that allows searching + for options. + - name: step + type: REAL + description: The increment of values in an input of type number. Set to 1 to allow only integers. + - name: suffix + type: TEXT + description: Short text to display after th input, on the same line. Useful to add units or a currency + symbol to an input. + - name: type + type: TEXT + description: 'Declares input control behavior and expected format. All HTML input types are supported (text, + number, date, file, checkbox, radio, hidden, ...). SQLPage adds some custom types: textarea, switch, + header. text by default. See https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#input_types' + - name: value + type: TEXT + description: A default value that will already be present in the field when the user loads the page. + - name: width + type: INTEGER + description: Width of the form field, between 1 and 12. +--- + +## Building forms in SQL + +The form component will display a series of input fields of various types, that can be filled in by the user. +When the user submits the form, the data is posted to an SQL file specified in the `action` property. + +### Handling submitted values + +The receiving SQL page will be able to handle the data, +and insert it into the database, use it to perform a search, format it, update existing data, etc. + +A value in a field named "x" will be available as `:x` in the SQL query of the target page. + +### Form projects + + - [A multi-step form](https://github.com/sqlpage/SQLPage/tree/main/examples/forms-with-multiple-steps), guiding the user through a process without overwhelming them with a large form. + - [File upload form](https://github.com/sqlpage/SQLPage/tree/main/examples/image%20gallery%20with%20user%20uploads), letting users upload images to a gallery. + - [Rich text editor](https://github.com/sqlpage/SQLPage/tree/main/examples/rich-text-editor), letting users write text with bold, italics, links, images, etc. + - [Master-detail form](https://github.com/sqlpage/SQLPage/tree/main/examples/master-detail-forms), to edit a list of structured items. + - [Form with a variable number of fields](https://github.com/sqlpage/SQLPage/tree/main/examples/forms%20with%20a%20variable%20number%20of%20fields), when the fields are not known in advance. + - [Demo of all input types](/examples/form), showing all the input types supported by SQLPage. diff --git a/examples/official-site/content/components/hero.md b/examples/official-site/content/components/hero.md new file mode 100644 index 000000000..7b0009b55 --- /dev/null +++ b/examples/official-site/content/components/hero.md @@ -0,0 +1,70 @@ +--- +icon: home +category: page-layout +summary: Introduce a page with a headline, media, and a call to action. +top: + - name: autoplay + type: BOOLEAN + description: Automatically start playing the video + - name: description + type: TEXT + description: A description of the page. Displayed below the title, in smaller characters and slightly greyed + out. + - name: description_md + type: TEXT + description: A description of the page. Displayed below the title, in smaller characters and slightly greyed + out - formatted using markdown. + - id + - name: image + type: URL + description: The URL of an image to display next to the page title. + - name: link + type: URL + description: Creates a large "call to action" button below the description, linking to the specified URL. + - name: link_text + type: TEXT + description: The text to display in the call to action button. Defaults to "Go". + - name: loop + type: BOOLEAN + description: Loop the video + - name: muted + type: BOOLEAN + description: Mute the video + - name: nocontrols + type: BOOLEAN + description: Hide the video controls (play, pause, volume, etc.), and autoplay the video. + - name: poster + type: URL + description: URL of the image to be displayed before the video starts. Ignored if no video is present. + - name: reverse + type: BOOLEAN + description: 'Reverse the order of the image and text: the image will be on the left, and the text on the + right. On small screens, the image will be above the text.' + - name: title + type: TEXT + description: The title of your page. Will be shown in very large characters at the top. + - name: video + type: URL + description: The URL of a video to display next to the page title. +row: + - name: color + type: COLOR + description: Color of the badge behind the feature section's icon. Defaults to "success". + - name: description + type: TEXT + description: Description of the feature section. + - name: description_md + type: TEXT + description: Description of the feature section - formatted using markdown. + - name: icon + type: ICON + description: Icon of the feature section. + - name: link + type: TEXT + description: An URL to which the user should be taken when they click on the section title. + - name: title + type: TEXT + description: The name of a single feature section highlighted by this hero. +--- + +Display a large title and description for your page, with an optional large illustrative image. Useful in your home page, for instance. diff --git a/examples/official-site/content/components/html.md b/examples/official-site/content/components/html.md new file mode 100644 index 000000000..37f8e419c --- /dev/null +++ b/examples/official-site/content/components/html.md @@ -0,0 +1,29 @@ +--- +icon: html +since: 0.25.0 +category: page-layout +summary: Insert your own HTML markup into the page. +top: + - name: html + type: TEXT + description: Raw HTML content to include in the page. This will not be sanitized or escaped. If you include + content from an untrusted source, your page will be vulnerable to cross-site scripting attacks. +row: + - name: html + type: TEXT + description: Raw HTML content to include in the page. This will not be sanitized or escaped. If you include + content from an untrusted source, your page will be vulnerable to cross-site scripting attacks. + - name: post_html + type: TEXT + description: Raw HTML content to include after the text content. This will not be sanitized or escaped. + If you include content from an untrusted source, your page will be vulnerable to cross-site scripting + attacks. + - name: text + type: TEXT + description: Text content to include in the page. This will be sanitized and escaped. Use this property + to include user-generated content that should not contain HTML tags. +--- + +Include raw HTML in the output. For advanced users only. Use this component to create complex layouts or to include external content. + Be very careful when using this component with user-generated content, as it can lead to security vulnerabilities. + Use this component only if you are familiar with the security implications of including raw HTML, and understand the risks of cross-site scripting (XSS) attacks. diff --git a/examples/official-site/content/components/http_header.md b/examples/official-site/content/components/http_header.md new file mode 100644 index 000000000..0c56e47d8 --- /dev/null +++ b/examples/official-site/content/components/http_header.md @@ -0,0 +1,44 @@ +--- +icon: world-www +category: http-responses +summary: Set response headers for caching, content types, and more. +top: + - name: Access-Control-Allow-Origin + type: TEXT + description: Specifies which origins are allowed to access the resource in a cross-origin request, used + for implementing Cross-Origin Resource Sharing (CORS). + - name: Cache-Control + type: TEXT + description: Directives for how long the page should be cached by the browser. Set this to max-age=N to + keep the page in cache for N seconds. + - name: Content-Disposition + type: TEXT + description: Provides instructions on how the response content should be displayed or handled by the client, + such as inline or as an attachment. + - name: Location + type: TEXT + description: Specifies the URL to redirect the client to, usually used in 3xx redirection responses. + - name: Set-Cookie + type: TEXT + description: Sets a cookie in the client browser, used for session management and storing user-related + information. +--- + +An advanced component to set arbitrary HTTP headers: can be used to set a custom caching policy to your pages, or implement custom redirections, for example. +If you are a beginner, you probably don't need this component. + +When used, this component has to be the first component in the page, because once the page is sent to the browser, it is too late to change the headers. + +HTTP headers are additional pieces of information sent with responses to web requests that provide instructions +or metadata about the data being sent — for example, +setting cache control directives to control caching behavior +or specifying the content type of a response. + +Any valid HTTP header name can be used as a top-level parameter for this component. +The examples shown here are just that, examples; and you can create any custom header +if needed simply by declaring it. + +If your header's name contains a dash or any other special character, +you will have to use your database's quoting mechanism to declare it. +In standard SQL, you can use double quotes to quote identifiers (like "X-My-Header"), +in Microsoft SQL Server, you can use square brackets (like [X-My-Header]). diff --git a/examples/official-site/content/components/json.md b/examples/official-site/content/components/json.md new file mode 100644 index 000000000..81c48edce --- /dev/null +++ b/examples/official-site/content/components/json.md @@ -0,0 +1,39 @@ +--- +icon: code +since: 0.9.0 +category: http-responses +summary: Return query results as JSON for an API. +top: + - name: contents + type: TEXT + description: A single JSON payload to send. You can use your database's built-in json functions to build + the value to enter here. If not provided, the contents will be taken from the next SQL statements and + rendered as a JSON array. + - name: type + type: TEXT + description: |- + The type of the JSON payload to send: "array", "jsonlines", or "sse". + In "array" mode, each query result is rendered as a JSON object in a single top-level array. + In "jsonlines" mode, results are rendered as JSON objects in separate lines, without a top-level array. + In "sse" mode, results are rendered as JSON objects in separate lines, prefixed by "data: ", which allows you to read the results as server-sent events in real-time from javascript. +--- + +Converts SQL query results into the JSON machine-readable data format. Ideal to quickly build APIs for interfacing with external systems. + +**JSON** is a widely used data format for programmatic data exchange. +For example, you can use it to integrate with web services written in different languages, +with mobile or desktop apps, or with [custom client-side components](/custom_components.sql) inside your SQLPage app. + +Use it when your application needs to expose data to external systems. +If you only need to render standard web pages, +and do not need other software to access your data, +you can ignore this component. + +This component **must appear at the top of your SQL file**, before any other data has been sent to the browser. +An HTTP response can have only a single datatype, and it must be declared in the headers. +So if you have already called the `shell` component, or another traditional HTML component, +you cannot use this component in the same file. + +SQLPage can also return JSON or JSON Lines when the incoming request says it prefers them with an HTTP `Accept` header, so the same `/users.sql` page can show a table in a browser but return raw data to `curl -H "Accept: application/json" http://localhost:8080/users.sql`. + +Use this component when you want to control the payload or force JSON output even for requests that would normally get HTML. diff --git a/examples/official-site/content/components/list.md b/examples/official-site/content/components/list.md new file mode 100644 index 000000000..253463b6e --- /dev/null +++ b/examples/official-site/content/components/list.md @@ -0,0 +1,73 @@ +--- +icon: list +category: display-data +summary: Present rows as a vertical list with optional links and icons. +top: + - class + - name: compact + type: BOOLEAN + description: Whether to display the list in a more compact format, allowing more items to be displayed + on the screen. + - name: empty_description + type: TEXT + description: Description to display if the list is empty. + - name: empty_description_md + type: TEXT + description: Description to display if the list is empty, in Markdown format. + - name: empty_link + type: URL + description: URL to which the user should be taken if they click on the empty list. + - name: empty_title + type: TEXT + description: Title text to display if the list is empty. + - id + - name: title + type: TEXT + description: Text header at the top of the list. + - name: wrap + type: BOOLEAN + description: Wrap list items onto multiple lines if they are too long +row: + - name: active + type: BOOLEAN + description: Whether this item in the list is considered "active". Active items are displayed more prominently. + - class + - name: color + type: COLOR + description: The name of a color, to be displayed as a dot near the list item contents. + - name: delete_link + type: URL + description: A page that will be loaded when the user clicks on the delete button for this specific item. + The link will be submitted as a POST request. + - name: description + type: TEXT + description: A description of the list item, displayed as greyed-out text. + - name: description_md + type: TEXT + description: A description of the list item, displayed as greyed-out text, in Markdown format, allowing + you to use rich text formatting, including `**bold**` and `*italic*` text. + - name: edit_link + type: URL + description: A URL to which the user should be taken when they click on the "edit" icon. Does not show + the icon when omitted. + - name: icon + type: ICON + description: Name of an icon to display on the left side of the item. + - id + - name: image_url + type: URL + description: The URL of a small image to display on the left side of the item. + - name: link + type: URL + description: An URL to which the user should be taken when they click on the list item. + - name: title + type: TEXT + required: true + description: Name of the list item, displayed prominently. + - name: view_link + type: URL + description: A URL to which the user should be taken when they click on the "view" icon. Does not show + the icon when omitted. +--- + +A vertical list of items. Each item can be clickable and link to another page. diff --git a/examples/official-site/content/components/log.md b/examples/official-site/content/components/log.md new file mode 100644 index 000000000..4a8a8bac9 --- /dev/null +++ b/examples/official-site/content/components/log.md @@ -0,0 +1,26 @@ +--- +icon: logs +since: 0.37.1 +category: server-logic +summary: Write a message to the SQLPage server log. +top: + - name: level + type: TEXT + description: How important the message is. One of 'trace', 'debug', 'info' (default), 'warn', 'error'. + Not case-sensitive. Controls the level shown in the logs. + - name: message + type: TEXT + required: true + description: The text to write to the server logs. It is printed when the page runs. +--- + +A component that writes messages to the server logs. +When a page runs, it prints your message to the terminal/console (standard error). +Use it to track what happens and troubleshoot issues. + +## Reading log messages + +- Running from a terminal (Linux, macOS, or Windows PowerShell/Command Prompt): they show up in the window. +- Docker: run `docker logs `. +- Linux service (systemd): run `journalctl -u sqlpage`. +- This component's output is written to [standard error (stderr)](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)). SQLPage request access logs are separate and are written to standard output (stdout). diff --git a/examples/official-site/content/components/login.md b/examples/official-site/content/components/login.md new file mode 100644 index 000000000..d8baa7d31 --- /dev/null +++ b/examples/official-site/content/components/login.md @@ -0,0 +1,95 @@ +--- +icon: password-user +since: 0.39.0 +category: forms-and-feedback +summary: Display a sign-in form for a username and password. +top: + - name: action + type: TEXT + description: 'An optional link to a target page that will handle the results of the form. ' + - name: autofocus + type: BOOLEAN + description: Focus the username field when the page opens. Defaults to true. Set to false when the form + is one part of a larger page. + - class + - name: enctype + type: TEXT + description: Form data encoding. + - name: error_message + type: TEXT + description: An error message to display above the form, typically shown after a failed login attempt. + - name: error_message_md + type: TEXT + description: A markdown error message to display above the form, typically shown after a failed login attempt. + - name: footer + type: TEXT + description: A text placed at the bottom of the authentication form. If both footer and footer_md are specified, + footer takes precedence. + - name: footer_md + type: TEXT + description: A markdown text placed at the bottom of the authentication form. Useful for creating links + to other pages (creating a new account, contacting technical support, etc.). + - name: forgot_password_link + type: TEXT + description: The link to the page allowing the user to reset their password. + - name: forgot_password_text + type: TEXT + description: A text for the link allowing the user to reset their password. If the text is empty, the link + is not displayed. + - id + - name: image + type: URL + description: The URL of an centered image displayed before the title. + - name: password + type: TEXT + required: true + description: Label and placeholder for the password field. + - name: password_icon + type: ICON + description: Icon to display on the left side of the input field, on the same line. + - name: remember_me_text + type: TEXT + description: A text for the option allowing the user to request the preservation of their identity. If + the text is empty, the option is not displayed. + - name: title + type: TEXT + description: Title of the authentication form. + - name: username + type: TEXT + required: true + description: Label and placeholder for the user account identifier text field. + - name: username_icon + type: ICON + description: Icon to display on the left side of the input field, on the same line. + - name: validate + type: TEXT + description: The text to display in the button at the bottom of the form that submits the values. + - name: validate_color + type: COLOR + description: The color of the button at the bottom of the form that submits the values. Omit this property + to use the default color. + - name: validate_outline + type: COLOR + description: A color to outline the validation button. + - name: validate_shape + type: TEXT + description: The shape of the validation button. + - name: validate_size + type: TEXT + description: The size of the validation button. +--- + +The login component is an authentication form with numerous customization options. +It offers the main functionalities for this type of form. +The user can enter their username and password. +There are many optional attributes such as the use of icons on input fields, the insertion of a link to a page to reset the password, an option for the application to maintain the user's identity via a cookie. +It is also possible to set the title of the form, display the company logo, or customize the appearance of the form submission button. + +This component should be used in conjunction with other components such as [authentication](component.sql?component=authentication) and [cookie](component.sql?component=cookie). +It does not implement any logic and simply collects the username and password to pass them to the code responsible for authentication. + +A few things to know : +- The form uses the POST method to transmit information to the destination page, +- The user's username and password are entered into fields with the names `username` and `password`, +- To obtain the values of username and password, you must use the variables `:username` and `:password`, +- When you set the `remember_me_text` property, the variable `:remember` becomes available after form submission to check if the user checked the "remember me" checkbox. diff --git a/examples/official-site/content/components/map.md b/examples/official-site/content/components/map.md new file mode 100644 index 000000000..42ea16e8e --- /dev/null +++ b/examples/official-site/content/components/map.md @@ -0,0 +1,87 @@ +--- +icon: map +since: 0.8.0 +category: display-data +summary: Plot locations and geographic shapes on an interactive map. +top: + - name: attribution + type: HTML + description: Text to display at the bottom right of the map. Defaults to "© OpenStreetMap". + - class + - name: height + type: INTEGER + description: Height of the map, in pixels. Default to 350px + - id + - name: latitude + type: REAL + description: Latitude of the center of the map. If omitted, the map will be centered on its markers. + - name: longitude + type: REAL + description: Longitude of the center of the map. + - name: max_zoom + type: INTEGER + description: How far the map can be zoomed in. Defaults to 18. Added in v0.15.2. + - name: tile_source + type: URL + description: Custom map tile images to use, as a URL. Defaults to "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png". + Added in v0.15.2. + - name: title + type: TEXT + description: A text header displayed above the map. + - name: zoom + type: REAL + description: Zoom Level to apply to the map. Defaults to 5. +row: + - name: color + type: COLOR + description: Background color of the marker on the map. Requires "icon" to be set. + - name: description + type: TEXT + description: Plain text description of the marker, to be displayed in a tooltip when the marker is clicked. + - name: description_md + type: TEXT + description: Description of the marker, in markdown, rendered in a tooltip when the marker is clicked. + - name: geojson + type: JSON + description: A GeoJSON geometry (line, polygon, ...) to display on the map. Can be styled using geojson + properties using the name of leaflet path options. Introduced in 0.15.1. Accepts raw strings in addition + to JSON objects since 0.15.2. + - name: icon + type: ICON + description: Name of the icon to use for the marker + - name: latitude + type: REAL + required: true + description: Latitude of the marker. Required only if geojson is not set. + - name: link + type: TEXT + description: A link to associate to the marker's title. If set, the marker tooltip's title will be clickable + and will open the link. + - name: longitude + type: REAL + required: true + description: Longitude of the marker. Required only if geojson is not set. + - name: size + type: INTEGER + description: Size of the marker icon. Requires "icon" to be set. Introduced in 0.15.2. + - name: title + type: TEXT + description: Title of the marker, displayed on hover and in the tooltip when the marker is clicked. +--- + +## Visualize SQL data on a map. + +The map component displays a custom interactive map with markers on it. + +In its simplest form, the component displays points on a map from a table of latitudes and longitudes. +But it can also be used by cartographers in combination with PostgreSQL's PostGIS or SQLite's spatialite, +to create custom visualizations of geospatial data. +Use the `geojson` property to generate rich maps from a GIS database. + +### Example Use Cases + +1. **Store Locator**: Build an interactive map to find the nearest store information using SQL-stored geospatial data. +2. **Delivery Route Optimization**: Visualize the results of delivery route optimization algorithms. +3. **Sales Heatmap**: Identify high-performing regions by mapping sales data stored in SQL. +4. **Real-Time Tracking**: Create dynamic dashboards that track vehicles, assets, or users live using PostGIS or MS SQL Server geospatial time series data. Use the [shell](?component=shell) component to auto-refresh the map. +5. **Demographic Insights**: Map customer demographics or trends geographically to uncover opportunities for growth or better decision-making. diff --git a/examples/official-site/content/components/modal.md b/examples/official-site/content/components/modal.md new file mode 100644 index 000000000..59fc9f397 --- /dev/null +++ b/examples/official-site/content/components/modal.md @@ -0,0 +1,67 @@ +--- +icon: app-window +since: 0.36.0 +category: forms-and-feedback +summary: Open a dialog over the page for details, forms, or media. +top: + - name: allow + type: TEXT + description: For embedded content, this attribute specifies the features or permissions that can be used. + - name: class + type: TEXT + description: Class attribute added to the container in HTML. It can be used to apply custom styling to + this item through css. + - name: close + type: TEXT + description: The text to display in the Close button. + - name: close_label + type: TEXT + description: The same as `close`. Use it on databases where `close` is a reserved word, such as SQL Server. + - name: embed + type: TEXT + description: Embed remote content in an iframe. + - name: embed_mode + type: TEXT + description: Use "iframe" to display embedded content within an iframe. + - name: height + type: INTEGER + description: Height of the modal content, in pixels. Overflow content scrolls. + - name: id + type: TEXT + required: true + description: ID attribute added to the container in HTML. It can be used to target this item through css + or for displaying this item. + - name: large + type: BOOLEAN + description: Indicates that the modal box has an increased width. + - name: sandbox + type: TEXT + description: For embedded content, this attribute specifies the security restrictions on the loaded content. + - name: scrollable + type: BOOLEAN + description: Create a scrollable modal that allows scroll the modal body. + - name: small + type: BOOLEAN + description: Indicates that the modal box has a reduced width. + - name: style + type: TEXT + description: Applies CSS styles to the embedded content. + - name: title + type: TEXT + required: true + description: Description of the modal box. +row: + - name: contents + type: TEXT + description: A paragraph of text to display, without any formatting, without having to make additional + queries. + - name: contents_md + type: TEXT + description: Rich text in the markdown format. Among others, this allows you to write bold text using `**bold**`, + italics using `*italics*`, and links using `[text](https://example.com)`. +--- + +Defines the a temporary popup box displayed on top of a webpage’s content. +Useful for displaying additional information, help, or collect data from users. + +Modals are closed by default, and can be opened by clicking on a button or link targeting their ID. diff --git a/examples/official-site/content/components/pagination.md b/examples/official-site/content/components/pagination.md new file mode 100644 index 000000000..45ada6d28 --- /dev/null +++ b/examples/official-site/content/components/pagination.md @@ -0,0 +1,104 @@ +--- +icon: sailboat-2 +since: 0.40.0 +category: navigation +summary: Link to other pages of a query result. +top: + - name: circle + type: BOOLEAN + description: Whether to use circle version of the pagination. + - class + - name: first_disabled + type: BOOLEAN + description: disables the button to go to the first page. + - name: first_link + type: URL + description: A target URL to which the user should be directed to get to the first page. If none, the link + is not displayed. + - name: first_title + type: TEXT + description: The text displayed on the button to go to the first page. + - id + - name: last_disabled + type: BOOLEAN + description: disables the button to go to the last page. + - name: last_link + type: URL + description: A target URL to which the user should be directed to get to the last page. If none, the link + is not displayed. + - name: last_title + type: TEXT + description: The text displayed on the button to go to the last page. + - name: next_disabled + type: BOOLEAN + description: Disables the button to go to the next page. + - name: next_link + type: URL + description: A target URL to which the user should be directed to get to the next page. If none, the link + is not displayed. + - name: next_title + type: TEXT + description: The text displayed on the button to go to the next page. + - name: outline + type: BOOLEAN + description: Whether to use outline version of the pagination. + - name: previous_disabled + type: BOOLEAN + description: disables the button to go to the previous page. + - name: previous_link + type: URL + description: A target URL to which the user should be directed to get to the previous page. If none, the + link is not displayed. + - name: previous_title + type: TEXT + description: The text displayed on the button to go to the previous page. +row: + - name: active + type: BOOLEAN + description: Whether the link is active or not. Defaults to false. + - name: contents + type: INTEGER + required: true + description: Page number. + - name: link + type: URL + description: A target URL to which the user should be redirected to view the requested page of data. + - name: offset + type: BOOLEAN + description: Whether to use offset to show only a few pages at a time. Usefull if the count of pages is + too large. Defaults to false +--- + +Navigation links to go to the first, previous, next, or last page of a dataset. +Useful when data is divided into pages, each containing a fixed number of rows. + +This component only handles the display of pagination. +**Your sql queries are responsible for filtering data** based on the page number passed as a URL parameter. + +This component is typically used in conjunction with a [table](?component=table), +[list](?component=list), or [card](?component=card) component. + +The pagination component displays navigation buttons (first, previous, next, last) customizable with text or icons. + +For large numbers of pages, an offset can limit the visible page links. + +A minimal example of a SQL query that uses the pagination would be: +```sql +select 'table' as component; +select * from my_table limit 100 offset $offset; + +select 'pagination' as component; +with recursive pages as ( + select 0 as offset + union all + select offset + 100 from pages + where offset + 100 < (select count(*) from my_table) +) +select + (offset/100+1) as contents, + sqlpage.link(sqlpage.path(), json_object('offset', offset)) as link, + offset = coalesce(cast($offset as integer), 0) as active +from pages; +``` + +For more advanced usage, the [pagination guide](blog.sql?post=How+to+use+the+pagination+component) provides a complete tutorial. diff --git a/examples/official-site/content/components/redirect.md b/examples/official-site/content/components/redirect.md new file mode 100644 index 000000000..4ab88c356 --- /dev/null +++ b/examples/official-site/content/components/redirect.md @@ -0,0 +1,43 @@ +--- +icon: arrow-right +since: 0.7.2 +category: http-responses +summary: Send the visitor to another URL. +top: + - name: link + type: TEXT + required: true + description: The URL to redirect the user to. +--- + +Redirects the user to another page. + +This component helps you: +1. Send users to a different page +1. Stop execution of the current page + +### Conditional logic + +There is no `IF` statement in SQL. Even when you use a [`CASE` expression](https://modern-sql.com/caniuse/case_(simple)), all branches are always evaluated (and only one is returned). + +To conditionally execute a component or a [SQLPage function](/functions.sql), you can use the `redirect` component. +A common use case is error handling. You may want to proceed with the rest of a page only when certain pre-conditions are met. + +```sql +SELECT + 'redirect' AS component, + 'error_page.sql' AS link +WHERE NOT your_condition; + +-- The rest of the page is only executed if the condition is true +``` +### Technical limitation + +You must use this component **at the beginning of your SQL file**, before any other components that might send content to the browser. +Since the component needs to tell the browser to go to a different page by sending an *HTTP header*, +it will fail if the HTTP headers have already been sent by the time it is executed. + +> **Important difference from [http_header](?component=http_header)** +> +> This component completely stops the page from running after it's called. +> This makes it a good choice for protecting sensitive information from unauthorized users. diff --git a/examples/official-site/content/components/rss.md b/examples/official-site/content/components/rss.md new file mode 100644 index 000000000..e4c00061d --- /dev/null +++ b/examples/official-site/content/components/rss.md @@ -0,0 +1,128 @@ +--- +icon: rss +since: 0.20.0 +category: http-responses +summary: Publish an RSS feed from query results. +top: + - name: author + type: TEXT + description: Defines the group, person, or people responsible for creating the channel. + - name: category + type: TEXT + description: Defines the category of the channel. The value should be a string representing the category + (e.g., "News", "Technology", etc.). + - name: complete + type: BOOLEAN + description: Specifies that a channel is complete and will not post any more items in the future. + - name: copyright + type: TEXT + description: Provides the copyright details for the channel. + - name: description + type: TEXT + required: true + description: Describes the channel. + - name: explicit + type: BOOLEAN + description: Indicates whether the channel contains explicit content. The value can be either TRUE or FALSE. + - name: funding_text + type: TEXT + description: The text to display with the donation/funding link. Ignored unless "funding_url" is also set. + - name: funding_url + type: URL + description: Specifies the donation/funding links for the channel. The content of the tag is the recommended + string to be used with the link. + - name: guid + type: TEXT + description: The globally unique identifier (GUID) for a channel. The value is a UUIDv5. + - name: image_url + type: URL + description: Provides a URL linking to the artwork for the channel. + - name: language + type: TEXT + description: Defines the language of the channel, specified in the ISO 639 format. For example, "en" for + English, "fr" for French. + - name: link + type: URL + required: true + description: Defines the hyperlink to the channel. + - name: locked + type: BOOLEAN + description: Tells podcast hosting platforms whether they are allowed to import this feed. + - name: self_link + type: URL + description: URL of the RSS feed. + - name: sub_category + type: TEXT + description: Defines a sub-category, nested inside the "category". Ignored unless "category" is also set. + - name: title + type: TEXT + required: true + description: Defines the title of the channel. + - name: type + type: TEXT + description: Specifies the channel as either episodic or serial. The value can be either "episodic" or + "serial". +row: + - name: block + type: BOOLEAN + description: Prevents a specific item from appearing in podcast listening applications. + - name: date + type: TEXT + description: Indicates when the item was published (RFC-822 date-time). + - name: description + type: TEXT + required: true + description: Describes the item + - name: duration + type: INTEGER + description: The duration of an item in seconds. + - name: enclosure_length + type: INTEGER + description: The length in bytes of the audio/video episode content. + - name: enclosure_type + type: TEXT + description: The MIME media type of the audio/video episode content (e.g., "audio/mpeg", "audio/m4a", "video/m4v", + "video/mp4"). + - name: enclosure_url + type: URL + description: For podcast episodes, provides a URL linking to the audio/video episode content, in mp3, m4a, + m4v, or mp4 format. + - name: episode + type: INTEGER + description: The chronological number that is associated with an item. + - name: episode_type + type: TEXT + description: Defines the type of content for a specific item. The value can be either "full", "trailer", + or "bonus". + - name: explicit + type: BOOLEAN + description: Indicates whether the item contains explicit content. The value can be either TRUE or FALSE. + - name: guid + type: TEXT + description: The globally unique identifier (GUID) for an item. + - name: image_url + type: URL + description: Provides a URL linking to the artwork for the item. + - name: link + type: URL + required: true + description: Defines the hyperlink to the item (blog post URL, etc.). + - name: season + type: INTEGER + description: The chronological number associated with an item's season. + - name: title + type: TEXT + required: true + description: Defines the title of the feed item (episode name, blog post title, etc.). + - name: transcript_type + type: TEXT + description: The type of the transcript or closed captions file for the item (e.g., "text/plain", "text/html", + "text/vtt", "application/json", "application/x-subrip"). + - name: transcript_url + type: URL + description: A link to a transcript or closed captions file for the item. +--- + +Produces a data flow in the RSS format. +Can be used to generate a podcast feed. +To use this component, you must first return an HTTP header with the "application/rss+xml" content type (see http_header component). Next, you must use the shell-empty component to avoid that SQLPage generates HTML code. diff --git a/examples/official-site/content/components/shell.md b/examples/official-site/content/components/shell.md new file mode 100644 index 000000000..e26171a2f --- /dev/null +++ b/examples/official-site/content/components/shell.md @@ -0,0 +1,145 @@ +--- +icon: layout-navbar +category: page-layout +summary: Set the page layout, navigation, branding, and footer. +top: + - name: class + type: TEXT + description: class attribute added to the page's html element. It can be used to apply custom styling to + the whole page through css. + - name: css + type: URL + description: The URL of a CSS file to load and apply to the page. + - name: description + type: TEXT + description: A description of the page. It can be displayed by search engines when your page appears in + their results. + - name: favicon + type: URL + description: The URL of the icon the web browser should display in bookmarks and tabs. This property is + particularly useful if multiple sites are hosted on the same domain with different [``site_prefix``](/configuration#site_prefix). + - name: fixed_top_menu + type: BOOLEAN + description: Fixes the top bar with menu at the top (the top bar remains visible when scrolling long pages). + - name: font + type: TEXT + description: Specifies the font to be used for displaying text, which can be a valid font name from fonts.google.com + or the path to a local WOFF2 font file starting with a slash (e.g., "/fonts/MyLocalFont.woff2"). + - name: font_size + type: INTEGER + description: Font size on the page, in pixels. Set to 18 by default. + - name: footer + type: TEXT + description: Muted text to display in the footer of the page. This can be used to display a link to the + terms and conditions of your application, for instance. By default, shows "Built with SQLPage". Supports + links with markdown. + - name: icon + type: ICON + description: Name of an icon (from tabler-icons.io) to display next to the title in the navigation bar. + - name: image + type: URL + description: The URL of an image to display next to the page title. + - name: javascript + type: URL + description: The URL of a Javascript file to load and execute on the page. + - name: javascript_module + type: URL + description: The URL of a javascript module in the ESM format (see javascript.info/modules) + - name: language + type: TEXT + description: The language of the page. This can be used by search engines and screen readers to determine + in which language the page is written. + - name: layout + type: TEXT + description: The general page layout. Can be "boxed" (the default), "horizontal" (for a full-width menu), + "vertical"(vertical menu), "fluid" (removes side margins). + - name: link + type: URL + description: The target of the link in the top navigation bar. + - name: manifest + type: URL + description: The location of the [manifest.json](https://developer.mozilla.org/en-US/docs/Web/Manifest) + if the site is a [PWA](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps). Among other + features, serving a manifest enables your site to be "installed" as an app on most mobile devices. + - name: menu_item + type: TEXT + description: Adds a menu item in the navigation bar at the top of the page. The menu item will have the + specified name, and will link to as .sql file of the same name. A dropdown can be generated by passing + a json object with a `title` and `submenu` properties. + - name: navbar_title + type: TEXT + description: The title to display in the top navigation bar. Used to display a different title in the top + menu than the one that appears in the tab of the browser. + - name: norobot + type: BOOLEAN + description: Forbids robots to save this page in their database and follow the links on this page. This + will prevent this page to appear in Google search results for any query, for instance. + - name: preview_image + type: URL + description: The URL of an image to display as a link preview when the page is shared on social media + - name: refresh + type: INTEGER + description: Number of seconds after which the page should refresh. This can be useful to display dynamic + content that updates automatically. + - name: rss + type: URL + description: The URL of an RSS feed to display in the top navigation bar. You can use the rss component + to generate the field. + - name: rtl + type: BOOLEAN + description: Whether the page should be displayed in right-to-left mode. Used to display Arabic, Hebrew, + Persian, etc. + - name: search_button + type: TEXT + description: Customizes the text displayed on the search button. Replaces the default "Search" label with + custom text that may better match your applications terminology or language. + - name: search_placeholder + type: TEXT + description: Customizes the placeholder text shown in the search input field. Replaces the default "Search" + with text that better describes what users should search for. + - name: search_target + type: TEXT + description: When this is set, a search field will appear in the top navigation bar, and load the specified + sql file with an URL parameter named "search" when the user searches something. + - name: search_value + type: TEXT + description: This value will be placed in the search field when "search_target" is set. Using the "$search" + query parameter value will mirror the value that the user has searched for. + - name: sidebar + type: BOOLEAN + description: Whether the menu defined by menu_item should be displayed on the left side of the page instead + of the top. Introduced in v0.27. + - name: sidebar_theme + type: TEXT + description: Used with sidebar property, It can be set to "dark" to exclusively set the sidebar into dark + theme. + - name: social_image + type: URL + description: The URL of the preview image that will appear in the Open Graph metadata when the page is + shared on social media. + - name: target + type: TEXT + description: 'Where the menu items should open: "_blank" for a new tab, "_self" for the same tab, "_parent" + for the parent frame, or "_top" for the full body of the window. Set it inside a "menu_item" json object; + it has no effect when set directly on the shell.' + - name: theme + type: TEXT + description: Set to "dark" to use a dark theme. + - name: title + type: TEXT + description: The title of your page. Will be shown in a top bar above the page contents. Also usually displayed + by web browsers as the name of the web page's tab. +--- + +Customize the overall layout, header and footer of the page. + +This is a special component that provides the page structure wrapping all other components on your page. + +It generates the complete HTML document including the `` section with metadata, title, and stylesheets, +as well as the navigation bar, main content area, and footer. + +If you don't explicitly call the shell component at the top of your SQL file, SQLPage will automatically +add a default shell component before your first try to display data on the page. + +Use the shell component to customize page-wide settings like the page title, navigation menu, theme, fonts, +and to include custom visual styles (with CSS) or interactive behavior (with JavaScript) that should be loaded on the page. diff --git a/examples/official-site/content/components/status_bar.md b/examples/official-site/content/components/status_bar.md new file mode 100644 index 000000000..e51cbf03a --- /dev/null +++ b/examples/official-site/content/components/status_bar.md @@ -0,0 +1,37 @@ +--- +icon: layout-bottombar +since: 0.49.0 +category: navigation +summary: Show status messages and links in a horizontal bar. +top: + - class + - name: fixed + type: BOOLEAN + description: Keep the bar at the bottom of the screen while the page scrolls. Defaults to true. A fixed + bar overlays page content, so leave space below your last item if needed. Set to false to place the bar + in the page where the SQL appears. + - id + - name: label + type: TEXT + description: Accessible name for the bar. Defaults to "Status bar". +row: + - class + - name: color + type: COLOR + description: Color of the segment text and icon. + - name: icon + type: ICON + description: Icon displayed before the text. + - name: link + type: URL + description: URL to open when the segment is clicked. + - name: title + type: TEXT + description: Text displayed in the segment. + - name: tooltip + type: TEXT + description: Text shown when hovering over the segment or focusing its link. For an icon without a title, + supply a tooltip to give the segment an accessible name. +--- + +Display short status messages and links in a single horizontal bar. Each row adds one segment. When there are several segments, the last one aligns to the far edge. If the segments do not all fit, scroll the bar horizontally to see the rest. diff --git a/examples/official-site/content/components/status_code.md b/examples/official-site/content/components/status_code.md new file mode 100644 index 000000000..4baaea56b --- /dev/null +++ b/examples/official-site/content/components/status_code.md @@ -0,0 +1,36 @@ +--- +icon: error-404 +category: http-responses +summary: Set the HTTP status code returned by a page. +top: + - name: status + type: INTEGER + required: true + description: HTTP status code (e.g., 200 OK, 401 Unauthorized, 409 Conflict) +--- + +Sets the HTTP response code for the current page. + +This is an advanced technical component. +You typically need it when building internet-facing APIs and websites, +but you may not need it for simple internal applications. + +- Indicating operation results when using [SQLPage as an API](?component=json) + - `200`: *OK*, for successful operations + - `201`: *Created*, for successful record insertion + - `404`: *Not Found*, for missing resources + - `500`: *Internal Server Error*, for failed operations +- Handling data validation errors + - `400`: *Bad Request*, for invalid data +- Enforcing access controls + - `403`: *Forbidden*, for unauthorized access + - `401`: *Unauthorized*, for unauthenticated access +- Tracking system health + - `500`: *Internal Server Error*, for failed operations + +For search engine optimization: +- Use `404` for deleted content to remove outdated URLs from search engines +- For redirection from one page to another, use + - `301` (moved permanently), or + - `302` (moved temporarily) +- Use `503` during maintenance diff --git a/examples/official-site/content/components/steps.md b/examples/official-site/content/components/steps.md new file mode 100644 index 000000000..3a62986ad --- /dev/null +++ b/examples/official-site/content/components/steps.md @@ -0,0 +1,40 @@ +--- +icon: dots-circle-horizontal +category: navigation +summary: Mark progress through the stages of a task. +top: + - name: color + type: COLOR + description: Color of the bars displayed between steps. + - name: counter + type: TEXT + description: Display the number of the step on top of its name. + - name: description + type: TEXT + description: Description of the section. + - name: id + type: TEXT + description: id attribute injected as an anchor in HTML. It can be used for scrolling to this item through + links (use "#id" in link url). Added in v0.18.0. + - name: title + type: TEXT + description: Title of the section. +row: + - name: active + type: BOOLEAN + description: Whether this item in the grid is considered "active". Active items are displayed more prominently. + - name: description + type: TEXT + description: Tooltip to display when the user passes their mouse over the step's name. + - name: icon + type: ICON + description: An icon name (from tabler-icons.io) to display on the left side of the step name. + - name: link + type: URL + description: A target URL to which the user should be taken when they click on the step. + - name: title + type: TEXT + description: Name of the step. +--- + +Guide users through multi-stage processes, displaying a clear list of previous and future steps. diff --git a/examples/official-site/content/components/tab.md b/examples/official-site/content/components/tab.md new file mode 100644 index 000000000..a08986583 --- /dev/null +++ b/examples/official-site/content/components/tab.md @@ -0,0 +1,43 @@ +--- +icon: row-insert-bottom +since: 0.9.5 +category: navigation +summary: Switch between related pages using labeled tabs. +top: + - name: center + type: BOOLEAN + description: Whether the tabs should be centered or not. Defaults to false. + - class + - id +row: + - name: active + type: BOOLEAN + description: Whether the tab is active or not. Defaults to false. + - name: center + type: BOOLEAN + description: Whether this individual tab's label should be centered inside the tab. Defaults to false. + - class + - name: color + type: TEXT + description: Color of the tab's text, and of its underline when it is active. See preview.tabler.io/colors.html + for a list of available colors. + - name: description + type: TEXT + description: Description of the tab. This is displayed when the user hovers over the tab. + - name: icon + type: TEXT + description: Name of the icon to display on the tab. See tabler-icons.io for a list of available icons. + - id + - name: link + type: TEXT + description: Link to the page to display when the tab is clicked. By default, the link refers to the current + page, with a 'tab' parameter set to the tab's title and hash set to the id (if passed) - this brings + us back to the location of the tab after submission. + - name: title + type: TEXT + required: true + description: Text to display on the tab. If link is not set, the link will be the current page with a '$tab' + parameter set to the tab's title. If 'id' is set, the page will be scrolled to the tab. +--- + +Build a tabbed interface, with each tab being a link to a page. Each tab can be in two states: active or inactive. diff --git a/examples/official-site/content/components/table.md b/examples/official-site/content/components/table.md new file mode 100644 index 000000000..633f0a744 --- /dev/null +++ b/examples/official-site/content/components/table.md @@ -0,0 +1,149 @@ +--- +icon: table +category: display-data +summary: Turn query results into a sortable, searchable table. +top: + - name: align_center + type: TEXT + description: Name of a column the contents of which should be center-aligned. This argument can be repeated + multiple times to align multiple columns to the center. + - name: align_right + type: TEXT + description: Name of a column the contents of which should be right-aligned. This argument can be repeated + multiple times to align multiple columns to the right. Introduced in v0.15.0. + - name: border + type: BOOLEAN + description: Whether to draw borders on all sides of the table and cells. + - class + - name: currency + type: TEXT + description: The ISO 4217 currency code (e.g., USD, EUR, GBP, etc.) to use when formatting monetary values. + - name: custom_actions + type: JSON + description: 'If set, a column of custom action buttons will be added to each row. The value of this property + should be a JSON array of objects, each object defining a button with the following properties: `name` + (the text to display on the button), `icon` (the tabler icon name or image link to display on the button), + `link` (the URL to navigate to when the button is clicked, possibly containing the `{id}` placeholder + that will be replaced by the value of the `_sqlpage_id` property for that row), and `tooltip` (optional + text to display when hovering over the button). Added in v0.39.0' + - name: delete_url + type: TEXT + description: If set, a delete button will be added to each row. The value of this property should be a + URL, possibly containing the `{id}` placeholder that will be replaced by the value of the `_sqlpage_id` + property for that row. Clicking the delete button will take the user to that URL. Added in v0.39.0 + - name: description + type: TEXT + description: Description of the table contents. Helps users with screen readers to find a table and understand + what it’s about. + - name: edit_url + type: TEXT + description: If set, an edit button will be added to each row. The value of this property should be a URL, + possibly containing the `{id}` placeholder that will be replaced by the value of the `_sqlpage_id` property + for that row. Clicking the edit button will take the user to that URL. Added in v0.39.0 + - name: empty_description + type: TEXT + description: Text to display if the table does not contain any row. Defaults to "no data". + - name: freeze_columns + type: BOOLEAN + description: Whether to freeze the leftmost column of the table. + - name: freeze_footers + type: BOOLEAN + description: Whether to freeze the footer (bottom row) of the table, only works if that row has the `_sqlpage_footer` + property applied to it. + - name: freeze_headers + type: BOOLEAN + description: Whether to freeze the top row of the table. + - name: hover + type: BOOLEAN + description: Whether to enable a hover state on table rows. + - name: icon + type: TEXT + description: Set this to the name of a column whose content should be interpreted as a tabler icon name. + Used to display icons in the table. This argument can be repeated multiple times to intepret multiple + columns as icons. Introduced in v0.8.0. + - id + - name: initial_search_value + type: TEXT + description: Pre-fills the search bar used to filter the table. The user will still be able to edit the + value to display table rows that will initially be filtered out. + - name: markdown + type: TEXT + description: Set this to the name of a column whose content should be interpreted as markdown . Used to + display rich text with links in the table. This argument can be repeated multiple times to intepret multiple + columns as markdown. + - name: money + type: TEXT + description: Name of a numeric column whose values should be displayed as currency amounts, in the currency + defined by the `currency` property. This argument can be repeated multiple times. + - name: monospace + type: TEXT + description: Name of a column the contents of which should be displayed in monospace. This argument can + be repeated multiple times to display multiple columns in monospace. Introduced in v0.32.1. + - name: number_format_digits + type: INTEGER + description: Maximum number of decimal digits to display for numeric values. + - name: number_format_locale + type: TEXT + description: A BCP 47 language tag (e.g. "de-DE", "en-IN") deciding how numbers and monetary values are + formatted. Defaults to the locale of the visitor's browser. + - name: overflow + type: BOOLEAN + description: Whether to to let "wide" tables overflow across the right border and enable browser-based + horizontal scrolling. + - name: raw_numbers + type: TEXT + description: Name of a column whose values are numeric, but should be displayed as raw numbers without + any formatting (no thousands separators, decimal separator is always a dot). This argument can be repeated + multiple times. + - name: search + type: BOOLEAN + description: Add a search bar at the top of the table, letting users easily filter table rows by value. + - name: search_placeholder + type: TEXT + description: Customizes the placeholder text shown in the search input field. Replaces the default "Search..." + with text that better describes what users should search for. + - name: small + type: BOOLEAN + description: Whether to use compact table. + - name: sort + type: BOOLEAN + description: Make the columns clickable to let the user sort by the value contained in the column. + - name: striped_columns + type: BOOLEAN + description: Whether to add zebra-striping to any table column. + - name: striped_rows + type: BOOLEAN + description: Whether to add zebra-striping to any table row. + - name: title + type: TEXT + description: A title displayed above the table. +row: + - name: _sqlpage_actions + type: JSON + description: 'Sets custom action buttons for this specific row in addition to any defined at the table + level, The value of this property should be a JSON array of objects, each object defining a button with + the following properties: `name` (the text to display on the button), `icon` (the tabler icon name or + image link to display on the button), `link` (the URL to navigate to when the button is clicked, possibly + containing the `{id}` placeholder that will be replaced by the value of the `_sqlpage_id` property for + that row), and `tooltip` (optional text to display when hovering over the button). Added in v0.39.0' + - name: _sqlpage_color + type: COLOR + description: Sets the background color of the row. Added in v0.8.0. + - name: _sqlpage_css_class + type: TEXT + description: For advanced users. Sets a css class on the table row. Added in v0.8.0. + - name: _sqlpage_footer + type: BOOLEAN + description: Sets this row as the table footer. It is recommended that this parameter is applied to the + last row. Added in v0.34.0. + - name: _sqlpage_id + type: TEXT + description: Sets the id of the html tabler row element. Allows you to make links targeting a specific + row in a table. +--- + +A table with optional filtering and sorting. +Unlike most others, this component does not have a fixed set of item properties, any property that is used will be rendered directly as a column in the table. +Tables can contain rich text, including images, links, and icons. Table rows can be styled with a background color, and the table can be made striped, hoverable, and bordered. + +Advanced users can apply custom styles to table columns using a CSS class with the same name as the column, and to table rows using the `_sqlpage_css_class` property. diff --git a/examples/official-site/content/components/text.md b/examples/official-site/content/components/text.md new file mode 100644 index 000000000..07a002713 --- /dev/null +++ b/examples/official-site/content/components/text.md @@ -0,0 +1,72 @@ +--- +icon: align-left +category: page-layout +summary: Write paragraphs using plain text or Markdown. +top: + - name: article + type: BOOLEAN + description: Makes long texts more readable by increasing the line height, adding margins, using a serif + font, and decorating the initial letter. + - name: center + type: BOOLEAN + description: Whether to center the title. + - name: contents + type: TEXT + description: A top-level paragraph of text to display, without any formatting, without having to make additional + queries. + - name: contents_md + type: TEXT + description: Rich text in the markdown format. Among others, this allows you to write bold text using `**bold**`, + italics using `*italics*`, and links using `[text](https://example.com)`. + - name: html + type: TEXT + description: Raw html code to include on the page. Don't use that if you are not sure what you are doing, + it may have security implications. + - id + - name: title + type: TEXT + description: Text header before the paragraph. + - name: unsafe_contents_md + type: TEXT + description: Markdown format with html blocks. Use this only with trusted content. See the html-blocks + section of the Commonmark spec for additional info. +row: + - name: bold + type: BOOLEAN + description: Whether the span of text should be displayed as bold. + - name: break + type: BOOLEAN + description: Indicates that the current span of text starts a new paragraph. + - name: code + type: BOOLEAN + description: Use a monospace font. Useful to display the text as code. + - name: color + type: COLOR + description: The name of a color for this span of text. + - name: contents + type: TEXT + required: true + description: A span of text to display + - name: contents_md + type: TEXT + description: Rich text in the markdown format. Among others, this allows you to write bold text using `**bold**`, + italics using `*italics*`, and links using `[text](https://example.com)`. + - name: italics + type: BOOLEAN + description: Whether the span of text should be displayed as italics. + - name: link + type: URL + description: An URL to which the user should be taken when they click on this span of text. + - name: size + type: INTEGER + description: A number between 1 and 6 indicating the font size. + - name: underline + type: BOOLEAN + description: Whether the span of text should be underlined. + - name: unsafe_contents_md + type: TEXT + description: Markdown format with html blocks. Use this only with trusted content. See the html-blocks + section of the Commonmark spec for additional info. +--- + +A paragraph of text. The entire component will render as a single paragraph, with each item being rendered as a span of text inside it, the styling of which can be customized using parameters. diff --git a/examples/official-site/content/components/timeline.md b/examples/official-site/content/components/timeline.md new file mode 100644 index 000000000..fb727e9ec --- /dev/null +++ b/examples/official-site/content/components/timeline.md @@ -0,0 +1,41 @@ +--- +icon: git-commit +since: 0.13.0 +category: display-data +summary: Arrange events along a vertical timeline. +top: + - class + - id + - name: simple + type: BOOLEAN + description: If set to true, the timeline will be displayed in a condensed format without icons. +row: + - class + - name: color + type: TEXT + description: Color of the icon. See preview.tabler.io/colors.html for a list of available colors. + - name: date + type: TEXT + required: true + description: Date of the event. + - name: description + type: TEXT + description: Textual description of the event. + - name: description_md + type: TEXT + description: Description of the event in Markdown. + - name: icon + type: TEXT + description: Name of the icon to display next to the event. See tabler-icons.io for a list of available + icons. + - id + - name: link + type: TEXT + description: Link to a page with more information about the event. + - name: title + type: TEXT + required: true + description: Name of the event. +--- + +A list of events with a vertical line connecting them. diff --git a/examples/official-site/content/components/title.md b/examples/official-site/content/components/title.md new file mode 100644 index 000000000..9c8dad5bc --- /dev/null +++ b/examples/official-site/content/components/title.md @@ -0,0 +1,21 @@ +--- +icon: letter-case-upper +since: 0.19.0 +category: page-layout +summary: Add a heading and choose its level. +top: + - name: center + type: BOOLEAN + description: Whether to center the title. + - class + - name: contents + type: TEXT + required: true + description: A text to display. + - id + - name: level + type: INTEGER + description: Set the heading level (default level is 1) +--- + +Defines HTML headings. The level 1 is used for the maximal size and the level 6 is used for the minimal size. diff --git a/examples/official-site/content/components/toast.md b/examples/official-site/content/components/toast.md new file mode 100644 index 000000000..cd190a9a7 --- /dev/null +++ b/examples/official-site/content/components/toast.md @@ -0,0 +1,47 @@ +--- +icon: notification +since: 0.46.0 +category: forms-and-feedback +summary: Show a brief notification above the page. +top: + - class + - name: color + type: COLOR + description: Optional Tabler color. The default is the neutral toast appearance; colored variants use the + matching contrasting foreground utility. + - name: description + type: TEXT + description: Escaped plain-text body. This is used only when `description_md` is not supplied. + - name: description_md + type: TEXT + description: Rich-text alternative to `description`, rendered as Markdown. When both properties are supplied, + `description_md` takes precedence. + - name: dismissible + type: BOOLEAN + description: Whether to render an accessible manual close button. Defaults to true and is independent of + automatic dismissal. + - name: duration + type: INTEGER + description: Automatic dismissal delay in milliseconds. Defaults to 5000. Set to 0 to keep the toast visible + until manually dismissed (when `dismissible` is true) or the page is left. + - name: icon + type: ICON + description: Optional [Tabler icon](https://tabler.io/icons) name. + - id + - name: position + type: TEXT + description: 'Screen placement: `top-start`, `top-center`, `top-end`, `bottom-start`, `bottom-center`, + or `bottom-end`. Defaults to `top-end`; invalid values safely fall back to that default.' + - name: title + type: TEXT + description: Optional notification heading. + - name: trigger + type: TEXT + description: Optional URL fragment that opens the toast without reloading the page, with or without the + leading `#`. When set, the toast does not open on page load and can be opened repeatedly by a link or + button whose target is that fragment. Multiple toasts can share a trigger to open as a stack. +--- + +Displays a brief notification above the page. Each top-level `toast` row creates one notification, and consecutive toasts at the same position are queued in a shared stack. + +Ordinary notifications use `role="status"` and `aria-live="polite"`. Colored variants retain a readable contrasting foreground. Automatic dismissal and the manual close control are configured independently. diff --git a/examples/official-site/content/components/tracking.md b/examples/official-site/content/components/tracking.md new file mode 100644 index 000000000..ae6bfe0be --- /dev/null +++ b/examples/official-site/content/components/tracking.md @@ -0,0 +1,44 @@ +--- +icon: timeline-event-text +since: 0.18.0 +category: display-data +summary: Show a sequence of activity or status changes as colored segments. +top: + - name: center + type: BOOLEAN + description: Whether to center the component. + - class + - name: description + type: TEXT + description: A short paragraph. + - name: description_md + type: TEXT + description: A short paragraph formatted using markdown. + - id + - name: information + type: TEXT + description: A short text displayed below the title. + - name: placement + type: TEXT + description: Position of the tooltip (e.g. top, bottom, right, left) + - name: title + type: TEXT + required: true + description: Title of the tracking component. + - name: width + type: INTEGER + description: Width of the component, between 1 and 12. +row: + - name: color + type: TEXT + description: Color of the tracked item (e.g. success, warning, danger) + - name: link + type: URL + description: A URL to open when the user clicks on the tracked item. + - name: title + type: TEXT + required: true + description: Description of the state. +--- + +Component for visualising activity logs or other monitoring-related data. diff --git a/examples/official-site/content/shared-parameters.yaml b/examples/official-site/content/shared-parameters.yaml new file mode 100644 index 000000000..573207c8c --- /dev/null +++ b/examples/official-site/content/shared-parameters.yaml @@ -0,0 +1,10 @@ +id: + name: id + type: TEXT + description: id attribute added to the container in HTML. It can be used to target this item through css + or for scrolling to this item through links (use "#id" in link url). +class: + name: class + type: TEXT + description: class attribute added to the container in HTML. It can be used to apply custom styling to this + item through css. Added in v0.18.0.