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

Use external CSS files from .styles.scss source #5489

Merged
merged 1 commit into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 6 additions & 51 deletions kitsune/sumo/static/sumo/js/form-wizard.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import wizardStylesURL from "../scss/form-wizard.styles.scss";

/**
* A custom element for displaying multi-step forms. Designed to be used with
* child elements that inherit from `BaseFormStep`, or which implement a
Expand Down Expand Up @@ -44,57 +46,10 @@ export class FormWizard extends HTMLElement {
}

static get styles() {
let style = document.createElement("style");
style.textContent = `
:root,
:host {
--color-progress: var(--color-blue-06);
}

:host {
display: flex;
flex-direction: column;
border-radius: 8px;
box-shadow: 0px 2px 6px rgba(58, 57, 68, 0.2);
}

.form-wizard-content {
padding-inline: 32px;
padding-block-start: 24px;
}

h2 {
margin: 0;
font-size: 1.5rem;
line-height: 1;
color: var(--color-heading);
}

ul {
margin-inline-end: 48px;
}

section,
::slotted([slot="active"]) {
display: flex;
flex: 1;
}

progress {
flex: 1;
max-height: 8px;
appearance: none;
border: none;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
}

progress::-moz-progress-bar,
progress::-webkit-progress-value {
background-color: var(--color-progress);
}
`;
return style;
let stylesheet = document.createElement("link");
stylesheet.rel = "stylesheet";
stylesheet.href = wizardStylesURL;
return stylesheet;
}

constructor() {
Expand Down
47 changes: 47 additions & 0 deletions kitsune/sumo/static/sumo/scss/form-wizard.styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
:root,
:host {
--color-progress: var(--color-blue-06);
}

:host {
display: flex;
flex-direction: column;
border-radius: 8px;
box-shadow: 0px 2px 6px rgba(58, 57, 68, 0.2);
}

.form-wizard-content {
padding-inline: 32px;
padding-block-start: 24px;
}

h2 {
margin: 0;
font-size: 1.5rem;
line-height: 1;
color: var(--color-heading);
}

ul {
margin-inline-end: 48px;
}

section,
::slotted([slot="active"]) {
display: flex;
flex: 1;
}

progress {
flex: 1;
max-height: 8px;
appearance: none;
border: none;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
}

progress::-moz-progress-bar,
progress::-webkit-progress-value {
background-color: var(--color-progress);
}
12 changes: 11 additions & 1 deletion webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
preprocess: sveltePreprocess(),
compilerOptions: {
hydratable: true,
}
},
},
},
},
Expand All @@ -64,13 +64,23 @@ module.exports = {
},
{
test: /\.s?css$/,
exclude: /\.styles.scss$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"postcss-loader",
"sass-loader",
],
},
{
test: /\.styles.scss$/,
exclude: /node_modules/,
type: "asset/resource",
use: ["sass-loader"],
generator: {
filename: "[name].[contenthash].css"
}
},
{
test: /\.(svg|png|webp|gif|woff2?)$/,
type: "asset/resource",
Expand Down