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

Use placeholders when @​extend'ing in prose scope #550

Merged
merged 3 commits into from
Feb 26, 2018

Conversation

36degrees
Copy link
Member

This updates the prose scope (and the things the prose scope depends on) such that we only ever @​extend placeholder selectors.

This abstraction gives us control over which occurrences of the selector are included by the @​extend. Without this change, occurrences of e.g. the heading classes within the fieldset component are also ending up being ‘applied’ to the prose scope, leading to selectors like .govuk-c-fieldset__legend .govuk-prose-scope h4 in the CSS. This makes no sense, as the prose scope should never be used within the fieldset legend.

With this change, only occurrences of the placeholder selectors are 'included' when @​extend’ing. This means that as we define e.g. the typographic contextual adjustments at the placeholder level and these will be applied to the prose scope, but other references to the concrete classes will have no effect on the prose scope.

It also changes the linting rules to enforce that @​extends can only be used to extend placeholder classes.

Difference in generated CSS

Reversal of simple selectors in compound .govuk-link / attribute selectors:

<     .govuk-link[href^="/"]::after, .govuk-prose-scope a[href^="/"]::after, .govuk-link[href^="http://"]::after, .govuk-prose-scope a[href^="http://"]::after, .govuk-link[href^="https://"]::after, .govuk-prose-scope a[href^="https://"]::after,
< .govuk-link[href^="http.\://"]::after,
---
>     [href^="/"].govuk-link::after, .govuk-prose-scope a[href^="/"]::after, [href^="http://"].govuk-link::after, .govuk-prose-scope a[href^="http://"]::after, [href^="https://"].govuk-link::after, .govuk-prose-scope a[href^="https://"]::after,
> [href^="http.\://"].govuk-link::after,
< .govuk-link[href^="https.\://"]::after,
---
> [href^="https.\://"].govuk-link::after,

Change in whitespace around selectors:

< .govuk-body-m + .govuk-heading-l, .govuk-body + .govuk-heading-l, .govuk-prose-scope p + .govuk-heading-l, .govuk-prose-scope .govuk-body-m + h2, .govuk-prose-scope .govuk-body + h2, .govuk-prose-scope p + h2,
< .govuk-body-s + .govuk-heading-l, .govuk-prose-scope
< .govuk-body-s + h2,
< .govuk-list + .govuk-heading-l, .govuk-prose-scope ul + .govuk-heading-l,
< .govuk-prose-scope ol + .govuk-heading-l, .govuk-prose-scope
< .govuk-list + h2, .govuk-prose-scope ul + h2, .govuk-prose-scope ol + h2 {
---
> .govuk-body-m + .govuk-heading-l, .govuk-body + .govuk-heading-l, .govuk-prose-scope p + .govuk-heading-l, .govuk-prose-scope .govuk-body-m + h2, .govuk-prose-scope .govuk-body + h2, .govuk-prose-scope p + h2, .govuk-body-s + .govuk-heading-l, .govuk-prose-scope .govuk-body-s + h2, .govuk-list + .govuk-heading-l, .govuk-prose-scope ul + .govuk-heading-l,
> .govuk-prose-scope ol + .govuk-heading-l, .govuk-prose-scope .govuk-list + h2, .govuk-prose-scope ul + h2, .govuk-prose-scope ol + h2 {
<     .govuk-body-m + .govuk-heading-l, .govuk-body + .govuk-heading-l, .govuk-prose-scope p + .govuk-heading-l, .govuk-prose-scope .govuk-body-m + h2, .govuk-prose-scope .govuk-body + h2, .govuk-prose-scope p + h2,
<     .govuk-body-s + .govuk-heading-l, .govuk-prose-scope
<     .govuk-body-s + h2,
<     .govuk-list + .govuk-heading-l, .govuk-prose-scope ul + .govuk-heading-l,
<     .govuk-prose-scope ol + .govuk-heading-l, .govuk-prose-scope
<     .govuk-list + h2, .govuk-prose-scope ul + h2, .govuk-prose-scope ol + h2 {
---
>     .govuk-body-m + .govuk-heading-l, .govuk-body + .govuk-heading-l, .govuk-prose-scope p + .govuk-heading-l, .govuk-prose-scope .govuk-body-m + h2, .govuk-prose-scope .govuk-body + h2, .govuk-prose-scope p + h2, .govuk-body-s + .govuk-heading-l, .govuk-prose-scope .govuk-body-s + h2, .govuk-list + .govuk-heading-l, .govuk-prose-scope ul + .govuk-heading-l,
>     .govuk-prose-scope ol + .govuk-heading-l, .govuk-prose-scope .govuk-list + h2, .govuk-prose-scope ul + h2, .govuk-prose-scope ol + h2 {
< .govuk-body-m + .govuk-heading-m, .govuk-body + .govuk-heading-m, .govuk-prose-scope p + .govuk-heading-m, .govuk-prose-scope .govuk-body-m + h3, .govuk-prose-scope .govuk-body + h3, .govuk-prose-scope p + h3,
< .govuk-body-s + .govuk-heading-m, .govuk-prose-scope
< .govuk-body-s + h3,
< .govuk-list + .govuk-heading-m, .govuk-prose-scope ul + .govuk-heading-m,
< .govuk-prose-scope ol + .govuk-heading-m, .govuk-prose-scope
< .govuk-list + h3, .govuk-prose-scope ul + h3, .govuk-prose-scope ol + h3,
< .govuk-body-m + .govuk-heading-s, .govuk-body + .govuk-heading-s, .govuk-prose-scope p + .govuk-heading-s, .govuk-prose-scope
< .govuk-body-m + h4, .govuk-prose-scope .govuk-body + h4, .govuk-prose-scope p + h4,
< .govuk-body-s + .govuk-heading-s, .govuk-prose-scope
< .govuk-body-s + h4,
< .govuk-list + .govuk-heading-s, .govuk-prose-scope ul + .govuk-heading-s,
< .govuk-prose-scope ol + .govuk-heading-s, .govuk-prose-scope
< .govuk-list + h4, .govuk-prose-scope ul + h4, .govuk-prose-scope ol + h4 {
---
> .govuk-body-m + .govuk-heading-m, .govuk-body + .govuk-heading-m, .govuk-prose-scope p + .govuk-heading-m, .govuk-prose-scope .govuk-body-m + h3, .govuk-prose-scope .govuk-body + h3, .govuk-prose-scope p + h3, .govuk-body-s + .govuk-heading-m, .govuk-prose-scope .govuk-body-s + h3, .govuk-list + .govuk-heading-m, .govuk-prose-scope ul + .govuk-heading-m,
> .govuk-prose-scope ol + .govuk-heading-m, .govuk-prose-scope .govuk-list + h3, .govuk-prose-scope ul + h3, .govuk-prose-scope ol + h3, .govuk-body-m + .govuk-heading-s, .govuk-body + .govuk-heading-s, .govuk-prose-scope p + .govuk-heading-s, .govuk-prose-scope .govuk-body-m + h4, .govuk-prose-scope .govuk-body + h4, .govuk-prose-scope p + h4, .govuk-body-s + .govuk-heading-s, .govuk-prose-scope .govuk-body-s + h4, .govuk-list + .govuk-heading-s, .govuk-prose-scope ul + .govuk-heading-s,
> .govuk-prose-scope ol + .govuk-heading-s, .govuk-prose-scope .govuk-list + h4, .govuk-prose-scope ul + h4, .govuk-prose-scope ol + h4 {
<     .govuk-body-m + .govuk-heading-m, .govuk-body + .govuk-heading-m, .govuk-prose-scope p + .govuk-heading-m, .govuk-prose-scope .govuk-body-m + h3, .govuk-prose-scope .govuk-body + h3, .govuk-prose-scope p + h3,
<     .govuk-body-s + .govuk-heading-m, .govuk-prose-scope
<     .govuk-body-s + h3,
<     .govuk-list + .govuk-heading-m, .govuk-prose-scope ul + .govuk-heading-m,
<     .govuk-prose-scope ol + .govuk-heading-m, .govuk-prose-scope
<     .govuk-list + h3, .govuk-prose-scope ul + h3, .govuk-prose-scope ol + h3,
<     .govuk-body-m + .govuk-heading-s, .govuk-body + .govuk-heading-s, .govuk-prose-scope p + .govuk-heading-s, .govuk-prose-scope
<     .govuk-body-m + h4, .govuk-prose-scope .govuk-body + h4, .govuk-prose-scope p + h4,
<     .govuk-body-s + .govuk-heading-s, .govuk-prose-scope
<     .govuk-body-s + h4,
<     .govuk-list + .govuk-heading-s, .govuk-prose-scope ul + .govuk-heading-s,
<     .govuk-prose-scope ol + .govuk-heading-s, .govuk-prose-scope
<     .govuk-list + h4, .govuk-prose-scope ul + h4, .govuk-prose-scope ol + h4 {
---
>     .govuk-body-m + .govuk-heading-m, .govuk-body + .govuk-heading-m, .govuk-prose-scope p + .govuk-heading-m, .govuk-prose-scope .govuk-body-m + h3, .govuk-prose-scope .govuk-body + h3, .govuk-prose-scope p + h3, .govuk-body-s + .govuk-heading-m, .govuk-prose-scope .govuk-body-s + h3, .govuk-list + .govuk-heading-m, .govuk-prose-scope ul + .govuk-heading-m,
>     .govuk-prose-scope ol + .govuk-heading-m, .govuk-prose-scope .govuk-list + h3, .govuk-prose-scope ul + h3, .govuk-prose-scope ol + h3, .govuk-body-m + .govuk-heading-s, .govuk-body + .govuk-heading-s, .govuk-prose-scope p + .govuk-heading-s, .govuk-prose-scope .govuk-body-m + h4, .govuk-prose-scope .govuk-body + h4, .govuk-prose-scope p + h4, .govuk-body-s + .govuk-heading-s, .govuk-prose-scope .govuk-body-s + h4, .govuk-list + .govuk-heading-s, .govuk-prose-scope ul + .govuk-heading-s,
>     .govuk-prose-scope ol + .govuk-heading-s, .govuk-prose-scope .govuk-list + h4, .govuk-prose-scope ul + h4, .govuk-prose-scope ol + h4 {

Addition of .govuk-prose-scope hr here now that it extends %govuk-section-break:

< .govuk-section-break {
---
> .govuk-prose-scope hr, .govuk-section-break {

Re-ordering of selectors:

< .govuk-section-break--xl, .govuk-prose-scope hr {
---
> .govuk-prose-scope hr, .govuk-section-break--xl {
<     .govuk-section-break--xl, .govuk-prose-scope hr {
---
>     .govuk-prose-scope hr, .govuk-section-break--xl {

```diff
<     .govuk-section-break--xl, .govuk-prose-scope hr {
---
>     .govuk-prose-scope hr, .govuk-section-break--xl {
< .govuk-section-break--visible, .govuk-prose-scope hr {
---
> .govuk-prose-scope hr, .govuk-section-break--visible {

Removal of non-sensical prose scope adjustments for fieldset component 🎉:

<   .govuk-c-fieldset__legend .govuk-heading-s, .govuk-c-fieldset__legend .govuk-prose-scope h4, .govuk-prose-scope .govuk-c-fieldset__legend h4 {
---
>   .govuk-c-fieldset__legend .govuk-heading-s {
<   .govuk-c-fieldset__legend .govuk-heading-m, .govuk-c-fieldset__legend .govuk-prose-scope h3, .govuk-prose-scope .govuk-c-fieldset__legend h3 {
---
>   .govuk-c-fieldset__legend .govuk-heading-m {
<   .govuk-c-fieldset__legend .govuk-heading-l, .govuk-c-fieldset__legend .govuk-prose-scope h2, .govuk-prose-scope .govuk-c-fieldset__legend h2,
<   .govuk-c-fieldset__legend .govuk-heading-xl,
<   .govuk-c-fieldset__legend .govuk-prose-scope h1, .govuk-prose-scope
<   .govuk-c-fieldset__legend h1 {
---
>   .govuk-c-fieldset__legend .govuk-heading-l,
>   .govuk-c-fieldset__legend .govuk-heading-xl {

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-550 February 23, 2018 16:44 Inactive
Copy link

@kr8n3r kr8n3r left a comment

Choose a reason for hiding this comment

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

💯

This updates the prose scope (and the things the prose scope depends on) such that we only ever @​extend placeholder classes (classes starting with % which are not outputted into the CSS themselves)

This abstraction gives us control over which occurrences of the selector are included by the @​extend. Without this change, occurrences of e.g. the heading classes within the fieldset component are also ending up being ‘applied’ to the prose scope, leading to selectors like `.govuk-c-fieldset__legend .govuk-prose-scope h4` in the CSS. This makes no sense, as the prose scope should never be used within the fieldset legend.

With this change, only occurrences of the placeholder class are included when @​extend’ing. This means that we can define e.g. the typographic contextual adjustments at the placeholder level and these _will_ be applied to the prose scope, but other references to the concrete classes will have no effect on the prose scope.
@36degrees
Copy link
Member Author

@igloosi happy with the changelog entry?

@kr8n3r
Copy link

kr8n3r commented Feb 26, 2018

👍

@36degrees 36degrees merged commit 376c697 into master Feb 26, 2018
@36degrees 36degrees deleted the enforce-placeholders-for-extend branch February 26, 2018 11:23
This was referenced Mar 1, 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.

None yet

3 participants