Skip to content

Commit

Permalink
Split out Font Awesome into separate CSS file, optimise colours (#76)
Browse files Browse the repository at this point in the history
* Split out Font Awesome into separate CSS file, optimise colours

* Add default light theme into stories
  • Loading branch information
ahosgood authored Jan 22, 2024
1 parent 39e3646 commit 29b3d2a
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import "../src/nationalarchives/all.scss";
import "../src/nationalarchives/font-awesome.scss";
import { a11yConfig } from "./storybook-config";
import { customViewports } from "./viewports";
import Cookies from "../src/nationalarchives/lib/cookies.mjs";

document.documentElement.classList.add(
"tna-template",
"tna-template--light-theme",
"tna-template--yellow-accent",
);
if (window.self !== window.top) {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Set smaller minimum width for search field inputs
- Added more space between the text and chevron in a heading link
- Split out Font Awesome into a separate CSS file

### Deprecated
### Removed
Expand Down
1 change: 0 additions & 1 deletion src/nationalarchives/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@

@use "variables";
@use "tools";
@use "lib";
@use "utilities";
@use "components";
6 changes: 6 additions & 0 deletions src/nationalarchives/font-awesome.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@use "variables/assets";

$fa-font-path: assets.$fa-font-path;
@import "lib/font-awesome/fontawesome";
@import "lib/font-awesome/solid";
@import "lib/font-awesome/brands";
6 changes: 0 additions & 6 deletions src/nationalarchives/lib/_font-awesome.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/nationalarchives/lib/_index.scss

This file was deleted.

46 changes: 25 additions & 21 deletions src/nationalarchives/tools/_colour.scss
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,38 @@
fill: var(--#{$colour}) if($important, !important, null);
}

%light {
@include colour-css-vars;

@media (prefers-contrast: more) {
@include colour-css-vars-high-contrast;
}
}

@mixin light {
@extend %light;
}

%dark {
@include colour-css-vars-dark;

@media (prefers-contrast: more) {
@include colour-css-vars-high-contrast-dark;
}
}

@mixin dark {
@extend %dark;
}

%plain {
.tna-template--system-theme & {
@include colour-css-vars;
@extend %light;

@media (prefers-color-scheme: dark) {
@include colour-css-vars-dark;
}

@media (prefers-contrast: more) {
@include colour-css-vars-high-contrast;
}

@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
@include colour-css-vars-high-contrast-dark;
}
Expand Down Expand Up @@ -190,22 +210,6 @@
@extend %plain;
}

@mixin light {
@include colour-css-vars;

@media (prefers-contrast: more) {
@include colour-css-vars-high-contrast;
}
}

@mixin dark {
@include colour-css-vars-dark;

@media (prefers-contrast: more) {
@include colour-css-vars-high-contrast-dark;
}
}

%contrast {
--background: var(--contrast-background);
--font-base: var(--contrast-font-base);
Expand Down
6 changes: 3 additions & 3 deletions src/nationalarchives/utilities/_colour.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@use "../tools/colour";

:root {
@include colour.colour-css-vars;
}
// :root {
// @include colour.colour-css-vars;
// }

.tna-template {
@include colour.colour-background("page-background");
Expand Down
6 changes: 6 additions & 0 deletions tasks/test-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ const checkExists = [
"nationalarchives/all.js.map",
"nationalarchives/all.mjs",
"nationalarchives/all.scss",
"nationalarchives/font-awesome.css",
"nationalarchives/font-awesome.css.map",
"nationalarchives/font-awesome.scss",
"nationalarchives/prototype-kit.css",
"nationalarchives/prototype-kit.css.map",
"nationalarchives/prototype-kit.scss",
// Assets
"nationalarchives/assets/fonts/fa-brands-400.ttf",
"nationalarchives/assets/fonts/fa-brands-400.woff2",
Expand Down

0 comments on commit 29b3d2a

Please sign in to comment.