Skip to content

Commit 3f51185

Browse files
committed
change_percent without description in the big_number
fix #688
1 parent 50a9cf2 commit 3f51185

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- Adds support for setting column names with an `=` sign, like `SELECT some_property = (a*b) FROM some_table` in mssql
3030
- Adds support for the `LIMIT max_rows, offset` syntax in SQLite. https://www.sqlite.org/lang_select.html#limitoffset
3131
- Adds support for `ANY`, `ALL`, and `SOME` subqueries, like `SELECT * FROM t WHERE a = ANY (SELECT b FROM t2)`
32+
- Add support for `change_percent` without `description` in the big_number component to display the percentage change of a value.
3233

3334
## 0.30.1 (2024-10-31)
3435
- fix a bug where table sorting would break if table search was not also enabled.

examples/official-site/sqlpage/migrations/49_big_number.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ INSERT INTO example(component, description, properties) VALUES
5050
{"component":"big_number", "columns":3, "id":"colorfull_dashboard"},
5151
{"title":"Users", "value":"1,234", "color": "red" },
5252
{"title":"Orders", "value":56, "color": "green" },
53-
{"title":"Revenue", "value":"9,876", "unit": "€", "color": "blue", "dropdown_item": [
53+
{"title":"Revenue", "value":"9,876", "unit": "€", "color": "blue", "change_percent": -7, "dropdown_item": [
5454
{"label":"This week", "link":"?days=7&component=big_number#colorfull_dashboard"},
5555
{"label":"This month", "link":"?days=30&component=big_number#colorfull_dashboard"},
5656
{"label":"This quarter", "link":"?days=90&component=big_number#colorfull_dashboard"}

sqlpage/templates/big_number.handlebars

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,23 @@
3131
{{/if}}
3232
</div>
3333
{{/if~}}
34-
<div class="h1 {{#if description}}mb-3{{/if}} mt-auto text-nowrap text-truncate">{{value}}{{#if unit}} {{unit}}{{/if}}</div>
34+
<div class="d-flex align-items-center mt-1">
35+
<div class="h1 {{#if description}}mb-3{{else}}mb-0{{/if}} mt-auto text-nowrap text-truncate">{{value}}{{#if unit}} {{unit}}{{/if}}</div>
36+
{{#if (and change_percent (not description))}}
37+
<div class="ms-auto">
38+
{{#if change_percent}}
39+
<span class="text-{{#if (gte change_percent 0)}}success{{else}}danger{{/if}} d-inline-flex align-items-center lh-1">
40+
{{change_percent}}%
41+
{{#if (gte change_percent 0)}}
42+
{{~icon_img 'trending-up'~}}
43+
{{else}}
44+
{{~icon_img 'trending-down'~}}
45+
{{/if}}
46+
</span>
47+
{{/if}}
48+
</div>
49+
{{/if}}
50+
</div>
3551
{{~#if description}}
3652
<div class="d-flex flex-wrap mb-2" title="{{description}}">
3753
<div class="text-truncate me-2">{{description}}</div>

0 commit comments

Comments
 (0)