Skip to content

Commit 49ee73b

Browse files
Modal component
1 parent 0354c6d commit 49ee73b

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
INSERT INTO component(name, icon, description, introduced_in_version) VALUES
2+
('modal', 'app-window', 'Defines the content of a modal box. Useful for displaying additional information or help.', '0.36.0');
3+
4+
INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'modal', * FROM (VALUES
5+
('title','Description of the modal box.','TEXT',TRUE,FALSE),
6+
('close','The text to display in the Close button.','TEXT',TRUE,FALSE),
7+
('contents','A paragraph of text to display, without any formatting, without having to make additional queries.','TEXT',FALSE,TRUE),
8+
('contents_md','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).','TEXT',FALSE,TRUE),
9+
('unsafe_contents_md','Markdown format with html blocks. Use this only with trusted content. See the html-blocks section of the Commonmark spec for additional info.','TEXT',FALSE,TRUE),
10+
('scrollable','Dreate a scrollable modal that allows scroll the modal body.','BOOLEAN',TRUE,TRUE),
11+
('class','Class attribute added to the container in HTML. It can be used to apply custom styling to this item through css.','TEXT',TRUE,TRUE),
12+
('id','ID attribute added to the container in HTML. It can be used to target this item through css or for displaying this item.','TEXT',TRUE,FALSE)
13+
) x;
14+
15+
INSERT INTO example(component, description, properties) VALUES
16+
('modal',
17+
'This example shows how to create a modal box that displays a paragraph of text. The modal window is opened with the help of a button.',
18+
json('[
19+
{"component": "modal","id": "my_modal","title": "A modal box","close": "Close"},
20+
{"contents":"I''m a modal window, and I allow you to display additional information or help for the user."},
21+
{"component": "button"},
22+
{"title":"Open","modal":"my_modal"}
23+
]')
24+
);
25+
26+
INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'button', * FROM (VALUES
27+
('modal','Display the modal window corresponding to the specified ID.','TEXT',FALSE,TRUE)
28+
) x;

sqlpage/templates/modal.handlebars

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<div class="modal{{~#if class}} {{class}}{{/if~}}" id="{{id}}" tabindex="-1" aria-hidden="false" aria-labelledby="{{title}}">
2+
<div class="modal-dialog{{#if scrollable}} modal-dialog-scrollable"{{/if}} role="document">
3+
<div class="modal-content">
4+
<div class="modal-header">
5+
<h5 class="modal-title">{{title}}</h5>
6+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{{close}}"></button>
7+
</div>
8+
<div class="modal-body">
9+
{{~#each_row~}}
10+
<p>
11+
{{~#if contents_md~}}
12+
{{{markdown contents_md}}}
13+
{{else}}
14+
{{~#if unsafe_contents_md~}}
15+
{{{markdown unsafe_contents_md 'allow_unsafe'}}}
16+
{{else}}
17+
{{~contents~}}
18+
{{~/if~}}
19+
{{~/if~}}
20+
</p>
21+
{{~/each_row~}}
22+
</div>
23+
<div class="modal-footer">
24+
<button type="button" class="btn me-primary" data-bs-dismiss="modal">{{close}}</button>
25+
</div>
26+
</div>
27+
</div>
28+
</div>

0 commit comments

Comments
 (0)