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

Opt-in global anchor and paragraph styles #658

Merged
merged 4 commits into from
May 3, 2018
Merged

Conversation

kr8n3r
Copy link

@kr8n3r kr8n3r commented Apr 17, 2018

To ease prototyping and new production instances we provided a way to include global styles for links and paragraphs, so that users do not have to add classes to every paragraph or link.

Inclusion is controlled by $govuk-global-styles variable in globals/settings folder.
Documentation has been added to the main README.md file

If Elements or Template compatibility variables are set to true then we render fixes to those and also include global styles

Trello: https://trello.com/c/toKpf2vV/868-3-add-optional-styles-that-set-paragraph-and-link-styles

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 17, 2018 10:06 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 17, 2018 10:23 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 19, 2018 10:51 Inactive
Copy link
Contributor

@alex-ju alex-ju left a comment

Choose a reason for hiding this comment

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

Left two comment. The second one is non-blocking and more of a personal opinion. Otherwise it's good to go. I'll wait for other to have a look, since it's more about agreeing on the approach.


In GOV.UK Frontend we want to provide a convenient way to have correct styles applied to your links (`<a>`) and paragraphs (`<p>`) without having to set required classes for each instance of an element.

We have chosen 'Opt-in' as the default behaviour.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we say 'Opted-in'. For me 'Opt-in' sound like I have the option to choose if I want it, which is the opposite of what we're doing by default. We can ask @amyhupe to help with wording.

// Settings
@import "../globals/common";
@import "../globals/optional/global-styles";
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the context optional/ may be the right name.
My view of this was that we'd have a /core in which we place the default style that you can choose not to use.

Copy link
Author

Choose a reason for hiding this comment

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

was considering putting it in core first. i have no issue with it being in core tbh

Copy link
Member

Choose a reason for hiding this comment

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

I quite like optional/ as this clearly differentiates those styles from the rest. But not a blocker.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 19, 2018 14:09 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 19, 2018 14:56 Inactive
@import "govuk-frontend/all/all";
```
If you choose this option, you will need to either use classes on links (`<a>`) and paragraphs (`<p>`) or have a different way to apply correct styles.

Copy link
Member

Choose a reason for hiding this comment

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

It would be good to document here, or link from here to another doc, what to look out for if choosing to set $govuk-global-styles to false and adding our link classes selectively, eg. govuk-link class must be added along with govuk-link--muted.

Instead of "use classes", maybe "add GOV.UK Frontend classes"?

@@ -0,0 +1,20 @@
# Global Styles
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 this documentation is most likely to be useful if you're using the legacy stuff, with this in mind should we align this work with the compatibility mode stuff?

User scenario:

  1. I have GOV.UK Template, and just want a build that works with that

Copy link
Author

Choose a reason for hiding this comment

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

in that case you don't need global styles then, right? As they're coming from template?

Copy link
Author

Choose a reason for hiding this comment

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

all of the *compatibillity vars are set to true in Frontend 🤔

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 23, 2018 07:49 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 25, 2018 15:19 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 25, 2018 15:20 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 25, 2018 15:24 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 25, 2018 15:33 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 25, 2018 15:45 Inactive
@kr8n3r kr8n3r changed the title WIP: Global a and p styles Global a and p styles Apr 25, 2018
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-658 April 25, 2018 15:57 Inactive
//
// 4. If both $govuk-global-styles and $govuk-compatibility-govuktemplate are set to false
// then don't include global styles
@if global-variable-exists("govuk-global-styles") == false or $govuk-global-styles == true or $govuk-compatibility-govuktemplate == true {
Copy link
Contributor

@NickColley NickColley Apr 25, 2018

Choose a reason for hiding this comment

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

should this be $govuk-compatibility-govuktemplate == false?

(and would it need the global-variable-exists statement too?)

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.

Here's my understanding:

If we agree that global styles should be enabled for new projects (or prototyping) this should be the default.

Then if people need to use GOV.UK Frontend in a way that's compatible with the older projects they should opt in.

With this in mind.

All compatibility flags should be false by default.

global styles should be true by default

govuktemplate flag should set global styles to false

global styles should still be able to be set on it's own, if the user is using GOV.UK Frontend in a project that uses another framework for example.

so at the risk of complicating this PR, should we need to update the defaults for the compatibility flags?

@joelanman
Copy link
Contributor

It would be good to go over this - I'm finding it hard to understand the logic and naming - especially $govuk-compatibility-govuktemplate

@kr8n3r kr8n3r force-pushed the global-a-and-p-styles branch 3 times, most recently from 9adb06c to 27a5744 Compare May 2, 2018 11:32
const results = await sassRender({ data: sass, ...sassConfig })
expect(results.css.toString()).toContain(', p {')
})
it('for links and paragraphs are not output if flag is set to false', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also have variants for

  1. When compatibility flags are set to true
  2. When compatibility flags are set to true and global flag is set to true

@joelanman
Copy link
Contributor

it would be great to get a diagram to explain the logic for this work - happy to help out if needed

@kr8n3r kr8n3r force-pushed the global-a-and-p-styles branch 3 times, most recently from dd5bfd3 to c13c6ec Compare May 2, 2018 16:11
@kr8n3r
Copy link
Author

kr8n3r commented May 3, 2018

@dashouse made a point that if you are using template then you might need our globals as we have changed spacing in typography

@kr8n3r kr8n3r force-pushed the global-a-and-p-styles branch 7 times, most recently from 08bf080 to e837894 Compare May 3, 2018 09:50
@kr8n3r kr8n3r changed the title Global a and p styles and legacy compatibility setting Opt-in global a and p styles May 3, 2018
@kr8n3r kr8n3r changed the title Opt-in global a and p styles Opt-in global link and anchor styles May 3, 2018
@kr8n3r
Copy link
Author

kr8n3r commented May 3, 2018

updated to just include optional global styles based on a flag

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.

💯 👍 👏

@kr8n3r kr8n3r changed the title Opt-in global link and anchor styles Opt-in global anchor and paragraph styles May 3, 2018
@kr8n3r kr8n3r merged commit d1595d6 into master May 3, 2018
@36degrees 36degrees deleted the global-a-and-p-styles branch May 3, 2018 12:58
@kr8n3r kr8n3r mentioned this pull request May 18, 2018
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.

8 participants