2022-03-15 16:05:18 +01:00
|
|
|
|
const plugin = require('tailwindcss/plugin');
|
|
|
|
|
const vanillaRTL = require('tailwindcss-vanilla-rtl');
|
|
|
|
|
|
2022-03-04 23:55:24 +01:00
|
|
|
|
/**
|
|
|
|
|
* Design Tokens
|
|
|
|
|
*/
|
2022-02-27 17:08:38 +01:00
|
|
|
|
const colors = require('./src/tokens/colors');
|
|
|
|
|
const {
|
|
|
|
|
fontFamily,
|
|
|
|
|
fontSize,
|
|
|
|
|
fontWeight,
|
|
|
|
|
letterSpacing,
|
|
|
|
|
lineHeight,
|
|
|
|
|
} = require('./src/tokens/typography');
|
|
|
|
|
const { breakpoints } = require('./src/tokens/breakpoints');
|
|
|
|
|
const {
|
|
|
|
|
borderRadius,
|
|
|
|
|
borderWidth,
|
|
|
|
|
boxShadow,
|
|
|
|
|
} = require('./src/tokens/objectStyles');
|
|
|
|
|
const { spacing } = require('./src/tokens/spacing');
|
|
|
|
|
|
2022-03-04 23:55:24 +01:00
|
|
|
|
/**
|
|
|
|
|
* Plugins
|
|
|
|
|
*/
|
|
|
|
|
const typeScale = require('./src/tokens/typeScale');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Functions
|
|
|
|
|
* themeColors: For converting our design tokens into a format that tailwind accepts
|
|
|
|
|
*/
|
2022-02-27 17:08:38 +01:00
|
|
|
|
const themeColors = Object.fromEntries(
|
|
|
|
|
Object.entries(colors).map(([key, hues]) => {
|
|
|
|
|
const shades = Object.fromEntries(
|
|
|
|
|
Object.entries(hues).map(([k, shade]) => [k, shade.hex]),
|
|
|
|
|
);
|
|
|
|
|
return [key, shades];
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Root Tailwind config, reusable for other projects.
|
|
|
|
|
*/
|
|
|
|
|
module.exports = {
|
|
|
|
|
prefix: 'w-',
|
|
|
|
|
theme: {
|
|
|
|
|
screens: {
|
|
|
|
|
...breakpoints,
|
|
|
|
|
},
|
|
|
|
|
colors: {
|
|
|
|
|
...themeColors,
|
|
|
|
|
inherit: 'inherit',
|
|
|
|
|
current: 'currentColor',
|
|
|
|
|
transparent: 'transparent',
|
2022-03-15 16:05:18 +01:00
|
|
|
|
/* allow system colours https://www.w3.org/TR/css-color-4/#css-system-colors */
|
|
|
|
|
LinkText: 'LinkText',
|
|
|
|
|
ButtonText: 'ButtonText',
|
2022-02-27 17:08:38 +01:00
|
|
|
|
},
|
|
|
|
|
fontFamily,
|
|
|
|
|
fontSize,
|
|
|
|
|
fontWeight,
|
|
|
|
|
lineHeight,
|
|
|
|
|
letterSpacing,
|
|
|
|
|
borderRadius,
|
|
|
|
|
borderWidth,
|
|
|
|
|
boxShadow: {
|
|
|
|
|
...boxShadow,
|
|
|
|
|
none: 'none',
|
|
|
|
|
},
|
|
|
|
|
spacing,
|
2022-03-23 04:27:12 +01:00
|
|
|
|
extend: {
|
|
|
|
|
opacity: {
|
|
|
|
|
15: '0.15',
|
|
|
|
|
85: '0.85',
|
|
|
|
|
},
|
2022-03-28 16:43:35 +02:00
|
|
|
|
outlineOffset: {
|
|
|
|
|
inside: '-3px',
|
|
|
|
|
},
|
2022-03-23 04:27:12 +01:00
|
|
|
|
},
|
2022-02-27 17:08:38 +01:00
|
|
|
|
},
|
2022-03-15 16:05:18 +01:00
|
|
|
|
plugins: [
|
|
|
|
|
typeScale,
|
|
|
|
|
vanillaRTL,
|
|
|
|
|
/**
|
|
|
|
|
* forced-colors media query for Windows High-Contrast mode support
|
|
|
|
|
* See:
|
|
|
|
|
* - https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors
|
|
|
|
|
* - https://github.com/tailwindlabs/tailwindcss/blob/v3.0.23/src/corePlugins.js#L168-L171
|
|
|
|
|
*/
|
|
|
|
|
plugin(({ addVariant }) => {
|
|
|
|
|
addVariant('forced-colors', '@media (forced-colors: active)');
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
corePlugins: {
|
|
|
|
|
...vanillaRTL.disabledCorePlugins,
|
|
|
|
|
// Disable float and clear which have poor RTL support.
|
|
|
|
|
float: false,
|
|
|
|
|
clear: false,
|
2022-03-23 04:27:12 +01:00
|
|
|
|
// Disable text-transform so we don’t rely on uppercasing text.
|
|
|
|
|
textTransform: false,
|
2022-03-15 16:05:18 +01:00
|
|
|
|
},
|
2022-02-27 17:08:38 +01:00
|
|
|
|
};
|