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

Move form components into gem #116

Merged
merged 3 commits into from
Jan 4, 2018
Merged

Move form components into gem #116

merged 3 commits into from
Jan 4, 2018

Conversation

NickColley
Copy link
Contributor

@NickColley NickColley commented Jan 3, 2018

Moves form related components needed in email-alert-frontend into the gem so they can be used across applications.

We're avoiding static here since these pages need strong integration tests within the applications they are used in, and static mocks components.

These were originally implemented in the following pull requests to government-frontend

We'll move the error related components later to make the PR smaller.

We will do a follow up PR to remove these components from government-frontend

As part of https://trello.com/c/HSre7K10/453-style-the-mvp-email-collection-page-needed-by-jan

@NickColley NickColley force-pushed the add-form-components branch 2 times, most recently from a395080 to c0f7806 Compare January 3, 2018 15:39
tuzz
tuzz previously requested changes Jan 3, 2018
startup.sh Outdated
bundle install

PLEK_SERVICE_STATIC_URI=${PLEK_SERVICE_STATIC_URI-assets.publishing.service.gov.uk} \
bundle exec rackup spec/dummy/config.ru --port=3212 --host=0.0.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this as running the app is addressed in #115

expect(page).to_not have_selector("[@class='gem-c-radio__input'][@value='govuk-verify'][@checked='checked']", visible: input_visible)
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Good job on fixing these tests, they look tricky. 🎉

@NickColley NickColley force-pushed the add-form-components branch from c0f7806 to a11c968 Compare January 3, 2018 16:25
This component was originally added in alphagov/government-frontend#552

Moved from government-frontend for use in email-alert-frontend

Also renames the namespace to `gem`
Moved from government-frontend for use in email-alert-frontend

Also renames the namespace to `gem`

This was originally implemented in government-frontend in alphagov/government-frontend#552
Moved from government-frontend for use in email-alert-frontend

Also renames the namespace to `gem`

Originally implemented in alphagov/government-frontend#561
@NickColley NickColley force-pushed the add-form-components branch from a11c968 to 7333c6f Compare January 4, 2018 10:49
@NickColley NickColley changed the title WIP: Move form components into gem Move form components into gem Jan 4, 2018
classes ||= ''
text_classes ||= ''
hint_text_classes ||= ''
html_for ||= ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Is for reserved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fofr
Copy link
Contributor

fofr commented Jan 4, 2018

Should the components be called:

form-radio-button
form-label

So their ID and file name matches their component name?

@NickColley
Copy link
Contributor Author

@fofr I believe the components should be called how they're called, but ideally the guide would have categories to group components. I've halfway got there by prefixing the name that is displayed...

Can we raise an issue to allow grouping by category maybe?

@@ -0,0 +1,25 @@
// Forked from GOV.UK Frontend, namespace changed to ensure no conflicts.

$gem-spacing-scale-0: 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you expect an app in a component to also use these variables? eg Spacing is a common thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, that's a good point.

For now since these are forked lets keep them in here, the main reason to namespace these is to avoid collisions when importing GOV.UK Frontend, I'd imagine long term using the proper GOV.UK Frontend scale variables within downstream components is OK?

@NickColley NickColley dismissed tuzz’s stale review January 4, 2018 14:17

Sat next to Chris and he said "Sure"

@NickColley NickColley merged commit e59f5fd into master Jan 4, 2018
@NickColley NickColley deleted the add-form-components branch January 4, 2018 14:17
Copy link
Contributor

@andysellick andysellick left a comment

Choose a reason for hiding this comment

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

Sorry, apparently was a bit slow in getting this in. Have only reviewed the first commit so far.

// Fix legend text wrapping in Edge and IE
// 1. IE9-11 & Edge 12-13
// 2. IE8-11
box-sizing: border-box; // 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't there a mixin for this? Is there a reason it's not being used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not aware of a mixin for box-sizing

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's useful to use this mixin since the support for the unprefixed version is so high at 98%

https://caniuse.com/#feat=css3-boxsizing

@@ -0,0 +1,40 @@
<%
classes ||= ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are most of these declarations empty strings, apart from bold, which is false? They all mostly seem to be handled the same way i.e. if (thing) do something with (thing).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bold is a boolean that toggles, the others expect strings, so it seemed reasonable to instantiate them with their expected types

Copy link
Contributor

Choose a reason for hiding this comment

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

Except they're all being treated the same way, as described. Seems inconsistent, but maybe that's just me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What issues are you anticipating? This is how most of the components are done as far as I know?

gem-c-label__hint
<%= hint_text_classes if hint_text_classes %>
"
id="<%= hint_id %>"
Copy link
Contributor

Choose a reason for hiding this comment

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

hint_id looks like an optional parameter but it seems like it's quite important for accessibility? Would it be worth doing a check here to ensure developers remember to pass it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If hint_text is used but hint_id is not passed the component will throw an exception

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I suppose it will, won't it. Ah okay.

gem-c-label__text
<%= text_classes if text_classes %>
"
<% if html_for %>
Copy link
Contributor

Choose a reason for hiding this comment

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

When would a label not have a for attribute?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in another PR

assert_select ".gem-c-label__text", text: "National Insurance number"
assert_select ".gem-c-label--bold"
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a test for some of the parameters (perhaps added in a later commit, will check) i.e. classes, text_classes, hint_text_classes, html_for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in another PR, but we havent tested or documented the classes yet, feel free to raise an issue.

padding: 0 0 0 em(40px, 19px);

clear: left;

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for all the line spaces here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe clean them up at some point?

Copy link
Contributor Author

@NickColley NickColley Jan 4, 2018

Choose a reason for hiding this comment

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

Will raise an issue to lint the scss in this repo 👍

#124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants