Closed chris-gds closed 3 years ago
We present the big numbers component as part of a list of values~with an optional heading. The default heading level is h3
unless otherwise specified~. Each value will be a number, can have an associated "label" (not a literal label tag) and can be a link. The latter 2 attributes of the component are optional.
Users can also communicate that a number is a "minimum" to a given value by adding a "+" to the end of the number eg: 400+ government agencies.
<%= render "govuk_publishing_components/components/big_number", {
items: [
{
number: 116,
label: "Open consultations",
href: "/government/publications?publication_filter_option=open-consultations",
},
{
number: 553,
label: "Closed consultations in the past 12 months",
href: "/government/publications?publication_filter_option=open-consultations",
},
],
} %>
<%= render "govuk_publishing_components/components/big_number", {
items: [
{
number: 23,
label: "Ministerial departments",
href: "/organisations#ministerial_departments",
},
{
number: 400,
show_plus: true,
label: "Other agencies",
href: "/councils",
},
],
} %>
<%= render "govuk_publishing_components/components/big_number", {
heading: "Ministerial departments",
heading_level: 2,
items: [
{
number: 23,
},
],
} %>
The below is based on the above API proposal.
Number values should be split into list items within an unordered list unless they are a single value, in which case the markup for the value itself will be produced.
Each value item should primarily consist of a span
containing the number itself. If a label is present, a second span
will be present containing the label. If a href is specified, the element will be wrapped in a link.
The heading should use the heading component and will ingest the heading_level attribute if present.
There should be no need for any additional attributes such as aria or data at this stage. There is no tracking on any uses of the big number presently and it is standard practice on the components gem to only extend components as and when we need to.
The explore team will soon be iterating on the gov.uk homepage. Included in the proposed design is a unified version of the big number component, as used on the homepage. I've discussed this with the designer and propose the following:
We should use a similar hover behaviour to that seen on the previous and next navigation where, if present, the label is the visual indicator of hover wherein the line thickness will change as per the standard govuk-link
behaviour. Otherwise the number will include an underline on hover.
The label should be separated from the associated number using a pseudo element to mock a block-level relationship, like so:
.gem-c-big-number__label {
&:before {
content: "";
display: block;
}
}
This is to bypass a quirk of NVDA where anything listed as block-level is dictated separately. Whilst not a WCAG fail, it could be a jarring experience for NVDA users.
The focus state should not need to be updated with any additional styling.
The above proposition sounds good to me 👍
The heading should use the heading component and will ingest the heading_level attribute if present.
In regards to the heading, I would avoid nesting components, if possible (as we may need more flexibility), in favour of using helpers/presenters – this was we share the logic without introducing interdependencies.
After chatting to Alex outside of this issue I've decided to remove the option to include a heading in the component. This feature is infrequent enough that it's presently reasonable to simple ask the developer to use a heading component outside the big number component if they need one.
A couple of updates:
Can this be closed, as https://github.com/alphagov/govuk_publishing_components/pull/2278 has been merged in?
I'm gonna hold off on closing as we haven't rolled the component out and it isn't being used anywhere yet. I've got a plan to look into getting it onto the site this week.
As the work on this has progressed quite significantly and we now have the component and at least have PR's on it in multiple places, I'm calling this closed.
What
"Big numbers" was an element that we believe qualifies for being a Component
Why
Reasons for doing this:
Visuals
More context