Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add https://github.com/jhthorsen/postcss-pseudo-shorthand #344

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jhthorsen
Copy link

@jhthorsen jhthorsen commented Mar 3, 2023

PostCSS pseudo shorthand

PostCSS plugin that expands pseudo aliases to browser specific aliases, to avoid writing the same CSS rules multiple times.

Example input

input[range]::range-thumb {
  background: green;
}

Example output

input[range]::-moz-range-thumb {
  background: green;
}
input[range]::-ms-thumb {
  background: green;
}
input[range]::-webkit-slider-thumb {
  background: green;
}

Usage

The example usage below has the default rules documented. More rules can be added without any majort version bump.

import postcssPseudoShorthand from 'postcss-pseudo-shorthand';

const config = {
  plugins: [
    postcssPseudoShortHand({
      rules: {
        '::color-swatch': ['::-moz-color-swatch', '::-webkit-color-swatch'],
        '::color-swatch-wrapper': ['::-moz-focus-inner', '::-webkit-color-swatch-wrapper'],
        '::range-thumb': ['::-moz-range-thumb', '::-ms-thumb', '::-webkit-slider-thumb'],
        '::range-track': ['::-moz-range-track', '::-ms-track', '::-webkit-slider-runnable-track'],
      },
    }),
  ],
};

export default config;

See PostCSS docs for examples for your environment.


MIT © Jan Henning Thorsen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant