-
-
Notifications
You must be signed in to change notification settings - Fork 158
Support lazy-loaded content fragments in card component #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lovasoa
merged 8 commits into
sqlpage:main
from
lorefnon:feat-card-remote-fragment-support
Jan 5, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
376e558
Add support for embed parameter that skips the shell layout
lorefnon 4a0f135
Add support for cards with remote content
lorefnon 874ee8a
Adapt js to support lazy-loaded fragments
lorefnon 5891675
Add example
lorefnon 9c7097f
Reformat & Fix lint errors
lorefnon 77009ac
Update query param name and add docs
lorefnon 814ffdc
Add example
lorefnon 32757a0
squash migrations
lovasoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Remote Content Demo | ||
|
|
||
| This small SQLPage example shows how to: | ||
| - lazy-load other page in cards including: | ||
| - chart component rendered by sqlpage | ||
| - map component rendered by sqlpage | ||
| - table component rendered by sqlpage | ||
|
|
||
|  | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| select | ||
| 'chart' as component, | ||
| 'Quarterly Revenue' as title, | ||
| 'area' as type, | ||
| 'indigo' as color, | ||
| 5 as marker, | ||
| TRUE as time; | ||
| select | ||
| '2022-01-01T00:00:00Z' as x, | ||
| 15 as y; | ||
| select | ||
| '2022-04-01T00:00:00Z' as x, | ||
| 46 as y; | ||
| select | ||
| '2022-07-01T00:00:00Z' as x, | ||
| 23 as y; | ||
| select | ||
| '2022-10-01T00:00:00Z' as x, | ||
| 70 as y; | ||
| select | ||
| '2023-01-01T00:00:00Z' as x, | ||
| 35 as y; | ||
| select | ||
| '2023-04-01T00:00:00Z' as x, | ||
| 106 as y; | ||
| select | ||
| '2023-07-01T00:00:00Z' as x, | ||
| 53 as y; | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| select | ||
| 'card' as component, | ||
| 2 as columns; | ||
| select | ||
| 'A card with a Markdown description' as title, | ||
| 'This is a card with a **Markdown** description. | ||
|
|
||
| This is useful if you want to display a lot of text in the card, with many options for formatting, such as | ||
| - **bold**, | ||
| - *italics*, | ||
| - [links](index.sql), | ||
| - etc.' as description_md; | ||
| select | ||
| 'A card with lazy-loaded chart' as title, | ||
| '/chart-example.sql?_sqlpage_embed' as embed; | ||
| select | ||
| 'A card with lazy-loaded map' as title, | ||
| '/map-example.sql?_sqlpage_embed' as embed; | ||
| select | ||
| 'A card with lazy-loaded table' as title, | ||
| '/table-example.sql?_sqlpage_embed' as embed; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| select | ||
| 'map' as component, | ||
| 1 as zoom; | ||
| select | ||
| 'New Delhi' as title, | ||
| 28.6139 as latitude, | ||
| 77.209 as longitude; | ||
|
|
||
|
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| select | ||
| 'table' as component, | ||
| TRUE as sort, | ||
| TRUE as search; | ||
| select | ||
| 'Ophir' as Forename, | ||
| 'Lojkine' as Surname, | ||
| 'lovasoa' as Pseudonym; | ||
| select | ||
| 'Linus' as Forename, | ||
| 'Torvalds' as Surname, | ||
| 'torvalds' as Pseudonym; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| select | ||
| 'chart' as component, | ||
| 'Quarterly Revenue' as title, | ||
| 'area' as type, | ||
| 'indigo' as color, | ||
| 5 as marker, | ||
| TRUE as time; | ||
| select | ||
| '2022-01-01T00:00:00Z' as x, | ||
| 15 as y; | ||
| select | ||
| '2022-04-01T00:00:00Z' as x, | ||
| 46 as y; | ||
| select | ||
| '2022-07-01T00:00:00Z' as x, | ||
| 23 as y; | ||
| select | ||
| '2022-10-01T00:00:00Z' as x, | ||
| 70 as y; | ||
| select | ||
| '2023-01-01T00:00:00Z' as x, | ||
| 35 as y; | ||
| select | ||
| '2023-04-01T00:00:00Z' as x, | ||
| 106 as y; | ||
| select | ||
| '2023-07-01T00:00:00Z' as x, | ||
| 53 as y; | ||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
examples/official-site/sqlpage/migrations/31_card_docs_update.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| DELETE FROM component WHERE name = 'card'; | ||
|
|
||
| INSERT INTO component(name, icon, description) VALUES | ||
| ('card', 'credit-card', 'A grid where each element is a small card that displays a piece of data.'); | ||
| INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'card', * FROM (VALUES | ||
| -- top level | ||
| ('title', 'Text header at the top of the list of cards.', 'TEXT', TRUE, TRUE), | ||
| ('description', 'A short paragraph displayed below the title.', 'TEXT', TRUE, TRUE), | ||
| ('description_md', 'A short paragraph displayed below the title - formatted using markdown.', 'TEXT', TRUE, TRUE), | ||
| ('columns', '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.', 'INTEGER', TRUE, TRUE), | ||
| -- item level | ||
| ('title', 'Name of the card, displayed at the top.', 'TEXT', FALSE, FALSE), | ||
| ('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.', 'TEXT', FALSE, TRUE), | ||
| ('description_md', ' | ||
| 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), , etc.', 'TEXT', FALSE, TRUE), | ||
| ('top_image', 'The URL (absolute or relative) of an image to display at the top of the card.', 'URL', FALSE, TRUE), | ||
| ('footer', 'Muted text to display at the bottom of the card.', 'TEXT', FALSE, TRUE), | ||
| ('footer_md', 'Muted text to display at the bottom of the card, with rich text formatting in Markdown format.', 'TEXT', FALSE, TRUE), | ||
| ('link', 'An URL to which the user should be taken when they click on the card.', 'URL', FALSE, TRUE), | ||
| ('footer_link', 'An URL to which the user should be taken when they click on the footer.', 'URL', FALSE, TRUE), | ||
| ('icon', 'Name of an icon to display on the left side of the card.', 'ICON', FALSE, TRUE), | ||
| ('color', 'The name of a color, to be displayed on the left of the card to highlight it.', 'COLOR', FALSE, TRUE), | ||
| ('active', 'Whether this item in the grid is considered "active". Active items are displayed more prominently.', 'BOOLEAN', FALSE, TRUE), | ||
| ('embed', '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', 'TEXT', FALSE, TRUE) | ||
| ) x; | ||
|
|
||
| INSERT INTO example(component, description, properties) VALUES | ||
| ('card', 'The most basic card', json('[{"component":"card"},{"description":"A"},{"description":"B"},{"description":"C"}]')), | ||
| ('card', 'A card with a Markdown description', | ||
| json('[{"component":"card", "columns": 2}, {"title":"A card with a Markdown description", "description_md": "This is a card with a **Markdown** description. \n\n'|| | ||
| 'This is useful if you want to display a lot of text in the card, with many options for formatting, such as '|| | ||
| '\n - **bold**, \n - *italics*, \n - [links](index.sql), \n - etc."}]')), | ||
| ('card', 'A beautiful card grid with bells and whistles, showing examples of SQLPage features.', | ||
| json('[{"component":"card", "title":"Popular SQLPage features", "columns": 2}, | ||
| {"title": "Download as spreadsheet", "link": "?component=csv#component", "description": "Using the CSV component, you can download your data as a spreadsheet.", "icon":"file-plus", "color": "green", "footer_md": "SQLPage can both [read](?component=form#component) and [write](?component=csv#component) **CSV** files."}, | ||
| {"title": "Custom components", "link": "/custom_components.sql", "description": "If you know some HTML, you can create your own components for your application.", "icon":"code", "color": "orange", "footer_md": "You can look at the [source of the official components](https://github.com/lovasoa/SQLpage/tree/main/sqlpage/templates) for inspiration."} | ||
| ]')), | ||
| ('card', 'A gallery of images.', | ||
| json('[ | ||
| {"component":"card", "title":"My favorite animals in pictures", "columns": 3}, | ||
| {"title": "Lynx", "description_md": "The **lynx** is a medium-sized **wild cat** native to Northern, Central and Eastern Europe to Central Asia and Siberia, the Tibetan Plateau and the Himalayas.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Lynx_lynx-4.JPG/640px-Lynx_lynx-4.JPG", "icon":"star" }, | ||
| {"title": "Squirrel", "description_md": "The **chipmunk** is a small, striped rodent of the family Sciuridae. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Tamias-rufus-001.jpg/640px-Tamias-rufus-001.jpg" }, | ||
| {"title": "Spider", "description_md": "The **jumping spider family** (_Salticidae_) contains more than 600 described genera and about *6000 described species*, making it the largest family of spiders with about 13% of all species.", "top_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/Jumping_spiders_%28Salticidae%29.jpg/640px-Jumping_spiders_%28Salticidae%29.jpg" } | ||
| ]')), | ||
| ('card', 'Cards with remote content', | ||
| json('[ | ||
| {"component":"card", "title":"Card with embedded remote content", "columns": 2}, | ||
| {"title": "Embedded Chart", "embed": "/examples/chart.sql?_sqlpage_embed" }, | ||
| {"title": "Description", "description_md": "You can find the sql file that generates the chart [here](https://github.com/lovasoa/SQLpage/tree/main/examples/official-site/examples/chart.sql)" } | ||
| ]')); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.