Skip to content

Commit f2a56a1

Browse files
committed
Add id/class to the components
1 parent 41c1318 commit f2a56a1

25 files changed

+123
-48
lines changed

examples/official-site/sqlpage/migrations/01_documentation.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ INSERT INTO component(name, icon, description) VALUES
193193
INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'form', * FROM (VALUES
194194
-- top level
195195
('method', '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.', 'TEXT', TRUE, TRUE),
196-
('action', 'An optional link to a target page that will handle the results of the form. By default the target page is the current page. Setting it to the name of a different sql file will load that file when the user submits the form.', 'TEXT', TRUE, TRUE),
196+
('action', '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.', 'TEXT', TRUE, TRUE),
197197
('title', '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.', 'TEXT', TRUE, TRUE),
198198
('validate', '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.', 'TEXT', TRUE, TRUE),
199199
('validate_color', 'The color of the button at the bottom of the form that submits the values. Omit this property to use the default color.', 'COLOR', TRUE, TRUE),
@@ -730,3 +730,4 @@ On other engines (such as SQLite), you can use the [`dynamic`](?component=dynami
730730
"css": "/prism-tabler-theme.css",
731731
"footer": "Official [SQLPage](https://sql.ophir.dev) documentation"
732732
}]'));
733+

examples/official-site/sqlpage/migrations/13_tab.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ VALUES (
2424
(
2525
'tab',
2626
'link',
27-
'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.',
27+
'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.',
2828
'TEXT',
2929
FALSE,
3030
TRUE
@@ -88,9 +88,9 @@ View the [dynamic tabs example](examples/tabs.sql).
8888
JSON(
8989
'[
9090
{ "component": "tab" },
91-
{ "title": "My First tab", "active": true },
92-
{ "title": "This is tab two" },
93-
{ "title": "Third tab is crazy" }
91+
{ "title": "My First tab", "active": true, "id": "first" },
92+
{ "title": "This is tab two", "id": "second" },
93+
{ "title": "Third tab is crazy", "id": "third" }
9494
]'
9595
)
9696
),
@@ -106,4 +106,4 @@ View the [dynamic tabs example](examples/tabs.sql).
106106
]'
107107
)
108108
)
109-
;
109+
;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
-- 1
2+
INSERT INTO parameter(component, top_level, name, description, type, optional)
3+
SELECT *, 'id', '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)', 'TEXT', TRUE
4+
FROM (VALUES
5+
('alert', TRUE),
6+
('breadcrumb', TRUE),
7+
('chart', TRUE),
8+
-- ('code', TRUE),
9+
('csv', TRUE),
10+
('datagrid', TRUE),
11+
('hero', TRUE),
12+
('list', TRUE),
13+
('list', FALSE),
14+
('map', TRUE),
15+
('tab', FALSE),
16+
('table', TRUE),
17+
('timeline', TRUE),
18+
('timeline', FALSE),
19+
-- ('title', TRUE),
20+
('tracking', TRUE),
21+
('text', TRUE)
22+
);
23+
24+
-- 2
25+
INSERT INTO parameter(component, top_level, name, description, type, optional)
26+
SELECT *, 'id', 'id attribute injected as an anchor in HTML. It can be used for scrolling to this item through links (use "#id" in link url)', 'TEXT', TRUE
27+
FROM (VALUES
28+
('steps', TRUE)
29+
);
30+
31+
-- 3
32+
INSERT INTO parameter(component, top_level, name, description, type, optional)
33+
SELECT *, 'class', 'class attribute added to the container in HTML. It can be used to apply custom styling to this item through css', 'TEXT', TRUE
34+
FROM (VALUES
35+
('alert', TRUE),
36+
('breadcrumb', TRUE),
37+
('button', TRUE),
38+
('card', FALSE),
39+
('chart', TRUE),
40+
-- ('code', TRUE),
41+
('csv', TRUE),
42+
('datagrid', TRUE),
43+
('divider', TRUE),
44+
('form', TRUE),
45+
('list', TRUE),
46+
('list', FALSE),
47+
('map', TRUE),
48+
('tab', FALSE),
49+
('table', TRUE),
50+
('timeline', TRUE),
51+
('timeline', FALSE),
52+
-- ('title', TRUE),
53+
('tracking', TRUE)
54+
);
55+

examples/official-site/sqlpage/sqlpage.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
database_url: "sqlite::memory:"
33

44
# We have a file upload example, and would like to limit the size of the uploaded files
5-
max_uploaded_file_size: 256000
5+
max_uploaded_file_size: 256000
6+
7+
listen_on: "0.0.0.0:9898"
8+

sqlpage/templates/alert.handlebars

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
<div class="
2-
alert
3-
alert-{{default color "info"}}
4-
{{#if dismissible}}alert-dismissible{{/if}}
5-
{{#if important}}alert-important{{/if}}
6-
" role="alert">
1+
<div
2+
{{#if id}}id="{{id}}"{{/if}}
3+
class="
4+
alert
5+
alert-{{default color "info"}}
6+
{{#if dismissible}}alert-dismissible{{/if}}
7+
{{#if important}}alert-important{{/if}}
8+
{{class}}
9+
"
10+
role="alert"
11+
>
712
<div class="d-flex">
813

914
{{#if icon}}

sqlpage/templates/breadcrumb.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<nav aria-label="breadcrumb" class="my-1">
1+
<nav {{#if id}}id="{{id}}"{{/if}} aria-label="breadcrumb" class="my-1 {{class}}">
22
<ol class="breadcrumb">
33
{{#each_row}}
44
<li class="breadcrumb-item{{#if active}} active{{/if}}" {{#if active}}aria-current="page"{{/if}}>

sqlpage/templates/button.handlebars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="btn-list mb-2 {{#if justify}}justify-content-{{justify}}{{/if}}">
1+
<div class="btn-list mb-2 {{#if justify}}justify-content-{{justify}}{{/if}} {{class}}">
22
{{#each_row}}
33
{{#if form}}
44
<button type="submit" form="{{form}}" {{#if link}}formaction="{{link}}"{{/if}}
@@ -22,4 +22,4 @@
2222
</a>
2323
{{/if}}
2424
{{/each_row}}
25-
</div>
25+
</div>

sqlpage/templates/card.handlebars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
row-cols-xl-5
2121
{{/if}}
2222
gx-2 gy-2
23-
mt-1 mb-3">
23+
mt-1 mb-3 {{class}}">
2424
{{#each_row}}
25-
<div class="col">
25+
<div class="col {{class}}" {{#if id}}id="{{id}}"{{/if}}>
2626
<div class="card h-100 {{#if active}}card-active{{/if}}" {{#if embed }}data-pre-init="card" data-embed="{{embed}}"{{/if}}>
2727
{{#if link}}
2828
<a href="{{link}}" style="text-decoration: inherit; color: inherit">

sqlpage/templates/chart.handlebars

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
<div class="card my-2" data-pre-init="chart" data-js="/{{static_path 'apexcharts.js'}}">
1+
<div
2+
{{#if id}}id="{{id}}"{{/if}}
3+
class="card my-2 {{class}}"
4+
data-pre-init="chart"
5+
data-js="/{{static_path 'apexcharts.js'}}"
6+
>
27
<div class="card-body">
38
<div class="d-flex">
49
<h3 class="card-title">{{title}}</h3>

sqlpage/templates/code.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="code-component my-1">
1+
<div class="code-component my-1 {{class}}" {{#if id}}id="{{id}}"{{/if}}>
22
{{#each_row}}
33
<h2>{{title}}</h2>
44
<p>{{description}}</p>

0 commit comments

Comments
 (0)