Skip to content

Commit 32778bf

Browse files
New component : Empty state (#890)
* empty_state component added * empty_state component added * Correction and new example * rename status_code to header * Enhance empty_state component documentation and template to support rich text formatting. Update docs with detailed descriptions and examples, and modify Handlebars template to conditionally render Markdown content. * add and document class and id attributes --------- Co-authored-by: lovasoa <contact@ophir.dev>
1 parent 5979e31 commit 32778bf

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
INSERT INTO component(name, icon, description, introduced_in_version) VALUES
2+
('empty_state', 'info-circle', 'Displays a large placeholder message to communicate a single information to the user and invite them to take action.
3+
4+
Typically includes a title, an optional icon/image, descriptive text (rich text formatting and images supported via Markdown), and a call-to-action button.
5+
6+
Ideal for first-use screens, empty data sets, "no results" pages, or error messages.', '0.35.0');
7+
8+
INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'empty_state', * FROM (VALUES
9+
('title','Description of the empty state.','TEXT',TRUE,FALSE),
10+
('header','Text displayed on the top of the empty state.','TEXT',TRUE,TRUE),
11+
('icon','Name of an icon to be displayed on the top of the empty state.','ICON',TRUE,TRUE),
12+
('image','The URL (absolute or relative) of an image to display at the top of the empty state.','URL',TRUE,TRUE),
13+
('description','A short text displayed below the title.','TEXT',TRUE,TRUE),
14+
('link_text','The text displayed on the button.','TEXT',TRUE,FALSE),
15+
('link_icon','Name of an icon to be displayed on the left side of the button.','ICON',TRUE,FALSE),
16+
('link','The URL to which the button should navigate when clicked.','URL',TRUE,FALSE),
17+
('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),
18+
('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,TRUE)
19+
) x;
20+
21+
INSERT INTO example(component, description, properties) VALUES
22+
('empty_state', '
23+
This example shows how to create a 404-style "Not Found" empty state with
24+
- a prominent header displaying "404",
25+
- a helpful description suggesting to adjust search parameters, and
26+
- a "Search again" button with a search icon that links back to the search page.
27+
',
28+
json('[{
29+
"component": "empty_state",
30+
"title": "No results found",
31+
"header": "404",
32+
"description": "Try adjusting your search or filter to find what you''re looking for.",
33+
"link_text": "Search again",
34+
"link_icon": "search",
35+
"link": "#not-found",
36+
"id": "not-found"
37+
}]')),
38+
('empty_state', '
39+
It''s possible to use an icon or an image to illustrate the problem.
40+
',
41+
json('[{
42+
"component": "empty_state",
43+
"title": "A critical problem has occurred",
44+
"icon": "mood-wrrr",
45+
"description_md": "SQLPage can do a lot of things, but this is not one of them.
46+
47+
Please restart your browser and **cross your fingers**.",
48+
"link_text": "Close and restart",
49+
"link_icon": "rotate-clockwise",
50+
"link": "#"
51+
}]'));
52+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div class="empty{{#if class}} {{class}}{{/if}}"{{#if id}} id="{{id}}"{{/if}}>
2+
{{#if header}}
3+
<div class="empty-header">{{header}}</div>
4+
{{else}}
5+
{{#if icon}}
6+
<div class="empty-icon">
7+
<span>{{icon_img icon }}</span>
8+
</div>
9+
{{else}}
10+
{{#if image}}
11+
<div class="empty-img"><img src="{{image}}" height="128" alt="{{image}}"/></div>
12+
{{/if}}
13+
{{/if}}
14+
{{/if}}
15+
<p class="empty-title">{{title}}</p>
16+
<div class="empty-subtitle text-secondary remove-bottom-margin">
17+
{{~#if description}}<p>{{description}}</p>{{/if~}}
18+
{{~#if description_md~}}
19+
{{{markdown description_md}}}
20+
{{~/if~}}
21+
</div>
22+
23+
<div class="empty-action">
24+
<a href="{{link}}" class="btn btn-primary">
25+
<span class="me-1">{{icon_img link_icon}}</span>
26+
{{link_text}}
27+
</a>
28+
</div>
29+
</div>

0 commit comments

Comments
 (0)