-
Notifications
You must be signed in to change notification settings - Fork 325
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
Investigate ways to let users customise the typography scale in govuk-font
#3837
Comments
Initial investigationI explored 4 initial solutions:
Draft implementations for these solutions can be found in the commits of my test branch. Further details can be found in the comments under each commit. Summary of findingsA problem which ran through the first 3 solutions is: what does the user think the scale value will result in? For example if in any of the solutions a user picks a "default" of 24 and an "override" of 19, what should we return? Should we return "tablet" map with a 19px font size or the "null" map which is a 16px font size, intended for small screens? The ideology of our font scale maps within maps within a map system and the naming therein doesn't make it clear what a scale value's "default" will be. This led to solution 4 where the user can pick a specific font map by scale value and breakpoint and reapply it to the scale map they initially picked. Further thoughtsThis was discussed with the other design system devs and the followings ideas and points were raised: Letting users build their own font mapsCould we simply pass a map to @include govuk-font(
$size: (
null: (
font-size: 15px,
line-height: 2
),
print: (
font-size: 10pt,
line-height: 2
)
)
); You could extend this by combining it with my 4th solution where the override map we use isn't itself navigation to a point on the scale but a font-scale format map which we just replace on the pulled scale map at the specified breakpoint: @include govuk-font(
$size: 19,
$scale-override: (
tablet: (
font-size: 21px,
line-height: 2
)
)
); You could add checks to make sure that the map passed followed the format of our font maps. This would reduce how much interaction we have with Is
|
I've explored the 2nd heading aka: changing how users interact with fonts and the typography scale. I've made a proof of concept in this commit. Breaking it down, I'm proposing to split
You can see an example of how this would be implemented in my proof of concept commit where I apply it to the table component, both refactoring the component and applying needs from #3778 and #3922 to the component to test it completely. Broadly speaking, a user refactoring // current setup
.my-class {
@include govuk-font($size: 19, $weight: bold);
}
// with proposed mixin setup
.my-class {
@include govuk-typography($weight: bold);
@include govuk-responsive-font-size($size: 19);
} This would result in more lines of code for users but I would argue it makes it clearer what the user is getting in the 2 mixins rather than just Some additional considerations not explored in this proof of concept:
|
Great proposal @owenatgov, keeps breaking changes away too With typefaces or font families (GDS Transport) coming in multiple styles (Regular, Bold) how about:
Helps follow that A-Z of our font utilities starting with |
@colinrotherham I like it! As you've said it sticks to the namespacing convention laid out in the other mixins. |
Given how pervasive it is, I don't think we should get rid of I'm still really not sure about the govuk-frontend/packages/govuk-frontend/src/govuk/components/table/_index.scss Lines 13 to 15 in 783cf18
Based on previous discussions, I believe your intention here was to get 16px on mobile, 19px on tablet and desktop. But what What you'd actually need to do is something like this: .govuk-table--complex {
@include govuk-font-size($size: 16, $breakpoint: tablet);
@include govuk-media-query($from: tablet) {
@include govuk-font-size($size: 19, $breakpoint: tablet);
}
} As I understand it, the main thing we want to solve here is that there are some instances where dropping from 19px to 16px on desktop makes sense, and we want to allow that. Can I suggest we consider a much simpler alternative, which is to preserve the existing version of the 19px point in the scale with a different key? $govuk-typography-scale: (
// ...
19: (
null: (
font-size: 19px,
line-height: 25px
),
print: (
font-size: 14pt,
line-height: 1.15
)
),
19r: (
null: (
font-size: 16px,
line-height: 20px
),
tablet: (
font-size: 19px,
line-height: 25px
),
print: (
font-size: 14pt,
line-height: 1.15
)
),
// ...
) We can then just do: .govuk-table--complex {
@include govuk-font($size: 19r);
} |
@36degrees Thanks for the comment. I have some thoughts. Firstly, could you go more into why removing Secondly, good catch on This leads into my last point on the extra scale map idea. This solves #3922 but I think there's still value in scrutinising |
Ah I missed that Liked how the "split out" mixins would let us reduce all the |
I think we need a really good reason to make breaking changes and I just don't see what that is at the minute, but maybe I'm missing something. Generally I think it's a useful mixin that works in the vast majority of cases to give users everything they need to typographically style an element. Referring back to your earlier comment:
Can you give an example of a time that the Whilst it's true it doesn't meet every need, in instances where users want to do something 'custom' they still have the underlying mixins which they can compose instead.
IMO we're taking something that's currently relatively simple (and well understood by our users) and adding a lot of complexity to try and enable users to solve problems we don't really understand ourselves yet. I think in the vast majority of cases we want users to stick to the typography scale. If the typography scale isn't meeting user's needs, we should revisit it rather than optimising for people deviating from it. I think we should find the easiest way to solve the specific problem we have at hand (a way to preserve specifically 16px mobile / 19px tablet and above in certain situations).
Paraphrasing to check I'm understanding this correctly – the issue is that some users think that I agree that there are plenty of examples of people using I don't think that this provides enough justification to remove the mixin entirely (especially as although there is repetition, it compresses really well as the properties appear in the same order every time) Before we remove the mixin I think we should first try:
|
@36degrees Here's an example I shared on Slack in alphagov/govuk-design-system@d53ca8c E.g. Having to use |
@36degrees I'm gonna try to answer your questions holistically. Firstly, I think the overall proposal is too contentious and isn't backed up enough to go ahead with. The new scale and specifically the fact that for 16 and 19 we're not producing separate tablet breakpoints is going to likely remove a lot of the need for any sort of customisation. Looking again at the .govuk-table {
@include govuk-font($size: 19);
}
// ...
.govuk-table--complex {
@include govuk-typography-responsive($size: 16);
@include govuk-media-query($from: tablet) {
@include govuk-typography-responsive($size: 19);
}
} That's identical to the IMO this discussion has uncovered the root problem which is our typography documentation. I think therefore going with your ideas of improving our documentation and renaming Having said all that, I'm going to record some examples where
My instinct now is to close this issue, create a new one to reconsider the name of |
New issues have been jotted up. I'm therefore going to close this as the investigation is concluded. |
What
Investigate how we could extend the
govuk-font
mixin to allow users to, where necessary, bypass the responsive scale.Why
During the audit of our components against the new typography scale (alphagov/govuk-design-system#2299) we noticed there are some instances where we do still want values that we've now set to not drop down a size on small screens to still drop down. For example: table cell content in the new type scale is now 19 on big and small screens by default, where it actually would be more readable if it was 16 on small screens.
Developers using govuk-frontend currently have a couple of hacky options to do achieve this:
1: apply 2
govuk-font
's between breakpointsThis works, however it creates a lot of repeated code as
govuk-font
includes several useful typography rules as well as the corresponding font size.2: use
$size: false
to only need to callgovuk-font
onceThis solves the precise problem in option 1, but is itself quite messy. It's trickier to parse at a glance, actively advises misusing our own tooling and potentially encourages ignoring the typography scale at all. We should avoid this solution where possible.
Related issue: #2456
Part of alphagov/govuk-design-system#2289
Timebox
1 sprint (2 weeks)
Who is working on this?
Developers
Spike lead:
@owenatgov
Spike buddy:
TBD
Questions to answer
govuk-font
without letting teams ignore our typography scale recommendations?Done when
The text was updated successfully, but these errors were encountered: