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

              
                <div class="app">
  <div class="ring">

    <div class="topic" data-topic="good">
      <button class="js btn">Good</button>
      <div class="line-wrap">
        <div class="line"></div>
      </div>

      <label class="display btn">Good</label>
    </div>
    <div class="topic" data-topic="fast">
      <button class="js btn">Fast</button>
      <div class="line-wrap">
        <div class="line"></div>
      </div>
      <label class="display btn">Fast</label>

    </div>
    <div class="topic" data-topic="cheap">

      <button class="js btn">Cheap</button>
      <div class="line-wrap">
        <div class="line"></div>
      </div>
      <label class="display btn">Cheap</label>

    </div>
    <button class="js topic-result topic-result--1"></button>
    <button class="js topic-result topic-result--2"></button>

    <div class="ring-background-2">
      <div class="bg-line bg-line--3"></div>
      <div class="bg-line bg-line--1"></div>
      <div class="bg-line bg-line--2"></div>

      <svg viewBox="0 15 100 100">

    <polygon  points="50 15, 100 100, 0 100"/>

</svg>
    </div>
  </div>
</div>

<a target="_blank" class="reference" href="https://twitter.com/FrazDav/status/1164207783081848832?s=09">inspiration</a>
              
            
!

CSS

              
                $size: 70px;
$box-shadow: 0px 10px 13px -6px rgba(0, 0, 0, 0.2),
  0px 20px 31px 3px rgba(0, 0, 0, 0.14), 0px 8px 38px 7px rgba(0, 0, 0, 0.12);
$box-shadow-light: 0px 1px 3px 0px rgba(white, 0.2),
  0px 1px 1px 0px rgba(white, 0.14), 0px 2px 1px -1px rgba(white, 0.12);
$duration: 500ms;
$transition-timing-function: cubic-bezier(0.07, 1.12, 0.74, 1.06);
$color-theme: #181e45;

