-
Notifications
You must be signed in to change notification settings - Fork 90
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
Allow for a single-file import of all elements stylesheets #489
Allow for a single-file import of all elements stylesheets #489
Conversation
Thanks @lennym! The relationship between the govuk-elements-sass files and the govuk_frontend_toolkit isn't explicit (ideally the imports would be at the top of each file - not that it would resolve the issue with includePaths - but at least the relationship between the two would be clearer.) I've been trying to avoid making breaking changes - which is why they're still listed at the top. This looks good, I'm hoping to release a new version of govuk-elements-sass shortly and will include this in that release. |
Thanks a lot @gemmaleigh. One thing I might suggest, that would be super helpful to us at least, (and since you seem to have ownership of govuk-frontend-toolkit too) would be to have all those dependencies import-able as a single file - something like this PR - rather than needing to pull them all in individually. |
I won't be able to merge this PR as-is, as the package is built from assets in |
I think I see what you mean... the same set of changes should be made to the files in the Will do. Give me 5 minutes. |
You'll only need to make the changes once in the assets directory, there's a https://github.com/alphagov/govuk_elements/blob/master/gulpfile.js#L127 Cheers! |
I've pushed the changes in assets - actually an extra change to also group the govuk-frontend-toolkit files as well, as IMO this makes it a lot clearer what is coming from where. If you want me to undo the changes in Edit: looks like I'll need to add the extra files to the gulp task too. |
If you could undo the changes in packages (aside from the change to the package.json file) and ensure those two new files are copied over, that would be great - thanks! |
Makes it slightly clearer when reading the main sass entry point file which of the modules are coming from govuk-frontent-toolkit, and which are coming from this module.
This allows sass compilers which dynamically look for a module's entry-point file to read the correct file.
072fe95
to
93f4448
Compare
Done. Let me know if I need to do anything else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works nicely, thanks for making those changes - much appreciated!
If we drop the govuk- prefix from both, the elements import becomes import “elements” to import all govuk-elements partials and import “frontend-toolkit” to import the govuk-frontend-toolkit dependencies. The main govuk-elements stylesheet still imports the same partials, these were split into two files in #489.
Move the import of the govuk-elements styles into a single, standalone file so they can be imported as a single import statement without also including govuk_frontent_toolkit files.
What problem does the pull request solve?
We use a sass compiler which is npm-aware (https://npmjs.com/npm-sass), and so generally don't use configured
includePaths
when compiling. However, the main sass file in this repo is only compilable if theincludePaths
are set.By moving the govuk-elements-sass code (as distinct from the govuk_frontend_toolkit code), we can
@import "govuk-elements-sass"
in our stylesheets and have them compile correctly (note thesass
property added to package.json supports this shorthand, as opposed to having to specify a full file path)This will also support any users who wish to import the elements code alone, without also importing govuk_frontend_toolkit for whatever reason.
What type of change is it?
Has the documentation been updated?