refactor: use a multi-theme plugin for colours
This commit is contained in:
parent
a0951ef2f3
commit
096fe8f1ce
|
@ -6,7 +6,7 @@ export default function Home() {
|
||||||
<div data-theme="blue" className="mx-auto max-w-6xl">
|
<div data-theme="blue" className="mx-auto max-w-6xl">
|
||||||
<h2 className="sr-only">Featured case study</h2>
|
<h2 className="sr-only">Featured case study</h2>
|
||||||
<section className="font-sans text-black">
|
<section className="font-sans text-black">
|
||||||
<div className="lg:flex lg:items-center [ ] fancy-corners fancy-corners--large fancy-corners--top-left fancy-corners--bottom-right">
|
<div className="lg:flex lg:items-center fancy-corners fancy-corners--large fancy-corners--top-left fancy-corners--bottom-right">
|
||||||
<div className="flex-shrink-0 self-stretch sm:flex-basis-40 md:flex-basis-50 xl:flex-basis-60">
|
<div className="flex-shrink-0 self-stretch sm:flex-basis-40 md:flex-basis-50 xl:flex-basis-60">
|
||||||
<div className="h-full">
|
<div className="h-full">
|
||||||
<article className="h-full">
|
<article className="h-full">
|
||||||
|
@ -42,7 +42,7 @@ export default function Home() {
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a
|
<a
|
||||||
className="mt-4 button button--secondary"
|
className="inline-block py-2 px-5 mt-4 text-lg font-bold border-2 transition-colors duration-200 ease-in-out hover:bg-white focus:bg-white bg-secondary border-secondary text-tertiary hover:border-quinary hover:text-quinary focus:border-quinary focus:text-quinary"
|
||||||
href="https://inviqa.com/cxcon-experience-transformation"
|
href="https://inviqa.com/cxcon-experience-transformation"
|
||||||
>
|
>
|
||||||
Explore this event
|
Explore this event
|
||||||
|
|
|
@ -3,22 +3,6 @@
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
@layer components {
|
@layer components {
|
||||||
.button {
|
|
||||||
@apply px-5 py-2 inline-block text-lg font-bold border-2 duration-200 transition-colors ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme="blue"] .button--secondary {
|
|
||||||
@apply bg-red border-red text-white hover:bg-white hover:text-red;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme="purple"] .button--secondary {
|
|
||||||
@apply bg-orange border-orange text-purple hover:bg-white hover:text-purple hover:border-purple;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme="teal"] .button--secondary {
|
|
||||||
@apply bg-pink border-pink text-white hover:bg-white hover:text-pink;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fancy-corners {
|
.fancy-corners {
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
|
@ -30,21 +14,11 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 8em;
|
width: 8em;
|
||||||
height: 8em;
|
height: 8em;
|
||||||
|
background-color: theme('colors.primary');
|
||||||
background-size: 100% 100%;
|
background-size: 100% 100%;
|
||||||
background-position: 0 0;
|
background-position: 0 0;
|
||||||
transform: translateZ(-1px);
|
transform: translateZ(-1px);
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
@apply bg-purple;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme="blue"] .fancy-corners:after,
|
|
||||||
[data-theme="blue"] .fancy-corners:before {
|
|
||||||
@apply bg-blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme="teal"] .fancy-corners:after,
|
|
||||||
[data-theme="teal"] .fancy-corners:before {
|
|
||||||
@apply bg-teal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.fancy-corners[class*="--bottom"]:after,
|
.fancy-corners[class*="--bottom"]:after,
|
||||||
|
|
|
@ -1,3 +1,73 @@
|
||||||
|
let plugin = require("tailwindcss/plugin");
|
||||||
|
|
||||||
|
let colors = {
|
||||||
|
black: "#333333",
|
||||||
|
blue: "#334982",
|
||||||
|
grey: "#f3f3f3",
|
||||||
|
orange: "#fdb913",
|
||||||
|
pink: "#e40087",
|
||||||
|
purple: "#782b8f",
|
||||||
|
red: "#dd372f",
|
||||||
|
teal: "#00857d",
|
||||||
|
white: "#fff",
|
||||||
|
};
|
||||||
|
|
||||||
|
let themes = {
|
||||||
|
blue: {
|
||||||
|
quaternary: colors.red,
|
||||||
|
quinary: colors.red,
|
||||||
|
primary: colors.blue,
|
||||||
|
secondary: colors.red,
|
||||||
|
tertiary: colors.white,
|
||||||
|
},
|
||||||
|
|
||||||
|
purple: {
|
||||||
|
quaternary: colors.white,
|
||||||
|
quinary: colors.purple,
|
||||||
|
primary: colors.purple,
|
||||||
|
secondary: colors.orange,
|
||||||
|
tertiary: colors.purple,
|
||||||
|
},
|
||||||
|
|
||||||
|
teal: {
|
||||||
|
quaternary: colors.pink,
|
||||||
|
quinary: colors.pink,
|
||||||
|
primary: colors.teal,
|
||||||
|
secondary: colors.pink,
|
||||||
|
tertiary: colors.white,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let multiThemePlugin = plugin(function ({ addBase }) {
|
||||||
|
addBase(generateForRoot());
|
||||||
|
|
||||||
|
Object.keys(themes).forEach((themeName) => {
|
||||||
|
addBase(generateForTheme(themeName));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function generateForRoot() {
|
||||||
|
let defaultThemeName = Object.keys(themes)[0];
|
||||||
|
|
||||||
|
return Object.entries(themes[defaultThemeName]).map(([colourName, value]) => {
|
||||||
|
return {
|
||||||
|
":root": {
|
||||||
|
[`--color-${colourName}`]: value,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateForTheme(themeName) {
|
||||||
|
return Object.entries(themes[themeName]).map(([colourName, value]) => {
|
||||||
|
return {
|
||||||
|
[`[data-theme=${themeName}]`]: {
|
||||||
|
[`--color-${colourName}`]: value,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
content: [
|
content: [
|
||||||
|
@ -6,17 +76,14 @@ module.exports = {
|
||||||
],
|
],
|
||||||
theme: {
|
theme: {
|
||||||
colors: {
|
colors: {
|
||||||
black: "#333333",
|
...colors,
|
||||||
blue: "#334982",
|
|
||||||
grey: "#f3f3f3",
|
quaternary: "var(--color-quaternary)",
|
||||||
orange: "#fdb913",
|
quinary: "var(--color-quinary)",
|
||||||
pink: "#e40087",
|
primary: "var(--color-primary)",
|
||||||
purple: "#782b8f",
|
secondary: "var(--color-secondary)",
|
||||||
red: "#dd372f",
|
tertiary: "var(--color-tertiary)",
|
||||||
teal: "#00857d",
|
|
||||||
white: "#fff",
|
|
||||||
},
|
},
|
||||||
extend: {},
|
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: [multiThemePlugin],
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue