-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a modifier for tables with lots of data #4630
Conversation
📋 StatsFile sizes
Modules
View stats and visualisations on the review app Action run for 30d1ce8 |
Stylesheets changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css b/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css
index 8133c4408..de1d6fec7 100644
--- a/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css
+++ b/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css
@@ -5130,6 +5130,32 @@ screen and (-ms-high-contrast:active) {
}
}
+.govuk-table--small-text-until-tablet {
+ font-size: 1rem;
+ line-height: 1.25
+}
+
+@media print {
+ .govuk-table--small-text-until-tablet {
+ font-size: 14pt;
+ line-height: 1.2
+ }
+}
+
+@media (min-width:40.0625em) {
+ .govuk-table--small-text-until-tablet {
+ font-size: 1.1875rem;
+ line-height: 1.3157894737
+ }
+}
+
+@media print and (min-width:40.0625em) {
+ .govuk-table--small-text-until-tablet {
+ font-size: 14pt;
+ line-height: 1.15
+ }
+}
+
.govuk-table__header {
font-weight: 700
}
Action run for 30d1ce8 |
Other changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/components/table/_index.scss b/packages/govuk-frontend/dist/govuk/components/table/_index.scss
index c847ba233..5bb7bca5c 100644
--- a/packages/govuk-frontend/dist/govuk/components/table/_index.scss
+++ b/packages/govuk-frontend/dist/govuk/components/table/_index.scss
@@ -9,6 +9,16 @@
border-collapse: collapse;
}
+ // Modifier for tables with a lot of data. Tables with lots of data benefit
+ // from a smaller font size on small screens.
+ .govuk-table--small-text-until-tablet {
+ @include govuk-font-size($size: 16);
+
+ @include govuk-media-query($from: tablet) {
+ @include govuk-font-size($size: 19);
+ }
+ }
+
.govuk-table__header {
@include govuk-typography-weight-bold;
}
diff --git a/packages/govuk-frontend/dist/govuk/components/table/fixtures.json b/packages/govuk-frontend/dist/govuk/components/table/fixtures.json
index 6b9357731..6fe6b0d38 100644
--- a/packages/govuk-frontend/dist/govuk/components/table/fixtures.json
+++ b/packages/govuk-frontend/dist/govuk/components/table/fixtures.json
@@ -180,6 +180,57 @@
"previewLayoutModifiers": [],
"html": "<table class=\"govuk-table\">\n <caption class=\"govuk-table__caption govuk-table__caption--m\">Caption 1: Months and rates</caption>\n <thead class=\"govuk-table__head\">\n <tr class=\"govuk-table__row\">\n <th scope=\"col\" class=\"govuk-table__header\">Month you apply</th>\n <th scope=\"col\" class=\"govuk-table__header govuk-table__header--numeric\">Rate for bicycles</th>\n <th scope=\"col\" class=\"govuk-table__header govuk-table__header--numeric\">Rate for vehicles</th>\n </tr>\n </thead>\n <tbody class=\"govuk-table__body\">\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">January</th>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£85</td>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£95</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">February</th>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£75</td>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£55</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <th scope=\"row\" class=\"govuk-table__header\">March</th>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£165</td>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£125</td>\n </tr>\n </tbody>\n</table>"
},
+ {
+ "name": "with small text modifier for tables with a lot of data",
+ "options": {
+ "classes": "govuk-table--small-text-until-tablet",
+ "rows": [
+ [
+ {
+ "text": "January"
+ },
+ {
+ "text": "£85",
+ "format": "numeric"
+ },
+ {
+ "text": "£95",
+ "format": "numeric"
+ }
+ ],
+ [
+ {
+ "text": "February"
+ },
+ {
+ "text": "£75",
+ "format": "numeric"
+ },
+ {
+ "text": "£55",
+ "format": "numeric"
+ }
+ ],
+ [
+ {
+ "text": "March"
+ },
+ {
+ "text": "£165",
+ "format": "numeric"
+ },
+ {
+ "text": "£125",
+ "format": "numeric"
+ }
+ ]
+ ]
+ },
+ "hidden": false,
+ "description": "",
+ "previewLayoutModifiers": [],
+ "html": "<table class=\"govuk-table govuk-table--small-text-until-tablet\">\n <tbody class=\"govuk-table__body\">\n <tr class=\"govuk-table__row\">\n <td class=\"govuk-table__cell\">January</td>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£85</td>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£95</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <td class=\"govuk-table__cell\">February</td>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£75</td>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£55</td>\n </tr>\n <tr class=\"govuk-table__row\">\n <td class=\"govuk-table__cell\">March</td>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£165</td>\n <td class=\"govuk-table__cell govuk-table__cell--numeric\">£125</td>\n </tr>\n </tbody>\n</table>"
+ },
{
"name": "classes",
"options": {
Action run for 30d1ce8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little unsure of how suitable complex
is for the name of a modifier class.
From what I can gather, most of the modifier classes in Frontend describe either the state (e.g. govuk-input--error
, govuk-tabs__panel--hidden
, govuk-pagination__item--current
) or the appearance (e.g. govuk-link--no-underline
, govuk-input--extra-letter-spacing
, govuk-tag--yellow
).
complex
is a descriptor of the contents of the table, rather than the state or appearance of it1, and there is a potential for a disconnect between what is considered 'complex' and what kind of data would actually benefit from having a smaller text size.
A table with three-columns for say, name, job title, and organisation isn't complex per se, but as each cell can contain reasonably long text, it could easily overflow a narrow screen on the default font-size. A three-column table where they all contain short words or numeric values is just as structurally 'complex', but can get away with the larger font-size.
Would a name like small
or smaller-text
better describe the modifier?
Footnotes
-
This isn't unheard of, tables also have
govuk-table__cell--numeric
which is arguably doing the same (though it could be considered appearance-based too, as it activates tabular numbers), but it does feel like those kinds of modifiers are the exception rather than the rule. ↩
@querkmachine That's a very good point. What do you think about |
@owenatgov I guess the question that spawns is that, as the other one uses I think |
@querkmachine More good points. what about |
@owenatgov Oh yeah, that sounds better. More consistent with the |
f16b25c
to
05648d3
Compare
// Modifier for complex tables. Very complex tables benefit from a smaller | ||
// font size on small screens. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy with the code itself. Still wonder if this comment and the name of the review app example now need to be amended to something other than 'complex table' though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone with "tables with a lot of data" which is complies with your point on complexity not necessarily being the barometer. Whatcha think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me 👍
05648d3
to
30d1ce8
Compare
Adds
govuk-table--small-text-until-tablet
for instances where users have complex tables which benefit from smaller text on smaller screens.Merging into the type-scale branch, not main.
Fixes #3922