Skip to content

Commit f882797

Browse files
committed
new attributes in the datagrid component
1 parent 0cb4cf7 commit f882797

File tree

5 files changed

+45
-17
lines changed

5 files changed

+45
-17
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CHANGELOG.md
22

3-
## 0.17.1 (unreleased)
3+
## 0.17.1 (2023-12-10)
44

55
- The previous version reduced log verbosity, but also removed the ability to see the HTTP requests in the logs.
66
This is now fixed, and you can see the HTTP requests again. Logging is still less verbose than before, but you can enable debug logs by setting the `RUST_LOG` environment variable to `debug`, or to `sqlpage=debug` to only see SQLPage debug logs.
@@ -17,8 +17,9 @@
1717
- New function: [`sqlpage.protocol`](https://sql.ophir.dev/functions.sql?function=protocol#function) to get the protocol used to access the current page. This is useful to build links that point to your own site, and work both in http and https.
1818
- Add an example to the documentation showing how to create heatmaps with the [chart](https://sql.ophir.dev/documentation.sql?component=chart#component) component.
1919
- 18 new icons available: https://tabler.io/icons/changelog#2.43
20+
- New top-level attributes for the [`datagrid`](https://sql.ophir.dev/documentation.sql?component=datagrid#component) component: `description`, `description_md` , `icon` , `image_url`.
2021

21-
## 0.17.0
22+
## 0.17.0 (2023-11-28)
2223

2324
### Uploads
2425

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ INSERT INTO component(name, icon, description) VALUES
106106
INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'datagrid', * FROM (VALUES
107107
-- top level
108108
('title', 'Text header at the top of the data grid.', 'TEXT', TRUE, TRUE),
109+
('description', 'A short paragraph displayed below the title.', 'TEXT', TRUE, TRUE),
110+
('description_md', 'A short paragraph displayed below the title - formatted using markdown.', 'TEXT', TRUE, TRUE),
111+
('icon', 'Name of an icon to display on the left side of the title.', 'ICON', TRUE, TRUE),
112+
('image_url', 'URL of an image to display on the left side of the title.', 'URL', TRUE, TRUE),
109113
-- item level
110114
('title', 'Name of the piece of information.', 'TEXT', FALSE, FALSE),
111115
('description', 'Value to display below the name.', 'TEXT', FALSE, TRUE),
@@ -120,13 +124,17 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
120124
INSERT INTO example(component, description, properties) VALUES
121125
('datagrid', 'Just some sections of information.', json('[{"component":"datagrid"},{"title":"Language","description":"SQL"},{"title":"Creation date","description":"1974"}, {"title":"Language family","description":"Query language"}]')),
122126
('datagrid', 'A beautiful data grid with nice colors and icons.',
123-
json('[{"component":"datagrid", "title":"User"}, '||
124-
'{"title": "Pseudo", "description": "lovasoa", "image_url": "https://avatars.githubusercontent.com/u/552629" },' ||
125-
'{"title": "Status", "description": "Active", "color": "green"},' ||
126-
'{"title": "Email Status", "description": "Validated", "icon": "check", "active": true},' ||
127-
'{"title": "Personal page", "description": "ophir.dev", "link": "https://ophir.dev/"},' ||
128-
'{"title":"Search engine", "link":"https://google.com", "description": "Google", "color": "red", "icon":"brand-google", "footer": "Owned by Alphabet Inc."}, '||
129-
'{"title":"Encyclopedia", "link":"https://wikipedia.org", "description": "Wikipedia", "color": "blue", "icon":"world", "footer": "Owned by the Wikimedia Foundation"}]'));
127+
json('[{"component":"datagrid", "title": "Ophir Lojkine", "image_url": "https://avatars.githubusercontent.com/u/552629", "description_md": "Member since **2021**"},
128+
{"title": "Pseudo", "description": "lovasoa", "image_url": "https://avatars.githubusercontent.com/u/552629" },
129+
{"title": "Status", "description": "Active", "color": "green"},
130+
{"title": "Email Status", "description": "Validated", "icon": "check", "active": true},
131+
{"title": "Personal page", "description": "ophir.dev", "link": "https://ophir.dev/"}
132+
]')),
133+
('datagrid', 'Using a picture in the data grid card header.', json('[
134+
{"component":"datagrid", "title": "Website Ideas", "icon": "bulb"},
135+
{"title": "Search engine", "link":"https://google.com", "description": "Google", "color": "red", "icon":"brand-google", "footer": "Owned by Alphabet Inc."},
136+
{"title": "Encyclopedia", "link":"https://wikipedia.org", "description": "Wikipedia", "color": "blue", "icon":"world", "footer": "Owned by the Wikimedia Foundation"}
137+
]'));
130138

131139

132140
INSERT INTO component(name, icon, description) VALUES

sqlpage/sqlpage.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ td > p {
1111
margin: 0;
1212
}
1313

14+
/** Removes the margin-bottom from the last element */
15+
.remove-bottom-margin > :last-child {
16+
margin-bottom: 0 !important;
17+
}
18+
1419
/* https://github.com/tabler/tabler/issues/1648 */
1520
* {
1621
scrollbar-color: var(--tblr-primary) var(--tblr-bg-surface-dark) !important;

sqlpage/templates/datagrid.handlebars

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
<div class="card my-2">
22
{{#if title}}
33
<div class="card-header">
4-
<h2 class="card-title">{{title}}</h2>
4+
{{#if image_url}}
5+
<img src="{{image_url}}" class="avatar avatar-lg me-2 rounded" width="32" height="32" alt="{{title}}" />
6+
{{/if}}
7+
{{#if icon}}
8+
<span class="avatar avatar-sm me-2">{{icon_img icon}}</span>
9+
{{/if}}
10+
<h2 class="card-title">
11+
{{~title~}}
12+
{{#if description}}
13+
<small class="text-muted d-block">{{description}}</small>
14+
{{/if}}
15+
{{#if description_md}}
16+
<small class="text-muted d-block remove-bottom-margin">{{{markdown description_md}}}</small>
17+
{{/if}}
18+
</h2>
519
</div>
620
{{/if}}
721
<div class="card-body">
@@ -15,7 +29,7 @@
1529
<span class="status status-{{color}} {{#if active}}fw-bold{{/if}}">
1630
{{/if}}
1731
{{#if image_url}}
18-
<img src="{{image_url}}" class="avatar avatar-xs me-2 rounded" width="32" height="32" alt="{{title}}" />
32+
<img src="{{image_url}}" class="avatar avatar-xs me-1 rounded" width="32" height="32" alt="{{title}}" />
1933
{{/if}}
2034
{{#if icon}}
2135
{{~icon_img icon~}}

0 commit comments

Comments
 (0)