import type { Config } from 'tailwindcss'; import plugin from 'tailwindcss/plugin'; export const plugins = [ // eslint-disable-next-line @typescript-eslint/unbound-method plugin(({ addUtilities, matchUtilities, theme, addComponents }) => { addUtilities({ '.scrollbar-thin': { 'scrollbar-width': 'thin', }, }); matchUtilities( { scrollbar: (value: string) => ({ scrollbarColor: value, }), }, { values: theme('colors') as Record } ); matchUtilities( { 'scrollbar-w': (value: string) => ({ '&::-webkit-scrollbar': { width: value, }, }), }, { values: theme('width') as Record } ); matchUtilities( { 'scrollbar-track': (value: string) => ({ '&::-webkit-scrollbar-track': { background: value, }, }), }, { values: theme('colors') as Record } ); matchUtilities( { 'scrollbar-thumb': (value: string) => ({ '&::-webkit-scrollbar-thumb': { backgroundColor: value, }, }), }, { values: theme('colors') as Record } ); matchUtilities( { 'scrollbar-thumb-border': (value: string) => ({ '&::-webkit-scrollbar-thumb': { borderRadius: value, }, }), }, { values: theme('borderRadius') as Record } ); matchUtilities( { 'scrollbar-thumb-border': (value: string) => ({ '&::-webkit-scrollbar-thumb': { borderWidth: value, }, }), }, { values: theme('borderWidth') as Record } ); matchUtilities( { 'scrollbar-thumb-border': (value: string) => ({ '&::-webkit-scrollbar-thumb': { borderColor: value, }, }), }, { values: theme('borderColor') as Record } ); matchUtilities( { 'slider-track': (value: string) => ({ '&::-webkit-slider-runnable-track': { background: value, }, '&::-moz-range-track': { background: value, }, '&::-ms-track': { background: 'transparent', }, '&::-ms-fill-lower': { background: value, }, '&::-ms-fill-upper': { background: value, }, }), }, { values: theme('colors') as Record } ); matchUtilities( { 'slider-track-w': (value: string) => ({ '&::-webkit-slider-runnable-track': { width: value, }, '&::-moz-range-track': { width: value, }, '&::-ms-track': { width: value, }, }), }, { values: theme('width') as Record } ); matchUtilities( { 'slider-track-h': (value: string) => ({ '&::-webkit-slider-runnable-track': { height: value, }, '&::-moz-range-track': { height: value, }, '&::-ms-track': { height: value, }, }), }, { values: theme('height') as Record } ); matchUtilities( { 'slider-track-cursor': (value: string) => ({ '&::-webkit-slider-runnable-track': { cursor: value, }, '&::-moz-range-track': { cursor: value, }, '&::-ms-track': { cursor: value, }, }), }, { values: theme('cursor') as Record } ); matchUtilities( { 'slider-thumb': (value: string) => ({ '&::-webkit-slider-thumb': { background: value, }, '&::-moz-range-thumb': { background: value, }, '&::-ms-thumb': { background: value, }, }), }, { values: { ...(theme('backgroundColor') as Record), }, } ); matchUtilities( { 'slider-thumb-w': (value: string) => ({ '&::-webkit-slider-thumb': { width: value, }, '&::-moz-range-thumb': { width: value, }, '&::-ms-thumb': { width: value, }, }), }, { values: theme('width') as Record } ); matchUtilities( { 'slider-thumb-h': (value: string) => ({ '&::-webkit-slider-thumb': { height: value, marginTop: `calc(-${value} / 2)`, }, '&::-moz-range-thumb': { height: value, }, '&::-ms-thumb': { height: value, }, }), }, { values: theme('height') as Record } ); /* * The default border properties were causing rendering issues, so we * split the width utility into it's own class to avoid that */ matchUtilities( { 'slider-thumb-border': (value: string) => ({ '&::-webkit-slider-thumb': { borderWidth: value, }, '&::-moz-range-thumb': { borderWidth: value, }, '&::-ms-thumb': { borderWidth: value, }, }), }, { values: theme('borderWidth') as Record } ); matchUtilities( { 'slider-thumb-border': (value: string) => ({ '&::-webkit-slider-thumb': { borderStyle: value, }, '&::-moz-range-thumb': { borderStyle: value, }, '&::-ms-thumb': { borderStyle: value, }, }), }, { values: { DEFAULT: 'solid', solid: 'solid', dashed: 'dashed', dotted: 'dotted', double: 'double', }, } ); matchUtilities( { 'slider-thumb-border': (value: string) => ({ '&::-webkit-slider-thumb': { borderColor: value, }, '&::-moz-range-thumb': { borderColor: value, }, '&::-ms-thumb': { borderColor: value, }, }), }, { values: { ...(theme('borderColor') as Record), DEFAULT: theme('borderColor.light') as string, }, } ); matchUtilities( { 'slider-thumb-border': (value: string) => ({ '&::-webkit-slider-thumb': { borderRadius: value, }, '&::-moz-range-thumb': { borderRadius: value, }, '&::-ms-thumb': { borderRadius: value, }, }), }, { values: { ...(theme('borderRadius') as Record), DEFAULT: '9999px', }, } ); matchUtilities( { 'slider-thumb-cursor': (value: string) => ({ '&::-webkit-slider-thumb': { cursor: value, }, '&::-moz-range-thumb': { cursor: value, }, '&::-ms-thumb': { cursor: value, }, }), }, { values: theme('cursor') as Record } ); /* Table style guide with custom classes */ addComponents({ '.table-container': { '@apply w-full min-w-[1200px] border border-b-0 border-light text-sm': {}, }, '.table-header': { '@apply h-6 bg-light text-xs': {}, }, '.table-header-cell': { '@apply h-6 min-h-0 content-center items-center border-b border-light px-2 text-subtle-1 whitespace-normal break-words': {}, }, '.table-cell': { '@apply min-h-12 content-center items-center border-b border-light p-2 whitespace-normal break-words': {}, }, '.table-cell-link': { '@apply flex h-full w-full items-center hover:underline': {}, }, '.table-cell-flex': { '@apply flex items-center gap-2 flex-wrap': {}, }, }); }), ] satisfies Config['plugins'];