postcss-match

1.0.0 • Public • Published

PostCSS Match Build Status

PostCSS plugin for Rust-style pattern matching.

.blah {
  @match baz {
    foo => { color: red; },
    bar | baz => { background: green; }
  }
}
.blah {
  background: green
}

In conjunction with postcss-simple-vars:

$animal: bear;
 
.zoo {
  @match $animal {
    snake => { color: green; },
    buffalo | bear => { background: brown; },
    lion => { font-weight: bold; },
    _ => {
      font-style: italic;
      color: gray;
    }
  }
}
.zoo {
  background: brown
}

Usage

postcss([ require('postcss-match') ])

See PostCSS docs for examples for your environment.

Differences from Rust and other known limitations

  • Braces around arm expressions are non-optional
  • Nested @match at-rules are currently unsupported
  • Rust-style range patterns are currently unsupported
  • Pattern exhaustiveness is not checked
  • Pattern unreachability is not checked

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    0
  • 0.2.0
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i postcss-match

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • rtsao