Skip to content
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

Allow for an optional divider between radio items #849

Merged
merged 2 commits into from
Jul 19, 2018

Conversation

kr8n3r
Copy link

@kr8n3r kr8n3r commented Jul 1, 2018

It used to be a feature in GOV.UK Elements and it's not currently available in our macros.

Direct url: https://govuk-frontend-review-pr-849.herokuapp.com/components/radios/with-a-divider/preview

This PR:

  • Adds an example
  • Updates the component template
  • Adds a test to check the divider item gets output
  • Updates README

Fixes: #729

Works fine with conditional reveal as well.

Screenshots

IE 8

IE 9

IE 11

Firefox 60

Safari 9.3

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 1, 2018 10:21 Inactive
text: Use Government Gateway
- value: govuk-verify
text: 'Use GOV.UK Verify'
- divider: 'or'
Copy link
Author

@kr8n3r kr8n3r Jul 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could follow the same rules as with all our text params and allow for either text or html, but surely it should only be text. it could be

- divider: {
  text: text here
}

as well

@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 7f71a88 to c71006e Compare July 1, 2018 10:32
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 1, 2018 10:32 Inactive
@kr8n3r
Copy link
Author

kr8n3r commented Jul 1, 2018

@dashouse question about text alignment in relationship to the radio. in elements it's aligned to the left

@dashouse
Copy link

dashouse commented Jul 3, 2018

Design wise 👍

@include govuk-font($size: 19);
display: block;
margin-bottom: govuk-spacing(2);
padding: 0 0 0 ($govuk-radios-size / 4);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is visually centring the text, but it's relying on the string being 'or' - if you use a different string then it doesn't work. What about making this element the same width as the radio buttons / checkboxes and then use text-align: center? That way it should work correctly for short strings, and automatically fall back to left-aligning if the string is long enough that centring it doesn't make sense.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the aim is for the left alignment to be where the line is in the conditional reveal. i've update the calculation
screen shot 2018-07-03 at 09 14 23
screen shot 2018-07-03 at 09 14 18

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we agreed to go with Ollie's suggestions

name: example
fieldset:
legend:
text: Have you changed your name?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this example make sense? The answers don't relate to the question.

@@ -44,9 +44,12 @@
<div class="govuk-radios {%- if params.classes %} {{ params.classes }}{% endif %}"
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}
{%- if isConditional %} data-module="radios"{% endif -%}>
{% for item in params.items %}
{% for item in params.items %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace

@@ -59,12 +62,13 @@
attributes: item.label.attributes,
for: id
}) | indent(6) | trim }}
</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace

@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from c71006e to 36c5e5b Compare July 3, 2018 08:02
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 3, 2018 08:02 Inactive
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 36c5e5b to 36d2706 Compare July 3, 2018 08:15
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 3, 2018 08:15 Inactive
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 36d2706 to f01a6e1 Compare July 3, 2018 08:31
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 3, 2018 08:31 Inactive
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from f01a6e1 to d29e0b0 Compare July 3, 2018 08:45
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 3, 2018 08:45 Inactive
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from d29e0b0 to 714bfda Compare July 3, 2018 08:54
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 3, 2018 08:54 Inactive
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 714bfda to d561e25 Compare July 3, 2018 08:57
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 3, 2018 08:57 Inactive
@kr8n3r kr8n3r changed the title WIP: Allow for optional divider between radio items Allow for an optional divider between radio items Jul 3, 2018
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from d561e25 to dff8aec Compare July 3, 2018 09:01
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 3, 2018 09:02 Inactive
@kr8n3r kr8n3r added this to the v1.1.0 milestone Jul 4, 2018
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from dff8aec to 9671ffe Compare July 4, 2018 13:57
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 4, 2018 13:57 Inactive
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks really good, but I think the argument docs could be clearer.

text: 'No'
},
{
html: 'Optional divider to separate options, e.g "or".'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it needs to be clearer how to use this – it's not obvious for example that specifying 'divider' means that all other options will be ignored.

@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 9671ffe to 21991cd Compare July 6, 2018 08:29
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 6, 2018 08:29 Inactive
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 21991cd to d3c0ee0 Compare July 6, 2018 12:01
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 6, 2018 12:02 Inactive
@@ -47,6 +47,9 @@
{% for item in params.items %}
{% set id = item.id if item.id else idPrefix + "-" + loop.index %}
{% set conditionalId = "conditional-" + id %}
{%- if item.divider %}
<span class="govuk-radios__divider">{{ item.divider }}</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just be a div, instead of span that has display: block set. It would make it consistent with the markup of the radios.

Copy link
Author

@kr8n3r kr8n3r Jul 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's now a div

@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from d3c0ee0 to 3813723 Compare July 10, 2018 09:00
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 10, 2018 09:01 Inactive
.govuk-radios__divider {
$govuk-divider-size: $govuk-radios-size !default;
@include govuk-font($size: 19);
display: block;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant now that the divider is a div.

@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 3813723 to 31a21b6 Compare July 10, 2018 14:53
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 10, 2018 14:53 Inactive
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 31a21b6 to 5bb1129 Compare July 10, 2018 15:59
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 10, 2018 15:59 Inactive
@@ -138,6 +138,14 @@
}
}

.govuk-radios__divider {
$govuk-divider-size: $govuk-radios-size !default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to work well but I wonder if it'll stand up to the following scenarios:

  1. A divider longer than 'or'
  2. A user changing their text size

It may be more flexible to have this span the full width of the component, and align it with the radios by some padding-left

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the original approach – see related discussion in #849 (comment)

When the divider is longer than or the text will overflow to the right, like this:

screen shot 2018-07-11 at 12 09 30

I don't think we'd tested with users changing their text size though – good call. It seems to work though, having enabled $govuk-typography-use-rem: true; in app.scss:

Firefox, with size set to 28 in appearance settings:

screen shot 2018-07-11 at 12 14 49

Safari, with 'Never use font sizes smaller than 24' configured under 'Advanced':
screen shot 2018-07-11 at 12 15 53

Chrome, with 'Font size' set to very large in appearance settings:

screen shot 2018-07-11 at 12 16 34

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet thanks for that. 👍

@kr8n3r kr8n3r removed this from the v1.1.0 milestone Jul 13, 2018
@NickColley NickColley added feature request User requests a new feature and removed enhancement labels Jul 13, 2018
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 5bb1129 to f161ac3 Compare July 13, 2018 18:48
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 13, 2018 18:48 Inactive
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from f161ac3 to 7b03bee Compare July 13, 2018 18:49
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-849 July 13, 2018 18:49 Inactive
@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 7b03bee to 6b2b82a Compare July 13, 2018 19:02
Copy link
Contributor

@NickColley NickColley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really well thought out. Great naming for the API choices 👍

@kr8n3r kr8n3r force-pushed the divider-in-radios-and-checkboxes branch from 6b2b82a to 95b8ffa Compare July 19, 2018 08:01
@kr8n3r kr8n3r added this to the [NEXT] milestone Jul 19, 2018
@kr8n3r kr8n3r merged commit e83b54a into master Jul 19, 2018
@kr8n3r kr8n3r deleted the divider-in-radios-and-checkboxes branch July 19, 2018 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request User requests a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants