Component State Switching

Hello, World

What is this?

For some initial context, read the discussion on this Github issue.

The component above has the following markup:

<div class="component-test" data-sauce-stateful-component>
  <state media="(min-width: 500px)" value="red"></state>
  <state media="(min-width: 700px)" value="blue"></state>
  <state media="(min-width: 900px)" value="green"></state>
  <state media="(min-width: 1100px)" value="green rounded"></state>
  Hello, World
</div>

When resizing the browser window, the box should...

  1. have a grey border when min-width < 500px
  2. have a red border when min-width >= 500px
  3. have a blue border when min-width >= 700px
  4. have a green border when min-width >= 900px
  5. have a green, rounded border when min-width >= 1100px

To find out more about how this works, have a look at the repository's README file.

Here's the entire minified script that powers this. Right now it's 2.2kB, before compression: