ecklf / tailwindcss-figma-plugin

Figma Plugin for Tailwind CSS
https://www.figma.com/community/plugin/738806869514947558/Tailwind-CSS
MIT License
269 stars 16 forks source link

Please document what a valid tailwind config should look like for your plugin #109

Closed christophermlne closed 4 years ago

christophermlne commented 4 years ago

For example, this does not work, but we don't know which part of the file your plugin considers to be invalid:

/*global module*/
const plugin = require('tailwindcss/plugin');/* eslint-disable */
module.exports = {
  prefix: '',
  important: false,
  separator: ':',
  theme: {
    screens: {
      xs: '480px', // corresponds to 'plm' in old system
      sm: '640px',
      md: '768px',
      lg: '1024px',
      xl: '1280px', // corresponds to 'max' in old system
    },
    colors: {
      // transparent: 'transparent',
      //
      black: '#000000',
      white: '#fff',
      //
      grey: {
        lightest: '#F7F7F7',
        lighter: '#E5E5E5',
        light: '#CCCCCC',
        default: '#999999',
        dark: '#333333',
        darker: '#666666', // corresponds to 'darkish' in old system
      },
      blue: {
      //   lighter: '#c6f2ff',
      //   light: '#7fdbf7',
        default: '#00BBE3',
      //   dark: '#068fb9',
      //   darker: '#0d6782',
      },
    },    // This scale was chosen after analyzing existing margin
    // and padding in app and will cover 99% of use cases
    spacing: {
      px: '1px',
      '0': '0',
      '1': '0.25rem',
      '2': 'var(--space-1)',
      '3': '0.75rem',
      '4': 'var(--space-2)',
      '5': '1.25rem',
      '6': '1.5rem',
      '8': 'var(--space-3)',
      '10': '2.5rem',
      '12': '3rem',
      '16': 'var(--space-4)',
    },    backgroundColor: theme => theme('colors'),
    backgroundPosition: {
      // bottom: 'bottom',
      // center: 'center',
      // left: 'left',
      // 'left-bottom': 'left bottom',
      // 'left-top': 'left top',
      // right: 'right',
      // 'right-bottom': 'right bottom',
      // 'right-top': 'right top',
      // top: 'top',
    },
    backgroundSize: {
      // auto: 'auto',
      // cover: 'cover',
      // contain: 'contain',
    },
    borderColor: theme => ({
      ...theme('colors'),
      default: theme('colors.grey.default', 'currentColor'),
    }),    // border-radius values are all over the place in the css.
    // below is just the Tailwind default border-radius scale
    // which would probably work better for us going forward
    borderRadius: {
      none: '0',
      sm: '0.125rem',
      default: '0.25rem',
      lg: '0.5rem',
      full: '9999px',
    },
    borderWidth: {
      default: '1px',
      '0': '0',
      '2': '2px',
      // '4': '4px',
      // '8': '8px',
    },
    boxShadow: {
      // default: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
      // md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
      // lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
      // xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
      // '2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)',
      // inner: 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)',
      // outline: '0 0 0 3px rgba(66, 153, 225, 0.5)',
      // none: 'none',
    },
    container: {},
    cursor: {
      auto: 'auto',
      default: 'default',
      pointer: 'pointer',
      grab: 'grab',
      grabbing: 'grabbing',
      // wait: 'wait',
      // text: 'text',
      // move: 'move',
      'not-allowed': 'not-allowed',
      'ew-resize': 'ew-resize',
    },
    fill: {
      current: 'currentColor',
    },
    flex: {
      '1': '1 1 0%',
      auto: '1 1 auto',
      initial: '0 1 auto',
      none: 'none',
    },
    flexGrow: {
      '0': '0',
      default: '1',
    },
    flexShrink: {
      '0': '0',
      default: '1',
    },
    fontFamily: {
      // sans: [
      //   'Source Sans Pro',
      //   'sans-serif',
      // ],
    },    // This scale was chosen after analyzing existing
    // font sizes used in semantic and utility classes
    // and will cover 99% of use cases
    fontSize: {
      xs: '0.75rem',
      sm: '0.875rem',
      base: '1rem',
      lg: '1.125rem',
      xl: '1.25rem',
      '2xl': '1.5rem',
      '3xl': '1.875rem',
      '4xl': '2rem',
      '5xl': '3rem',
      '6xl': '4rem',
    },
    fontWeight: {
      // hairline: '100',
      // thin: '200',
      light: '300',
      normal: '400',
      // medium: '500',
      semibold: '600',
      bold: '700',
      // extrabold: '800',
      // black: '900',
    },
    height: theme => ({
      auto: 'auto',
      ...theme('spacing'),
      full: '100%',
      screen: '100vh',
    }),
    inset: {
      // '0': '0',
      // auto: 'auto',
    },
    letterSpacing: {
      // tighter: '-0.05em',
      // tight: '-0.025em',
      // normal: '0',
      // wide: '0.025em',
      // wider: '0.05em',
      // widest: '0.1em',
    },
    lineHeight: {
      none: '1',
      tight: '1.2',
      snug: '1.3',
      normal: '1.4',
      relaxed: '1.6',
      loose: '2',
    },
    listStyleType: {
      none: 'none',
      disc: 'disc',
      decimal: 'decimal',
    },
    margin: (theme, { negative }) => ({
      auto: 'auto',
      ...theme('spacing'),
      ...negative(theme('spacing')),
    }),
    maxHeight: {
      full: '100%',
      screen: '100vh',
    },
    maxWidth: {
      xs: '18rem',
      sm: '24rem',
      // md: '28rem',
      lg: '32rem',
      xl: '36rem',
      '2xl': '42rem',
      '3xl': '48rem',
      // '4xl': '56rem',
      '5xl': '64rem',
      // '6xl': '72rem',
      '7xl': '80rem',
      // full: '100%',
    },
    minHeight: {
      '0': '0',
      full: '100%',
      screen: '100vh',
    },
    minWidth: {
      '0': '0',
      full: '100%',
    },
    objectPosition: {
      bottom: 'bottom',
      center: 'center',
      left: 'left',
      'left-bottom': 'left bottom',
      'left-top': 'left top',
      right: 'right',
      'right-bottom': 'right bottom',
      'right-top': 'right top',
      top: 'top',
    },    // This scale was chosen after analyzing existing opacity
    // values used in app and will cover 99% of use cases
    opacity: {
      '0': '0',
      '15': '0.15',
      '25': '0.25',
      '50': '0.5',
      '60': '0.6',
      '75': '0.75',
      '80': '0.80',
      '100': '1',
    },
    order: {
      // first: '-9999',
      // last: '9999',
      // none: '0',
      // '1': '1',
      // '2': '2',
      // '3': '3',
      // '4': '4',
      // '5': '5',
      // '6': '6',
      // '7': '7',
      // '8': '8',
      // '9': '9',
      // '10': '10',
      // '11': '11',
      // '12': '12',
    },
    padding: theme => theme('spacing'),
    // placeholderColor: theme => theme('colors'),
    stroke: {
      // current: 'currentColor',
    },
    // textColor: theme => theme('colors'),
    width: theme => ({
      auto: 'auto',
      ...theme('spacing'),
      '1/2': '50%',
      '1/3': '33.333333%',
      '2/3': '66.666667%',
      '1/4': '25%',
      '2/4': '50%',
      '3/4': '75%',
      '1/5': '20%',
      '2/5': '40%',
      '3/5': '60%',
      '4/5': '80%',
      '1/6': '16.666667%',
      '2/6': '33.333333%',
      '3/6': '50%',
      '4/6': '66.666667%',
      '5/6': '83.333333%',
      '1/12': '8.333333%',
      '2/12': '16.666667%',
      '3/12': '25%',
      '4/12': '33.333333%',
      '5/12': '41.666667%',
      '6/12': '50%',
      '7/12': '58.333333%',
      '8/12': '66.666667%',
      '9/12': '75%',
      '10/12': '83.333333%',
      '11/12': '91.666667%',
      full: '100%',
      screen: '100vw',
    }),
    zIndex: {
      // auto: 'auto',
      // '0': '0',
      // '10': '10',
      // '20': '20',
      // '30': '30',
      // '40': '40',
      // '50': '50',
    },
  },
  variants: {
    accessibility: ['responsive', 'focus'],
    alignContent: ['responsive'],
    alignItems: ['responsive'],
    alignSelf: ['responsive'],
    appearance: ['responsive'],
    backgroundAttachment: ['responsive'],
    backgroundColor: ['responsive', 'hover', 'focus'],
    backgroundPosition: ['responsive'],
    backgroundRepeat: ['responsive'],
    backgroundSize: ['responsive'],
    borderCollapse: ['responsive'],
    borderColor: ['responsive', 'hover', 'focus'],
    borderRadius: ['responsive'],
    borderStyle: ['responsive'],
    borderWidth: ['responsive'],
    boxShadow: ['responsive', 'hover', 'focus'],
    cursor: ['responsive'],
    display: ['responsive'],
    fill: ['responsive'],
    flex: ['responsive'],
    flexDirection: ['responsive'],
    flexGrow: ['responsive'],
    flexShrink: ['responsive'],
    flexWrap: ['responsive'],
    float: ['responsive'],
    fontFamily: ['responsive'],
    fontSize: ['responsive'],
    fontSmoothing: ['responsive'],
    fontStyle: ['responsive'],
    fontWeight: ['responsive', 'hover', 'focus'],
    height: ['responsive'],
    inset: ['responsive'],
    justifyContent: ['responsive'],
    letterSpacing: ['responsive'],
    lineHeight: ['responsive'],
    listStylePosition: ['responsive'],
    listStyleType: ['responsive'],
    margin: ['responsive'],
    maxHeight: ['responsive'],
    maxWidth: ['responsive'],
    minHeight: ['responsive'],
    minWidth: ['responsive'],
    objectFit: ['responsive'],
    objectPosition: ['responsive'],
    opacity: ['responsive', 'hover', 'focus'],
    order: ['responsive'],
    outline: ['responsive', 'focus'],
    overflow: ['responsive'],
    padding: ['responsive'],
    placeholderColor: ['responsive', 'focus'],
    pointerEvents: ['responsive'],
    position: ['responsive'],
    resize: ['responsive'],
    stroke: ['responsive'],
    tableLayout: ['responsive'],
    textAlign: ['responsive'],
    textColor: ['responsive', 'hover', 'focus'],
    textDecoration: ['responsive', 'hover', 'focus'],
    textTransform: ['responsive'],
    userSelect: ['responsive'],
    verticalAlign: ['responsive'],
    visibility: ['responsive'],
    whitespace: ['responsive'],
    width: ['responsive'],
    wordBreak: ['responsive'],
    zIndex: ['responsive'],
  },
  corePlugins: {},
  plugins: [
    plugin(function({ addUtilities }) {
      const newUtilities = {
        '.flex-basis-0': {
           'flex-basis': '0%'
        },
        '.flex-basis-100': {
           'flex-basis': '100%'
        },
        '.align-sub': {
           'vertical-align': 'sub'
        },
      }      addUtilities(newUtilities)
    })
  ],
};
ecklf commented 4 years ago

Hey there 👋 ,

the current description for the plugin says the following:

If parsing fails, make sure you have a valid config file with color values using either HEX, RGB(A) or HSL(A). Also make sure to not include comments in your file (working on a fix).

Any suggestions on what I should add besides that?

christophermlne commented 4 years ago

no, i think we just missed that in the documentation