-
Notifications
You must be signed in to change notification settings - Fork 334
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 input prefix and suffix #1816
Add input prefix and suffix #1816
Conversation
This work was reviewed by the Working Group in June, see alphagov/govuk-design-system#1269 (comment) for their comments. |
I've implemented the design for very narrow viewports. It only kicks in under 320px so I think that it's most likely to be seen by users who zoom in on a mobile device. I've tested this using the 'Aa' zoom button on iOS Safari: I've also tried to increase text scaling on Android Chrome but it mainly seems to work for text like paragraphs and headings, it doesn't do anything for form elements for instance. I'll raise a separate issue to investigate that. Tested on |
|
||
.govuk-input:focus { | ||
// Hack to stop focus style being overlapped by the suffix | ||
z-index: 1; |
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 wish we had another way of fixing this but I can't find anything else to stop the suffix overlapping the input focus border.
|
Minor, but can we have at least one example that does not use an input width modifier? This will allow us to verify that the input is unconstrained and 'full-width' by default. Possibly most of the examples should omit the width modifier? In the same way the National Insurance Number examples are 'full-width' even though in real world usage you'd expect them to be constrained… most of the examples should probably combine the minimum number of 'features' possible? Although we would then want some examples that show that they do combine properly… |
@36degrees I don't know if you saw the feedback from @christopherthomasdesign which the change with the width modifiers was in response to? But maybe we mainly shouldn't use the width modifiers in the review app as the examples are out of context anyway..? Let me know if you have any thought on that. Definitely happy to include some examples without width modifiers in either case. |
Yep, I did – and completely agree for the examples in the Design System.
I think generally we use examples that are focused on only the specific feature, and don't 'enable' anything else – for example, the National Insurance Number examples don't include the spellcheck attribute, the example that enables isPageHeading doesn't also add a class to style it (though I think we might be missing some examples for each label size!) |
That all makes sense, I think I'm just having a slow day! I've removed the width modifiers from the examples and added a new example that does use one. The inputs with prefix/suffix actually look pretty strange at full width but I guess that's okay, especially since there isn't an elegant way of setting any kind of max width on them. |
Do these end up showing in a 2/3 column grid? |
They get constrained by the grid which is also a good point so I think we're okay to leave it as is 👍 |
Doing this makes it possible to include block level elements inside the prefix/suffix containers.
- Remove browser prefix styles as these will be added by auto-prefixer. - Remove redundant margin-top on prefix and display-inline-block on input - Make all examples use type=text as both prices and weights can contain decimal points
Implement design from #1915 (comment) This ensures that especially on zooming in the input remains visible. Remove height restriction to ensure that longer prefix/suffix can wrap instead of overflowing container. Add an example to demonstrate text wrapping behaviour.
IE8 doesn't support flex so the prefix, suffix and input weren't aligned. This commit stops the removal of prefix/suffix borders on IE8 to make the elements look less 'broken'. There is still a gap between the elements on IE8 which is acceptable as we only functionally support IE8.
Remove width modifiers from other examples to keep them focused on the prefix/suffix functionality. Reorganise examples. We're not going to enforce the ordering of examples but for now going with the convention of placing the hidden examples at the end of the yaml.
Massive thanks for all the amazing work by @simonwhatley and his team on this component 🎉🙏 |
Use govuk-frontend styles [1] as they've been moved upstream [2] [1] https://github.com/alphagov/govuk-frontend/blob/master/src/govuk/components/input/_index.scss#L94-L177 [2] alphagov/govuk-frontend#1816
Use govuk-frontend styles [1] as they've been moved upstream [2] [1] https://github.com/alphagov/govuk-frontend/blob/master/src/govuk/components/input/_index.scss#L94-L177 [2] alphagov/govuk-frontend#1816
Use govuk-frontend styles [1] as they've been moved upstream [2] [1] https://github.com/alphagov/govuk-frontend/blob/master/src/govuk/components/input/_index.scss#L94-L177 [2] alphagov/govuk-frontend#1816
What
Adds prefix and suffix elements to the input component.
Why
A number of local and departmental design systems (GOV.UK Publishing Components, HMRC, MOJ and ONS) are using prefixes and suffixes to indicate currencies and measurements.
Examples
Prefix
HTML
Macro
Suffix
HTML
Macro
Fixes #1915