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

Tidy up how our sass and js is imported #3807

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 4 additions & 29 deletions src/javascripts/application.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
/* eslint-disable no-new */

// Import directly from the modules in govuk-frontend because our treeshaking
// currently doesn't work when importing directly from govuk-frontend
//
// See https://github.com/alphagov/govuk-frontend/issues/4957
import { Button } from 'govuk-frontend/dist/govuk/components/button/button.mjs'
import { NotificationBanner } from 'govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs'
import { SkipLink } from 'govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs'
import { createAll, Button, NotificationBanner, SkipLink } from 'govuk-frontend'

import Analytics from './components/analytics.mjs'
import BackToTop from './components/back-to-top.mjs'
Expand All @@ -24,28 +18,9 @@ import Search from './components/search.mjs'
import AppTabs from './components/tabs.mjs'

// Initialise GOV.UK Frontend
// Button
const $buttons = document.querySelectorAll('[data-module="govuk-button"]')

$buttons.forEach(($button) => {
new Button($button)
})

// Notification Banner
const $notificationBanner = document.querySelector(
'[data-module="govuk-notification-banner"]'
)

if ($notificationBanner) {
new NotificationBanner($notificationBanner)
}

// Skip link
const $skipLink = document.querySelector('[data-module="govuk-skip-link"]')

// No checking if it exists because we can safely assume there will always be
// a skip link on a page
new SkipLink($skipLink)
createAll(Button)
createAll(NotificationBanner)
createAll(SkipLink)

// Initialise cookie banner
const $cookieBanner = document.querySelector(
Expand Down
6 changes: 3 additions & 3 deletions src/stylesheets/_example-init.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@import "govuk/settings/all";
@import "govuk/helpers/all";
@import "govuk/tools/all";
@import "govuk/settings";
@import "govuk/helpers";
@import "govuk/tools";
12 changes: 6 additions & 6 deletions src/stylesheets/main.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
$govuk-new-typography-scale: true;

@import "govuk/settings/all";
@import "govuk/helpers/all";
@import "govuk/tools/all";
@import "govuk/core/all";
@import "govuk/objects/all";
@import "govuk/settings";
@import "govuk/helpers";
@import "govuk/tools";
@import "govuk/core";
@import "govuk/objects";

@import "govuk/components/back-link";
@import "govuk/components/breadcrumbs";
Expand Down Expand Up @@ -33,7 +33,7 @@ $govuk-new-typography-scale: true;
@import "govuk/components/task-list";
@import "govuk/components/warning-text";

@import "govuk/utilities/all";
@import "govuk/utilities";

@import "govuk/overrides/spacing";
@import "govuk/overrides/text-align";
Expand Down