* {
  box-sizing: border-box;
}
body {
  font-family: "Source Sans Pro", Verdana, sans-serif;
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: linear-gradient(#5c627d 50%, #2e3255);
}
button {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  outline: none;
}
.app {
  position: relative;
  margin: 0 auto;
  max-width: 800px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  flex-wrap: wrap;
  font-size: 18px;
}

.btn {
  font-size: inherit;
  background: none;
  cursor: pointer;
  border-radius: $size;
  width: $size;
  height: $size;
  text-transform: uppercase;
  background: transparent;
  transform: translateZ(0);
  outline: none;
  border: none;
  font-weight: bold;
  color: transparent;
  font-size: inherit;
  box-shadow: $box-shadow;

  &.display {
    font-weight: bold;
    display: block;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    box-shadow: none;
    text-align: center;
    line-height: $size;
    font-size: inherit;
    color: white;
  }
}

.btn-clicked {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: $size;
  height: $size;
  background: white;
  border-radius: 50%;
  opacity: 0.5;
  animation: btn-clicked $duration forwards;
}
@keyframes btn-clicked {
  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

.text {
  font-weight: bold;
  position: absolute;
  top: 0;
  left: 0;
  color: inherit;
  font-size: inherit;
  text-transform: uppercase;
  outline: 1px solid pink;
  width: $size;
  height: $size;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
}

.ring {
  width: $size;
  height: $size;
  position: relative;
  color: white;
}
.ring-background-2 {
  position: absolute;
  width: $size*6;
  height: $size*6;
  top: -$size/3;
  //top: 0;
  left: 0;
  transform: translate(calc(-50% + #{$size/2}), calc(-50% + #{$size/2}))
    scale(0.7);
  z-index: -1;

  .bg-line {
    position: absolute;
    top: 0;
    left: calc(50% - #{$size});
    background: linear-gradient(315deg, $color-theme 50%, #343a5d);
    background: $color-theme;
    width: $size*2;
    height: $size*6.2;
    border-radius: $size*2;

    &--1 {
      transform-origin: 50% #{$size};
      transform: rotate(30deg);
      &::before {
        content: "";
        display: block;
        width: 2px;
        height: 50%;
        top: 25%;
        left: -1px;
        position: absolute;
        box-shadow: 0 0 10px #333;
        z-index: -1;
      }
    }
    &--2 {
      transform-origin: 50% #{$size};
      transform: rotate(-30deg);
    }
    &--3 {
      box-shadow: 0 0 30px #333;
      transform-origin: 50% #{$size};
      height: $size*2;
      width: $size*6;
      top: auto;
      bottom: 0;
      left: 0;
      transform: translateY(#{-$size / 2.8});
    }
  }

  svg {
    polygon {
      background: linear-gradient(315deg, $color-theme 50%, #343a5d);
      fill: $color-theme;
    }

    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
  }
}

.reference {
  position: fixed;
  bottom: 4px;
  right: 4px;
  font-size: 14px;
  color: #ddd;
}

.line-wrap {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: $size;
  height: $size;
}
.line {
  pointer-events: none;
  border-radius: $size;
  position: absolute;
  top: 0;
  left: 0;
  width: $size;
  height: 100%;
  opacity: 1;
  transform-origin: 0 0;
  transition: $duration;
}

.topic-result {
  cursor: pointer;
  border: 0;
  transition: $duration;
  transform: scale(0) translateZ(0);
  position: absolute;
  top: 0;
  left: 0;
  width: $size;
  height: $size;
  border-radius: 50%;
  font-size: 40px;
  box-shadow: $box-shadow;
  &.is-active {
    transform: scale(1.1) translateZ(0);

    transition-timing-function: $transition-timing-function;
  }
}
.topic {
  position: absolute;
  top: 0;
  left: 0;
  $len: $size*1.5;

  &.is-active {
    .line {
      width: 250%;
      transition-timing-function: $transition-timing-function;
    }
  }

  &[data-topic="good"] {
    $deg: -90deg;
    transform: translateY(sin($deg)*$len) translateX(cos($deg)*$len);

    .line-wrap {
      transform: rotate(90deg);
    }
    .line {
      background: dodgerblue;
    }
  }
  &[data-topic="fast"] {
    $deg: -210deg;
    transform: translateY(sin($deg)*$len) translateX(cos($deg)*$len);
    .line-wrap {
      transform: rotate(90deg - 120deg);
    }
    .line {
      background: crimson;
    }
  }
  &[data-topic="cheap"] {
    $deg: 30deg;
    transform: translateY(sin($deg)*$len) translateX(cos($deg)*$len);

    .line-wrap {
      transform: rotate(90deg + 120deg);
    }
    .line {
      background: mediumseagreen;
    }
  }
}

              
            
!

JS

              
                const log = console.log;

// Quick prototyping, don't take the namings and algorithm to seriously. 

let topics = qsa(".topic");
let topicResult = qs(".js.topic-result--1");
let topicResult2 = qs(".js.topic-result--2");

// states
let activeResultToggle = false;
let actives = [];
// ----------------------

let onResultClick = () => {
  event.stopPropagation();
  event.preventDefault();
  actives = [];
  mapStateToDOM();
};

//topicResult.addEventListener("touchstart", onResultClick);
//topicResult2.addEventListener("touchstart", onResultClick);
topicResult.addEventListener("click", onResultClick);
topicResult2.addEventListener("click", onResultClick);

function onClick(event) {
  event.stopPropagation();
  event.preventDefault();
  let topic = this.closest(".topic");
  let anim = document.createElement("div");
  anim.className = "btn-clicked";
  topic.appendChild(anim);

  setTimeout(() => {
    try {
      // DOM cleanup
      anim && topic.removeChild(anim);
    } catch (ex) {}
  }, 2000);

  let type = topic.getAttribute("data-topic");

  if (!actives.includes(type)) {
    actives.push(type);
    if (actives.length > 2) actives.shift();
  } else {
    actives = actives.filter(t => t !== type);
  }

  mapStateToDOM();
}

let mapStateToDOM = () => {
  if (actives.length === 2) {
    activeResultToggle = !activeResultToggle;

    if (actives.includes("good") && actives.includes("cheap")) {
      if (activeResultToggle) {
        topicResult.textContent = "🐌";
        topicResult2.textContent = "";
      } else {
        topicResult.textContent = "";
        topicResult2.textContent = "🐌";
      }

      topicResult.style.backgroundColor = "cyan";
      topicResult2.style.backgroundColor = "cyan";
    } else if (actives.includes("good") && actives.includes("fast")) {
      if (activeResultToggle) {
        topicResult.textContent = "💰";
        topicResult2.textContent = "";
      } else {
        topicResult.textContent = "";
        topicResult2.textContent = "💰";
      }

      topicResult.style.backgroundColor = "hotpink";
      topicResult2.style.backgroundColor = "hotpink";
    } else {
      if (activeResultToggle) {
        topicResult.textContent = "💩";
        topicResult2.textContent = "";
      } else {
        topicResult.textContent = "";
        topicResult2.textContent = "💩";
      }

      topicResult.style.backgroundColor = "#fff000";
      topicResult2.style.backgroundColor = "#fff000";
    }
    if (activeResultToggle) {
      topicResult.classList.add("is-active");
      topicResult2.classList.remove("is-active");
      topicResult.style.zIndex = 1;
      topicResult2.style.zIndex = 0;
    } else {
      topicResult.classList.remove("is-active");
      topicResult2.classList.add("is-active");
      topicResult.style.zIndex = 0;
      topicResult2.style.zIndex = 1;
    }
  } else {
    topicResult.classList.remove("is-active");
    topicResult2.classList.remove("is-active");
  }

  topics.forEach(t => t.classList.remove("is-active"));
  actives.forEach(active => {
    topics.forEach(topic => {
      // O(n*n) but we have few items
      let topicType = topic.getAttribute("data-topic");
      if (topicType === active) {
        topic.classList.add("is-active");
      }
    });
  });
};

let buttons = qsa(".js.btn");
buttons.forEach(b => {
  //  b.addEventListener("touchstart", onClick);
  b.addEventListener("click", onClick);
});

function qs(expr, context) {
  return (context || document).querySelector(expr);
}
function qsa(expr, context) {
  return [].slice.call((context || document).querySelectorAll(expr), 0);
}

              
            
!
999px

Console