🔧 Remove opacity function from Tailwind config

pull/225/head
James Panther 2022-06-22 17:19:54 +10:00
parent 8afccdfe49
commit 7099d08355
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
1 changed files with 83 additions and 93 deletions

View File

@ -1,14 +1,3 @@
const colors = require("tailwindcss/colors");
function varWithOpacity(variable) {
return ({ opacityValue }) => {
if (opacityValue === undefined) {
return `rgb(var(${variable}))`;
}
return `rgba(var(${variable}), ${opacityValue})`;
};
}
module.exports = { module.exports = {
content: [ content: [
"./layouts/**/*.html", "./layouts/**/*.html",
@ -18,89 +7,90 @@ module.exports = {
], ],
darkMode: "class", darkMode: "class",
theme: { theme: {
extend: {
colors: { colors: {
transparent: "transparent",
neutral: { neutral: {
DEFAULT: varWithOpacity("--color-neutral"), DEFAULT: "rgba(var(--color-neutral), <alpha-value>)",
50: varWithOpacity("--color-neutral-50"), 50: "rgba(var(--color-neutral-50), <alpha-value>)",
100: varWithOpacity("--color-neutral-100"), 100: "rgba(var(--color-neutral-100), <alpha-value>)",
200: varWithOpacity("--color-neutral-200"), 200: "rgba(var(--color-neutral-200), <alpha-value>)",
300: varWithOpacity("--color-neutral-300"), 300: "rgba(var(--color-neutral-300), <alpha-value>)",
400: varWithOpacity("--color-neutral-400"), 400: "rgba(var(--color-neutral-400), <alpha-value>)",
500: varWithOpacity("--color-neutral-500"), 500: "rgba(var(--color-neutral-500), <alpha-value>)",
600: varWithOpacity("--color-neutral-600"), 600: "rgba(var(--color-neutral-600), <alpha-value>)",
700: varWithOpacity("--color-neutral-700"), 700: "rgba(var(--color-neutral-700), <alpha-value>)",
800: varWithOpacity("--color-neutral-800"), 800: "rgba(var(--color-neutral-800), <alpha-value>)",
900: varWithOpacity("--color-neutral-900"), 900: "rgba(var(--color-neutral-900), <alpha-value>)",
}, },
primary: { primary: {
50: varWithOpacity("--color-primary-50"), 50: "rgba(var(--color-primary-50), <alpha-value>)",
100: varWithOpacity("--color-primary-100"), 100: "rgba(var(--color-primary-100), <alpha-value>)",
200: varWithOpacity("--color-primary-200"), 200: "rgba(var(--color-primary-200), <alpha-value>)",
300: varWithOpacity("--color-primary-300"), 300: "rgba(var(--color-primary-300), <alpha-value>)",
400: varWithOpacity("--color-primary-400"), 400: "rgba(var(--color-primary-400), <alpha-value>)",
500: varWithOpacity("--color-primary-500"), 500: "rgba(var(--color-primary-500), <alpha-value>)",
600: varWithOpacity("--color-primary-600"), 600: "rgba(var(--color-primary-600), <alpha-value>)",
700: varWithOpacity("--color-primary-700"), 700: "rgba(var(--color-primary-700), <alpha-value>)",
800: varWithOpacity("--color-primary-800"), 800: "rgba(var(--color-primary-800), <alpha-value>)",
900: varWithOpacity("--color-primary-900"), 900: "rgba(var(--color-primary-900), <alpha-value>)",
}, },
secondary: { secondary: {
50: varWithOpacity("--color-secondary-50"), 50: "rgba(var(--color-secondary-50), <alpha-value>)",
100: varWithOpacity("--color-secondary-100"), 100: "rgba(var(--color-secondary-100), <alpha-value>)",
200: varWithOpacity("--color-secondary-200"), 200: "rgba(var(--color-secondary-200), <alpha-value>)",
300: varWithOpacity("--color-secondary-300"), 300: "rgba(var(--color-secondary-300), <alpha-value>)",
400: varWithOpacity("--color-secondary-400"), 400: "rgba(var(--color-secondary-400), <alpha-value>)",
500: varWithOpacity("--color-secondary-500"), 500: "rgba(var(--color-secondary-500), <alpha-value>)",
600: varWithOpacity("--color-secondary-600"), 600: "rgba(var(--color-secondary-600), <alpha-value>)",
700: varWithOpacity("--color-secondary-700"), 700: "rgba(var(--color-secondary-700), <alpha-value>)",
800: varWithOpacity("--color-secondary-800"), 800: "rgba(var(--color-secondary-800), <alpha-value>)",
900: varWithOpacity("--color-secondary-900"), 900: "rgba(var(--color-secondary-900), <alpha-value>)",
}, },
}, },
typography: (theme) => ({ extend: {
typography: ({ theme }) => ({
DEFAULT: { DEFAULT: {
css: { css: {
"--tw-prose-body": theme("colors.neutral.700"), "--tw-prose-body": theme("colors.neutral.700 / 1"),
"--tw-prose-headings": theme("colors.neutral.800"), "--tw-prose-headings": theme("colors.neutral.800 / 1"),
"--tw-prose-lead": theme("colors.neutral.500"), "--tw-prose-lead": theme("colors.neutral.500 / 1"),
"--tw-prose-links": theme("colors.primary.700"), "--tw-prose-links": theme("colors.primary.700 / 1"),
"--tw-prose-bold": theme("colors.neutral.900"), "--tw-prose-bold": theme("colors.neutral.900 / 1"),
"--tw-prose-counters": theme("colors.neutral.800"), "--tw-prose-counters": theme("colors.neutral.800 / 1"),
"--tw-prose-bullets": theme("colors.neutral.500"), "--tw-prose-bullets": theme("colors.neutral.500 / 1"),
"--tw-prose-hr": theme("colors.neutral.200"), "--tw-prose-hr": theme("colors.neutral.200 / 1"),
"--tw-prose-quotes": theme("colors.neutral.700"), "--tw-prose-quotes": theme("colors.neutral.700 / 1"),
"--tw-prose-quote-borders": theme("colors.primary.200"), "--tw-prose-quote-borders": theme("colors.primary.200 / 1"),
"--tw-prose-captions": theme("colors.neutral.500"), "--tw-prose-captions": theme("colors.neutral.500 / 1"),
"--tw-prose-code": theme("colors.secondary.700"), "--tw-prose-code": theme("colors.secondary.700 / 1"),
"--tw-prose-pre-code": theme("colors.neutral.700"), "--tw-prose-pre-code": theme("colors.neutral.700 / 1"),
"--tw-prose-pre-bg": theme("colors.neutral.50"), "--tw-prose-pre-bg": theme("colors.neutral.50 / 1"),
"--tw-prose-th-borders": theme("colors.neutral.500"), "--tw-prose-th-borders": theme("colors.neutral.500 / 1"),
"--tw-prose-td-borders": theme("colors.neutral.300"), "--tw-prose-td-borders": theme("colors.neutral.300 / 1"),
"--tw-prose-invert-body": theme("colors.neutral.300"), "--tw-prose-invert-body": theme("colors.neutral.300 / 1"),
"--tw-prose-invert-headings": theme("colors.neutral.50"), "--tw-prose-invert-headings": theme("colors.neutral.50 / 1"),
"--tw-prose-invert-lead": theme("colors.neutral.500"), "--tw-prose-invert-lead": theme("colors.neutral.500 / 1"),
"--tw-prose-invert-links": theme("colors.primary.400"), "--tw-prose-invert-links": theme("colors.primary.400 / 1"),
"--tw-prose-invert-bold": theme("colors.neutral.DEFAULT"), "--tw-prose-invert-bold": theme("colors.neutral.DEFAULT / 1"),
"--tw-prose-invert-counters": theme("colors.neutral.400"), "--tw-prose-invert-counters": theme("colors.neutral.400 / 1"),
"--tw-prose-invert-bullets": theme("colors.neutral.600"), "--tw-prose-invert-bullets": theme("colors.neutral.600 / 1"),
"--tw-prose-invert-hr": theme("colors.neutral.500"), "--tw-prose-invert-hr": theme("colors.neutral.500 / 1"),
"--tw-prose-invert-quotes": theme("colors.neutral.200"), "--tw-prose-invert-quotes": theme("colors.neutral.200 / 1"),
"--tw-prose-invert-quote-borders": theme("colors.primary.900"), "--tw-prose-invert-quote-borders": theme("colors.primary.900 / 1"),
"--tw-prose-invert-captions": theme("colors.neutral.400"), "--tw-prose-invert-captions": theme("colors.neutral.400 / 1"),
"--tw-prose-invert-code": theme("colors.secondary.400"), "--tw-prose-invert-code": theme("colors.secondary.400 / 1"),
"--tw-prose-invert-pre-code": theme("colors.neutral.200"), "--tw-prose-invert-pre-code": theme("colors.neutral.200 / 1"),
"--tw-prose-invert-pre-bg": theme("colors.neutral.700"), "--tw-prose-invert-pre-bg": theme("colors.neutral.700 / 1"),
"--tw-prose-invert-th-borders": theme("colors.neutral.500"), "--tw-prose-invert-th-borders": theme("colors.neutral.500 / 1"),
"--tw-prose-invert-td-borders": theme("colors.neutral.700"), "--tw-prose-invert-td-borders": theme("colors.neutral.700 / 1"),
a: { a: {
textDecoration: "underline", textDecoration: "underline",
textDecorationColor: theme("colors.primary.300"), textDecorationColor: theme("colors.primary.300 / 1"),
fontWeight: "500", fontWeight: "500",
"&:hover": { "&:hover": {
color: theme("colors.neutral.DEFAULT"), color: theme("colors.neutral.DEFAULT / 1"),
textDecoration: "none", textDecoration: "none",
backgroundColor: theme("colors.primary.600"), backgroundColor: theme("colors.primary.600 / 1"),
borderRadius: "0.09rem", borderRadius: "0.09rem",
}, },
}, },
@ -108,15 +98,15 @@ module.exports = {
color: "var(--tw-prose-code)", color: "var(--tw-prose-code)",
}, },
kbd: { kbd: {
backgroundColor: theme("colors.neutral.200"), backgroundColor: theme("colors.neutral.200 / 1"),
padding: "0.1rem 0.4rem", padding: "0.1rem 0.4rem",
borderRadius: "0.25rem", borderRadius: "0.25rem",
fontSize: "0.9rem", fontSize: "0.9rem",
fontWeight: "600", fontWeight: "600",
}, },
mark: { mark: {
color: theme("colors.neutral.800"), color: theme("colors.neutral.800 / 1"),
backgroundColor: theme("colors.secondary.200"), backgroundColor: theme("colors.secondary.200 / 1"),
padding: "0.1rem 0.2rem", padding: "0.1rem 0.2rem",
borderRadius: "0.12rem", borderRadius: "0.12rem",
}, },
@ -125,14 +115,14 @@ module.exports = {
invert: { invert: {
css: { css: {
a: { a: {
textDecorationColor: theme("colors.neutral.600"), textDecorationColor: theme("colors.neutral.600 / 1"),
}, },
kbd: { kbd: {
color: theme("colors.neutral.200"), color: theme("colors.neutral.200 / 1"),
backgroundColor: theme("colors.neutral.700"), backgroundColor: theme("colors.neutral.700 / 1"),
}, },
mark: { mark: {
backgroundColor: theme("colors.secondary.400"), backgroundColor: theme("colors.secondary.400 / 1"),
}, },
}, },
}, },