Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                h1 CommitSweeper
p Paint-by-hover, click to lock the commit color.
small
  em Sorry, desktop only.
p.warning Beware the mines!

- var n = 0;
  div
    while n < 364
      label
        input(type="checkbox")
        span.box
      - n++;

              
            
!

CSS

              
                // Learn more about this:
// @link https://dev.to/5t3ph/commitsweeper-pure-css-game-4f8a
// Looking to upgrade your CSS skills?
// @link https://moderncss.dev

$colors: (
  less: #ebedf0,
  low: #c6e48b,
  mid: #7bc96f,
  high: #239a3b,
  most: #196127
);

@function getColor($key) {
  @return map-get($colors, $key);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  display: grid;
  grid-gap: 1rem;
  place-content: center;
  text-align: center;
  font-family: Karla, sans-serif;
}

h1 {
  $h1: 4.2rem;
  font-size: $h1;
  font-size: unquote("min(max(2.5rem, 5vw), #{$h1})");
  color: getColor(mid);
}

h1,
p {
  margin: 0;
}

p {
  font-size: 1.125rem;

  &.warning {
    color: getColor(most);
    font-style: italic;
    margin-bottom: 1rem;
  }
}

div {
  grid-gap: 2px;
  width: 100vw;
  display: grid;
  grid-template-columns: repeat(51, 1fr);
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
}

label input {
  opacity: 0;
}

$boxSize: calc((100vw - 130px) / 52);
$numColors: length($colors);
$colorWidth: 100 / $numColors;

label {
  position: relative;
  display: grid;
  grid-template-areas: "box";
  width: $boxSize;
  height: $boxSize;
  background-color: getColor(less);
  overflow: hidden;

  .box,
  input,
  .box::after {
    grid-area: box;
  }

  .box {
    animation: cycle #{$numColors * 400}ms ease 0s infinite normal;
    animation-play-state: paused;
    position: relative;
  }

  // cycle on hover
  &:hover .box {
    animation-play-state: running;
  }

  // pause animation when checked
  input:checked + .box {
    animation-play-state: paused;
  }

  // Random "mines" reset the animation on all inputs that follow
  @for $i from 1 through 25 {
    $r: random(365);
    &:nth-of-type(#{$r}) input:checked + .box::after {
      content: "💣";
      font-size: $boxSize;
    }

    &:nth-of-type(#{$r}):focus-within ~ label .box {
      animation: unset;
    }
  }
}

@keyframes cycle {
  @each $name, $color in $colors {
    $i: index(($colors), ($name $color)) - 1;
    $frame: $i * $colorWidth;

    #{$frame}% {
      background-color: $color;
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console