Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## unreleased

- Set `wrap` on a `big_number` component to show long titles and descriptions across multiple lines.

## v0.48.0 (2026-11-12)

- Updated Rust and browser dependencies, including ApexCharts 8.8.1, Tabler 1.7.4, Tabler icons 3.51, and Tom Select 2.7. Chart series names and labels now display HTML as text, fixing upstream script injection in legends and tooltips.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ INSERT INTO component(name, icon, description, introduced_in_version) VALUES
INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'big_number', * FROM (VALUES
-- Top-level parameters (for the whole big_number list)
('columns', 'The number of columns to display the big numbers in (default is one column per item).', 'INTEGER', TRUE, TRUE),
('wrap', 'Wrap long titles and descriptions onto multiple lines. By default, they are truncated with an ellipsis.', 'BOOLEAN', TRUE, TRUE),
-- id and class, at both levels, come from 99_shared_id_class_attributes.sql
-- Item-level parameters (for each big number)
('title', 'The title or label for the big number.', 'TEXT', FALSE, TRUE),
Expand Down
6 changes: 3 additions & 3 deletions sqlpage/templates/big_number.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
{{#unless ../columns}}style="min-width: 9rem;"{{/unless}}
{{~#if id}} id="{{id}}"{{/if~}}
>
<div class="card flex-fill {{#if color}}bg-{{color}}-lt{{/if}}" style="--tblr-card-spacer-y: 1rem;">
<div class="card flex-fill {{#if ../wrap}}h-100 {{/if}}{{#if color}}bg-{{color}}-lt{{/if}}" style="--tblr-card-spacer-y: 1rem;">
<div class="card-body d-flex flex-column">

{{#if title}}
<div class="d-flex align-items-center">
<div class="subheader text-truncate me-2">
<div class="subheader me-2{{#unless ../wrap}} text-truncate{{/unless}}"{{#if ../wrap}} style="overflow-wrap: anywhere;"{{/if}}>
{{#if title_link}}
<a href="{{title_link}}" class="text-decoration-none"
{{#if title_link_new_tab}}
Expand Down Expand Up @@ -79,7 +79,7 @@

{{#if description}}
<div class="d-flex flex-wrap mb-2" title="{{description}}">
<div class="text-truncate me-2">{{description}}</div>
<div class="me-2{{#unless ../wrap}} text-truncate{{/unless}}"{{#if ../wrap}} style="overflow-wrap: anywhere;"{{/if}}>{{description}}</div>
{{#if change_percent}}
<div class="ms-auto">
<span class="text-{{#if (gte change_percent 0)}}success{{else}}danger{{/if}} d-inline-flex align-items-center lh-1">
Expand Down
10 changes: 10 additions & 0 deletions tests/end-to-end/fixtures/big-number/index.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ SELECT
'default-color' AS id,
'Default value' AS title,
'9,012' AS value;

SELECT 'big_number' AS component, 2 AS columns, $wrap = 'true' AS wrap;

SELECT
'long-text' AS id,
'Items checked across all locations during the reporting period' AS title,
120 AS value,
'Includes items from the main collection and all storage locations.' AS description;

SELECT 'short-text' AS id, 'Locations' AS title, 8 AS value;
34 changes: 34 additions & 0 deletions tests/end-to-end/fixtures/big-number/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,37 @@ for (const theme of ["light", "dark"]) {
}
});
}

test("long titles and descriptions wrap only when requested", async ({
page,
}) => {
await page.setViewportSize({ width: 640, height: 800 });
for (const wrap of [false, true]) {
await page.goto(`/big-number/?wrap=${wrap}`);
const card = page.locator("#long-text .card");
const title = card.getByText("Items checked across all locations", {
exact: false,
});
const description = card.getByText(
"Includes items from the main collection",
{
exact: false,
},
);
for (const text of [title, description]) {
const layout = await text.evaluate((element) => ({
clipped: element.scrollWidth > element.clientWidth,
multiline:
element.clientHeight >
1.5 * Number.parseFloat(getComputedStyle(element).lineHeight),
}));
expect(layout).toEqual({ clipped: !wrap, multiline: wrap });
}
if (wrap) {
const neighbor = page.locator("#short-text .card");
expect((await card.boundingBox())?.height).toBe(
(await neighbor.boundingBox())?.height,
);
}
}
});
Loading