-
Notifications
You must be signed in to change notification settings - Fork 107
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 utility classes for 2 different word-break options #1061
base: main
Are you sure you want to change the base?
Conversation
The GOV.UK Design System, has (Agree to allowing classes on table cells, been hacking my way around this for a while) |
@paulrobertlloyd that class uses Both |
@frankieroberto could it be a more generic modifier as @paulrobertlloyd suggests, but use a different method when inside a table cell? |
I like @edwardhorsford's suggestion. On service manual website we have added these locally:
But a more generalised class would be even better. |
This is useful if your table cell may contain long strings which will otherwise cause the table to overflow its container, for example email addresses (where full stops do not count as a break-point).
Also refactor to reduce duplication.
abf78b6
to
4cfc228
Compare
@anandamaryon1 @edwardhorsford @paulrobertlloyd I've updated this PR to change the modifier class from the a table cell modifier to add 2 generic modifiers:
The difference is subtle but crucial. The MDN word-break article has good explanation and examples: The only reason to use the I think I’ve got this right but happy to be corrected if I'm wrong! 🤯 |
Would it be grotesque to have just |
I considered that, but potentially there are other use-cases for That said, explaining the difference between the 2 options is really tricky and it took me ages to get my head around it... |
Ok thats fair @frankieroberto . I'll approve once tests are successful. |
I wonder also about having the single, simpler form, and then if teams need something more specific they could just use their own css? |
This adds a
nhsuk-table__cell--break-word
modifier which can be used on table cells where there is a risk that they contain such long content that the table might otherwise overflow its container and cause horizontal scrolling.This is particularly possible for email addresses, as the full stop character in email addresses is not a break point.
The modifier is opt-in though, as in other scenarios where the content is more predictable, you likely wouldn’t want table cells to break mid-word.
In order to enable this I’ve added support for
classes
on table cells. There is an existingformat
option used fornhsuk-table__cell--numeric
, butclasses
is more flexible (for example allowing custom modifiers and more than one class), and this doesn’t feel like a "format".I’ve also refactored the Table nunjucks macro to reduce duplication.
Screenshots