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

Update guidance on importing parts of Frontend #56

Merged
merged 4 commits into from
Jun 1, 2020

Conversation

36degrees
Copy link
Contributor

With the changes in GOV.UK Frontend v3.7.0, the preferred way to import a subset of the components has changed, with the introduction of a new index file for each component.

Importing the components using the index file avoids re-importing the 'base' (settings, tools and helpers layers) multiple times, improving compilation times.

Differentiate between importing select bits of GOV.UK Frontend vs importing a single specific component.

Include /index by default when importing, as older Sass compilers don't support importing index files, but add a note that explains that you can remove it if you are using a newer version.

Closes #47

With the changes in GOV.UK Frontend v3.7.0, the preferred way to import a subset of the components has changed, with the introduction of a new index file for each component.

Importing the components using the index file avoids re-importing the 'base' (settings, tools and helpers layers) multiple times, improving compilation times.

Differentiate between importing _select bits_ of GOV.UK Frontend vs importing a single specific component.

Include `/index` by default when importing, as older Sass compilers don't support importing index files, but add a note that explains that you can remove it if you are using a newer version.
@36degrees 36degrees requested a review from m-green May 21, 2020 11:15
@36degrees 36degrees marked this pull request as draft May 21, 2020 11:20
@36degrees 36degrees added this to the v3.7.0 milestone May 21, 2020
@netlify
Copy link

netlify bot commented May 21, 2020

Deploy preview for govuk-frontend-docs-preview ready!

Built with commit 945fe2b

https://deploy-preview-56--govuk-frontend-docs-preview.netlify.app

@m-green m-green force-pushed the import-component-index-files branch from acabcc9 to eb9cac4 Compare May 27, 2020 10:15
@m-green
Copy link
Contributor

m-green commented May 27, 2020

@36degrees Updated following our discussion! Let me know if it looks ok to go to 2i.


To import the [button](https://design-system.service.gov.uk/components/button/) component for example, add the following to your Sass file:
If you want to improve how quickly Sass compiles to CSS, you can import only the Sass rules you need.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will also (and arguably a lot more importantly) improve performance for end users, as the compiled CSS will only include the bits required for the service, so it'll be smaller, and thus the page will load quicker.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah thanks - updated in 148d922.

Comment on lines 36 to 37
@import
"node_modules/govuk-frontend/govuk/overrides/all";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
@import
"node_modules/govuk-frontend/govuk/overrides/all";
@import "node_modules/govuk-frontend/govuk/overrides/all";

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops - thanks!

@36degrees
Copy link
Contributor Author

LGTM – needs 2i and v3.7.0 to be released?

@m-green
Copy link
Contributor

m-green commented May 27, 2020

This has been 2i'd - now waiting for v3.7.0 release.

@36degrees 36degrees marked this pull request as ready for review June 1, 2020 15:16
```
You can remove lines that import parts of the CSS you do not need.

[Read more about the different parts of GOV.UK Frontend’s CSS](https://github.com/alphagov/govuk-frontend/tree/master/src/govuk).
Copy link
Member

Choose a reason for hiding this comment

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

@36degrees 36degrees merged commit 35b485b into master Jun 1, 2020
@36degrees 36degrees deleted the import-component-index-files branch June 1, 2020 15:30
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.

Update documentation to reference new ways of importing components
3 participants