Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

rtsao/postcss-match

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

PostCSS plugin for Rust-style pattern matching

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.