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

Add ability to invert background colour in review app examples #3808

Merged
merged 1 commit into from
Jun 15, 2023

Conversation

querkmachine
Copy link
Member

@querkmachine querkmachine commented Jun 14, 2023

Adds support for adding an array of modifiers (previewLayoutModifiers) to review app examples. If the array exists, the example is rendered with the provided modifier classes.

Resolves #3780.

Changes

  • Updates app JS so that it looks for a previewLayoutModifiers array in each example's metadata. If it finds it, it loops through it and adds an additional modifier class to the bodyClasses string.
  • Adds style for the .app-template__body--inverse class. It makes the body background blue.
    • This class being present additionally inverts the box-shadow colour used by .app-whitespace-highlight.
  • Updates Button, Breadcrumbs and Back Link component examples that use inverse colours to have the 'inverse' layout modifier.
  • Renames classes used on <html>/<body> to follow a similar scheme to the Frontend template:
    • Renames .app-no-canvas-background to .app-template.
    • Adds a .app-template__body class to the <body> element by default.
    • Renames .app-iframe-in-component-preview to .app-template__body--component-preview.

Thoughts

  • The modifier classes are currently added to the <body> when they might make more sense being on <html>. However, the htmlClasses Nunjucks variable doesn't seem to be accessible at the same point that bodyClasses is being set.
  • The inverted background colour being used is blue. This is the colour we use for 'dark background' examples in the Design System documentation and is what many of the inverted-colour modifiers were originally designed to be used against (being ported from the Product Page template). There's a potential "Why not on black?" question here, but I'm not particularly passionate one way or another.

@querkmachine querkmachine self-assigned this Jun 14, 2023
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3808 June 14, 2023 11:20 Inactive
@querkmachine querkmachine force-pushed the review-app-inverse-example-support branch from 6ee209c to 138e81e Compare June 14, 2023 11:57
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3808 June 14, 2023 11:57 Inactive
@querkmachine querkmachine requested a review from a team June 14, 2023 12:15
@querkmachine querkmachine marked this pull request as ready for review June 14, 2023 12:15
Copy link
Contributor

@colinrotherham colinrotherham left a comment

Choose a reason for hiding this comment

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

This is brilliant 🙌

Can you fix the "inverse" colour for $app-preview-border-colour too?

We're using #e4f2ff at the moment which only looks good on a white background, maybe pair it with:

$app-preview-border-colour: mix(govuk-colour("blue"), govuk-colour("white"), 10%);
$app-preview-border-colour-inverse: mix(govuk-colour("white"), govuk-colour("blue"), 10%);

Added a comment about background colour classes too

@querkmachine querkmachine force-pushed the review-app-inverse-example-support branch from 138e81e to 9261f96 Compare June 14, 2023 15:33
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3808 June 14, 2023 15:33 Inactive
Copy link
Contributor

@colinrotherham colinrotherham left a comment

Choose a reason for hiding this comment

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

I'm going to approve this because it's looking amazing since the last push

Added some thoughts on invertLayoutColours naming but not a blocker 😊

@querkmachine querkmachine force-pushed the review-app-inverse-example-support branch from 9261f96 to 7401164 Compare June 15, 2023 08:30
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3808 June 15, 2023 08:30 Inactive
@querkmachine querkmachine force-pushed the review-app-inverse-example-support branch from 7401164 to d6b59c0 Compare June 15, 2023 08:32
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3808 June 15, 2023 08:33 Inactive
@@ -131,10 +131,15 @@ export default async () => {
{{ ${macroName}(${macroParameters}) }}
`, {})

let bodyClasses = ''
let bodyClasses = 'app-template__body'
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker but now I've seen layoutModifiers should we use an array here too?

Could swap += with .push() then have a .join(' ') as it passes into the render context

Copy link
Member Author

Choose a reason for hiding this comment

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

I gave it a shot at one point, but setting the component-preview modifier by pushing it into an array just... didn't work as expected for reasons I couldn't understand. It was being applied in contexts where it shouldn't on first load, but then would work correctly after restarting the server (and then break again..., rinse, repeat).

The res.render line didn't like having the .join inline either, so I just kept it as-is rather than try and debug and optimise where it might not be needed.

@colinrotherham colinrotherham self-requested a review June 15, 2023 10:51
Copy link
Contributor

@colinrotherham colinrotherham left a comment

Choose a reason for hiding this comment

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

Still superb, approving again 🙌

@querkmachine querkmachine merged commit da548a2 into main Jun 15, 2023
@querkmachine querkmachine deleted the review-app-inverse-example-support branch June 15, 2023 13:09
colinrotherham pushed a commit that referenced this pull request Jul 19, 2023
…port

Add ability to invert background colour in review app examples
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.

Allow for viewing of inverse modifications of components in the review app
3 participants