Skip to content

Commit 11ed4fa

Browse files
committed
add tooltips in datagrid
fixes #425
1 parent f826168 commit 11ed4fa

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
8383
('link', 'A target URL to which the user should be taken when they click on the value.', 'URL', FALSE, TRUE),
8484
('icon', 'An icon name (from tabler-icons.io) to display on the left side of the value.', 'ICON', FALSE, TRUE),
8585
('color', 'If set to a color name, the value will be displayed in a pill of that color.', 'COLOR', FALSE, TRUE),
86-
('active', 'Whether this item in the grid is considered "active". Active items are displayed more prominently.', 'BOOLEAN', FALSE, TRUE)
86+
('active', 'Whether this item in the grid is considered "active". Active items are displayed more prominently.', 'BOOLEAN', FALSE, TRUE),
87+
('tooltip', 'A tooltip to display when the user passes their mouse over the value.', 'TEXT', FALSE, TRUE)
8788
) x;
8889

8990
INSERT INTO example(component, description, properties) VALUES
@@ -92,8 +93,8 @@ INSERT INTO example(component, description, properties) VALUES
9293
json('[{"component":"datagrid", "title": "Ophir Lojkine", "image_url": "https://avatars.githubusercontent.com/u/552629", "description_md": "Member since **2021**"},
9394
{"title": "Pseudo", "description": "lovasoa", "image_url": "https://avatars.githubusercontent.com/u/552629" },
9495
{"title": "Status", "description": "Active", "color": "green"},
95-
{"title": "Email Status", "description": "Validated", "icon": "check", "active": true},
96-
{"title": "Personal page", "description": "ophir.dev", "link": "https://ophir.dev/"}
96+
{"title": "Email Status", "description": "Validated", "icon": "check", "active": true, "tooltip": "Email address has been validated."},
97+
{"title": "Personal page", "description": "ophir.dev", "link": "https://ophir.dev/", "tooltip": "About me"}
9798
]')),
9899
('datagrid', 'Using a picture in the data grid card header.', json('[
99100
{"component":"datagrid", "title": "Website Ideas", "icon": "bulb"},

sqlpage/templates/datagrid.handlebars

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@
2424
<div class="datagrid-item">
2525
<div class="datagrid-title">{{title}}</div>
2626
<div class="datagrid-content {{#if active}}fw-bold{{/if}}">
27-
{{#if link}}<a href="{{link}}">{{/if}}
27+
{{~#if link}}
28+
<a href="{{link}}"
29+
{{~else~}}
30+
<span
31+
{{/if~}}
32+
{{~#if tooltip}} data-bs-toggle="tooltip" data-bs-placement="top" title="{{tooltip}}"{{/if}}
33+
>
2834
{{#if color}}
2935
<span class="status status-{{color}} {{#if active}}fw-bold{{/if}}">
3036
{{/if}}
@@ -42,7 +48,11 @@
4248
{{#if color}}
4349
</span>
4450
{{/if}}
45-
{{#if link}}</a>{{/if}}
51+
{{~#if link~}}
52+
</a>
53+
{{~else~}}
54+
</span>
55+
{{~/if~}}
4656
{{#if footer}}
4757
<small class="text-muted d-block">{{footer}}</small>
4858
{{/if}}

0 commit comments

Comments
 (0)