From c609bf3f1a0942597c65c9779c351ee0dc62f1dd Mon Sep 17 00:00:00 2001 From: Andrew Hosgood Date: Tue, 21 Nov 2023 18:28:21 +0000 Subject: [PATCH] Add all colour combinations --- .storybook/storybook.scss | 57 +++++++++++ .../components/gallery/gallery.stories.js | 16 ++-- .../colour-combinations.stories.js | 94 +++++++++++++++++++ .../colour-schemes/colour-schemes.stories.js | 36 +++---- src/nationalarchives/variables/_colour.scss | 5 +- 5 files changed, 179 insertions(+), 29 deletions(-) create mode 100644 src/nationalarchives/stories/utilities/colour-schemes/colour-combinations.stories.js diff --git a/.storybook/storybook.scss b/.storybook/storybook.scss index 8426ff41..427d828a 100644 --- a/.storybook/storybook.scss +++ b/.storybook/storybook.scss @@ -1,3 +1,5 @@ +@use "sass:math"; + @use "../src/nationalarchives/tools/colour"; @use "../src/nationalarchives/tools/media"; @@ -145,3 +147,58 @@ // @include colour.colour-border("keyline", 1px, solid, top); } } + +.tna-colour-contrast-demo { + display: table; + + border-top: rgb(0 0 0/0.25) 1px solid; + border-left: rgb(0 0 0/0.25) 1px solid; + + &__header { + display: table-header-group; + } + + &__block { + width: #{math.div(100%, 6)}; + padding: 1rem; + + display: table-cell; + + border-right: rgb(0 0 0/0.25) 1px solid; + border-bottom: rgb(0 0 0/0.25) 1px solid; + } + + &__examples { + display: table-row-group; + } + + &__theme-accent { + display: table-row; + } + + &__example { + display: table-cell; + + border-right: rgb(0 0 0/0.25) 1px solid; + border-bottom: rgb(0 0 0/0.25) 1px solid; + + &-content { + height: 100%; + padding: 1rem; + } + } + + &__link { + &--visited { + @include colour.colour-font("link-visited", true); + } + } + + .tna-template { + min-width: 15.25rem; + } + + .tna-chip { + margin: 1rem 0; + } +} diff --git a/src/nationalarchives/components/gallery/gallery.stories.js b/src/nationalarchives/components/gallery/gallery.stories.js index ed7459de..f6019555 100644 --- a/src/nationalarchives/components/gallery/gallery.stories.js +++ b/src/nationalarchives/components/gallery/gallery.stories.js @@ -62,14 +62,14 @@ Standard.args = { }, ] : index === 1 - ? [ - { - id: "tab-1", - title: "Transcript", - body: "

TEST TRANSCRIPT

", - }, - ] - : null, + ? [ + { + id: "tab-1", + title: "Transcript", + body: "

TEST TRANSCRIPT

", + }, + ] + : null, })), classes: "tna-gallery--demo", diff --git a/src/nationalarchives/stories/utilities/colour-schemes/colour-combinations.stories.js b/src/nationalarchives/stories/utilities/colour-schemes/colour-combinations.stories.js new file mode 100644 index 00000000..eddfa858 --- /dev/null +++ b/src/nationalarchives/stories/utilities/colour-schemes/colour-combinations.stories.js @@ -0,0 +1,94 @@ +import Button from "../../../components/button/template.njk"; + +export default { + title: "Utilities/Colour combinations", +}; + +const Template = () => { + const themes = [ + "tna-template--light-theme", + "tna-template--dark-theme", + "tna-template--light-theme tna-template--high-contrast-theme", + "tna-template--dark-theme tna-template--high-contrast-theme", + ]; + + const accents = [ + "", + "tna-template--black-accent", + "tna-template--yellow-accent", + "tna-template--pink-accent", + "tna-template--orange-accent", + "tna-template--green-accent", + "tna-template--blue-accent", + ]; + + const blocks = [ + "", + "tna-background-tint", + "tna-background-contrast", + "tna-background-accent", + "tna-background-accent-light", + ]; + + return `
+
+
+ Blocks +
+ ${blocks.reduce( + (blockOutput, block) => + `${blockOutput}
+ ${block || "Base"} +
`, + "", + )} +
+
+ ${themes.reduce( + (themeOutput, theme) => + `${themeOutput}${accents.reduce( + ( + accentOutput, + accent, + ) => `${accentOutput}
+
+ ${theme.replace(/tna-template--/g, "").replace(/-theme/g, "")} / ${accent + .replace(/tna-template--/g, "") + .replace(/-accent/g, "")} +
+ ${blocks.reduce( + (blockOutput, block) => + `${blockOutput}
+
+
+

Text

+

Link

+

Link (visited)

+ Chip + ${Button({ + params: { + text: "Button", + }, + })} + ${Button({ + params: { + text: "Button", + accent: true, + }, + })} +
+
+
`, + "", + )} +
`, + "", + )}`, + "", + )} +
+
`; +}; + +export const All = Template.bind({}); +All.args = {}; diff --git a/src/nationalarchives/stories/utilities/colour-schemes/colour-schemes.stories.js b/src/nationalarchives/stories/utilities/colour-schemes/colour-schemes.stories.js index b8ed02d7..45d593c0 100644 --- a/src/nationalarchives/stories/utilities/colour-schemes/colour-schemes.stories.js +++ b/src/nationalarchives/stories/utilities/colour-schemes/colour-schemes.stories.js @@ -64,28 +64,28 @@ const Template = ({ theme, accent }) => { theme === "system" ? "tna-template--system-theme" : theme === "light" - ? "tna-template--light-theme" - : theme === "dark" - ? "tna-template--dark-theme" - : theme === "light high-contrast" - ? "tna-template--light-theme tna-template--high-contrast-theme" - : theme === "dark high-contrast" - ? "tna-template--dark-theme tna-template--high-contrast-theme" - : "" + ? "tna-template--light-theme" + : theme === "dark" + ? "tna-template--dark-theme" + : theme === "light high-contrast" + ? "tna-template--light-theme tna-template--high-contrast-theme" + : theme === "dark high-contrast" + ? "tna-template--dark-theme tna-template--high-contrast-theme" + : "" } ${ accent === "black" ? "tna-template--black-accent" : accent === "yellow" - ? "tna-template--yellow-accent" - : accent === "pink" - ? "tna-template--pink-accent" - : accent === "orange" - ? "tna-template--orange-accent" - : accent === "green" - ? "tna-template--green-accent" - : accent === "blue" - ? "tna-template--blue-accent" - : "" + ? "tna-template--yellow-accent" + : accent === "pink" + ? "tna-template--pink-accent" + : accent === "orange" + ? "tna-template--orange-accent" + : accent === "green" + ? "tna-template--green-accent" + : accent === "blue" + ? "tna-template--blue-accent" + : "" }">