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

Discovery/load gcds #2048

Closed
wants to merge 6 commits into from
Closed
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
4 changes: 2 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ def useful_headers_after_request(response):
f"script-src-elem 'self' https://js-agent.newrelic.com *.siteintercept.qualtrics.com https://siteintercept.qualtrics.com 'nonce-{nonce}' 'unsafe-eval' data:;"
"connect-src 'self' *.google-analytics.com *.googletagmanager.com https://bam.nr-data.net *.siteintercept.qualtrics.com https://siteintercept.qualtrics.com;"
"object-src 'self';"
f"style-src 'self' fonts.googleapis.com https://tagmanager.google.com https://fonts.googleapis.com 'unsafe-inline';"
f"font-src 'self' {asset_domain} fonts.googleapis.com fonts.gstatic.com *.gstatic.com data:;"
f"style-src 'self' fonts.googleapis.com https://tagmanager.google.com https://fonts.googleapis.com https://cdnjs.cloudflare.com/ajax/libs/font-awesome/ 'unsafe-inline';"
f"font-src 'self' {asset_domain} fonts.googleapis.com fonts.gstatic.com *.gstatic.com https://cdnjs.cloudflare.com/ajax/libs/font-awesome/ data:;"
f"img-src 'self' blob: {asset_domain} *.canada.ca *.cdssandbox.xyz *.google-analytics.com *.googletagmanager.com *.notifications.service.gov.uk *.gstatic.com https://siteintercept.qualtrics.com data:;" # noqa: E501
"media-src 'self' *.alpha.canada.ca;"
"frame-ancestors 'self';"
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/main.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion app/templates/admin_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
{% block content %}
<div id="main_content" class="container px-gutterHalf contain-floats flex-grow">
<div class="grid-row contain-floats">
<main role="main" class="w-full float-left {% block main_content_class %}py-10{% endblock %} px-gutterHalf box-border column-main">
<main role="main"
class="w-full float-left {% block main_content_class %}py-10{% endblock %} px-gutterHalf box-border column-main">
{% if show_tou_prompt() %}
{{ tou_prompt() }}
{% else %}
Expand Down
10 changes: 10 additions & 0 deletions app/templates/main_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
{% include 'partials/google-tag-manager-head.html' %}
{% include 'partials/qualtrics-head.html' %}

<!-- GCDS icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
Copy link
Member

Choose a reason for hiding this comment

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

One thing to note here is that we are likely loading font-awesome twice now. Once here for GCDS, and then again for notify itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have our build pipeline to import a subset at least. So some icons will load twice for sure ... 😞

crossorigin="anonymous">

<!-- GC Design System -->
<link rel="stylesheet" media="screen" href="{{ asset_url('stylesheets/gcds.css') }}" />
Comment on lines +15 to +20
Copy link
Member

Choose a reason for hiding this comment

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

I wonder why we need to load 2 separate CSS files here - it would be nice if these were consolidated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think they'll be removing fontawesome soon in favour of their own icons.

<script nonce="{{ request_nonce }}" type="module" src="{{ asset_url('javascripts/gcds.esm.js') }}"></script>

<!-- end GCDS -->

<link
rel="stylesheet"
media="screen"
Expand Down
168 changes: 93 additions & 75 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const paths = {
templates: "app/templates/",
npm: "node_modules/",
toolkit: "node_modules/govuk_frontend_toolkit/",
gcds: "node_modules/@cdssnc/gcds-components/",
};

// 3. TASKS
Expand All @@ -34,87 +35,102 @@ const paths = {
// Move GOV.UK template resources

const javascripts = () => {
return src([
paths.toolkit + "javascripts/govuk/modules.js",
paths.toolkit + "javascripts/govuk/show-hide-content.js",
paths.src + "javascripts/utils.js",
paths.src + "javascripts/webpackLoader.js",
paths.src + "javascripts/stick-to-window-when-scrolling.js",
paths.src + "javascripts/detailsPolyfill.js",
paths.src + "javascripts/apiKey.js",
paths.src + "javascripts/cbor.js",
paths.src + "javascripts/fido2.js",
paths.src + "javascripts/autocomplete.js",
paths.src + "javascripts/autofocus.js",
paths.src + "javascripts/highlightTags.js",
paths.src + "javascripts/fileUpload.js",
paths.src + "javascripts/button.js",
paths.src + "javascripts/updateContent.js",
paths.src + "javascripts/listEntry.js",
paths.src + "javascripts/liveSearch.js",
paths.src + "javascripts/preventDuplicateFormSubmissions.js",
paths.src + "javascripts/fullscreenTable.js",
paths.src + "javascripts/previewPane.js",
paths.src + "javascripts/colourPreview.js",
paths.src + "javascripts/templateFolderForm.js",
paths.src + "javascripts/collapsibleCheckboxes.js",
paths.src + "javascripts/moreMenu.js",
paths.src + "javascripts/menu.js",
paths.src + "javascripts/scopeTabNavigation.js",
paths.src + "javascripts/url-typer.js",
paths.src + "javascripts/notificationsReports.js",
paths.src + "javascripts/main.js",
paths.src + "javascripts/templateCategories.js",
paths.src + "javascripts/templateContent.js",
])
.pipe(plugins.prettyerror())
.pipe(
plugins.babel({
presets: ["@babel/preset-env"],
})
)
.pipe(
plugins.addSrc.prepend([
//paths.src + 'javascripts/main.min.js',
paths.npm + "hogan.js/dist/hogan-3.0.2.js",
paths.npm + "jquery/dist/jquery.min.js",
paths.npm + "jquery-migrate/dist/jquery-migrate.min.js",
paths.npm + "query-command-supported/dist/queryCommandSupported.min.js",
//paths.npm + "diff-dom/diffDOM.js",
paths.npm + "textarea-caret/index.js",
paths.npm +
"accessible-autocomplete/dist/accessible-autocomplete.min.js",
])
)
//.pipe(plugins.uglify())
.pipe(plugins.concat("all.min.js"))
.pipe(
plugins.addSrc.prepend([
paths.src + "javascripts/main.min.js",
paths.src + "javascripts/scheduler.min.js",
paths.src + "javascripts/branding_request.min.js",
paths.src + "javascripts/formValidateRequired.min.js",
paths.src + "javascripts/sessionRedirect.min.js",
paths.src + "javascripts/touDialog.min.js",
paths.src + "javascripts/templateFilters.min.js",
])
)
.pipe(dest(paths.dist + "javascripts/"));
return (
src([
paths.toolkit + "javascripts/govuk/modules.js",
paths.toolkit + "javascripts/govuk/show-hide-content.js",
paths.src + "javascripts/utils.js",
paths.src + "javascripts/webpackLoader.js",
paths.src + "javascripts/stick-to-window-when-scrolling.js",
paths.src + "javascripts/detailsPolyfill.js",
paths.src + "javascripts/apiKey.js",
paths.src + "javascripts/cbor.js",
paths.src + "javascripts/fido2.js",
paths.src + "javascripts/autocomplete.js",
paths.src + "javascripts/autofocus.js",
paths.src + "javascripts/highlightTags.js",
paths.src + "javascripts/fileUpload.js",
paths.src + "javascripts/button.js",
paths.src + "javascripts/updateContent.js",
paths.src + "javascripts/listEntry.js",
paths.src + "javascripts/liveSearch.js",
paths.src + "javascripts/preventDuplicateFormSubmissions.js",
paths.src + "javascripts/fullscreenTable.js",
paths.src + "javascripts/previewPane.js",
paths.src + "javascripts/colourPreview.js",
paths.src + "javascripts/templateFolderForm.js",
paths.src + "javascripts/collapsibleCheckboxes.js",
paths.src + "javascripts/moreMenu.js",
paths.src + "javascripts/menu.js",
paths.src + "javascripts/scopeTabNavigation.js",
paths.src + "javascripts/url-typer.js",
paths.src + "javascripts/notificationsReports.js",
paths.src + "javascripts/main.js",
paths.src + "javascripts/templateCategories.js",
paths.src + "javascripts/templateContent.js",
])
.pipe(plugins.prettyerror())
.pipe(
plugins.babel({
presets: ["@babel/preset-env"],
}),
)
.pipe(
plugins.addSrc.prepend([
//paths.src + 'javascripts/main.min.js',
paths.npm + "hogan.js/dist/hogan-3.0.2.js",
paths.npm + "jquery/dist/jquery.min.js",
paths.npm + "jquery-migrate/dist/jquery-migrate.min.js",
paths.npm +
"query-command-supported/dist/queryCommandSupported.min.js",
//paths.npm + "diff-dom/diffDOM.js",
paths.npm + "textarea-caret/index.js",
paths.npm +
"accessible-autocomplete/dist/accessible-autocomplete.min.js",
]),
)
//.pipe(plugins.uglify())
.pipe(plugins.concat("all.min.js"))
.pipe(
plugins.addSrc.prepend([
paths.src + "javascripts/main.min.js",
paths.src + "javascripts/scheduler.min.js",
paths.src + "javascripts/branding_request.min.js",
paths.src + "javascripts/formValidateRequired.min.js",
paths.src + "javascripts/sessionRedirect.min.js",
paths.src + "javascripts/touDialog.min.js",
paths.src + "javascripts/templateFilters.min.js",
]),
)
.pipe(dest(paths.dist + "javascripts/"))
);
};

// copy static css
const static_css = () => {
return src(paths.src + "/stylesheets/index.css")
.pipe(
plugins.addSrc.prepend([
paths.npm + "accessible-autocomplete/dist/accessible-autocomplete.min.css",
paths.npm +
"accessible-autocomplete/dist/accessible-autocomplete.min.css",
paths.src + "stylesheets/fa-svg-with-js.css",
])
]),
)
.pipe(plugins.concat("index.css"))
.pipe(
dest(paths.dist + "stylesheets/")
);
.pipe(dest(paths.dist + "stylesheets/"));
};

// copy gcds
const gcds_styles = () => {
return src(paths.gcds + "/dist/gcds/gcds.css").pipe(
dest(paths.dist + "stylesheets/"),
);
};

const gcds_scripts = () => {
return src([paths.gcds + "/dist/gcds/**/*.js"]).pipe(
dest(paths.dist + "javascripts/"),
);
};

// Copy images
Expand Down Expand Up @@ -144,16 +160,18 @@ const watchFiles = {

// Default: compile everything
const defaultTask = parallel(
series(javascripts),
series(images),
series(static_css),
javascripts,
images,
gcds_scripts,
gcds_styles,
static_css,
);

// Watch for changes and re-run tasks
const watchForChanges = parallel(
watchFiles.javascripts,
watchFiles.images,
watchFiles.self
watchFiles.self,
);

exports.default = defaultTask;
Expand Down
Loading
Loading