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

              
                <!-- forked from https://codepen.io/jasesmith/pen/GqaVrx -->

<body ng-app="app" ng-controller="ctrl">
  <main class="column" style="background-image: {{b}}">

    <article class="column">
      <div class="flip-container" ng-class="{'flip-me': answered}">
        <div class="flipper">
          <div class="front">
            <div class="chip bg-light">
              <span class="fa fa-hand-spock-o fa-fw ghost"></span>
            </div>
          </div>
          <div class="back">
            <div class="chip bg-light">
              <span class="fa fa-hand-{{splashIcon}}-o fa-fw"></span>
            </div>
          </div>
        </div>
      </div>

      <div class="answers row around" ng-class="{'ghost': spocked}">
        <div class="column align-center">
          <div class="chip" ng-class="uiSetMoveClasses('rock', 1)" ng-click="uiPlay('rock')">
            <span class="fa fa-hand-rock-o fa-fw fa-2x"></span>
          </div>
        </div>
        <div class="column align-center">
          <div class="chip" ng-class="uiSetMoveClasses('paper', 2)" ng-click="uiPlay('paper')">
            <span class="fa fa-hand-paper-o fa-fw fa-2x"></span>
          </div>
        </div>
        <div class="column align-center">
          <div class="chip" ng-class="uiSetMoveClasses('scissors', 3)" ng-click="uiPlay('scissors')">
            <span class="fa fa-hand-scissors-o fa-fw fa-2x"></span>
          </div>
        </div>
      </div>

      <footer class="row around">
        <div>
          <span class="ghost">Me</span>
          <h1>{{score.me}}</h1>
        </div>
        <div>
          <span class="ghost">Spock</span>
          <h1>{{score.spock}}</h1>
        </div>
      </footer>

    </article>

    <div class="message-wrap content {{answered}}" ng-class="{'show': answered}">
      <div class="message row align-center" ng-click="uiPlayAgain()" ng-class="{'bg-warning': spocked, 'bg-info': winner==='tie','bg-success': winner=='me','bg-alert': winner=='spock'}">
        <div class="text">{{message}}</div>
        <div class="chip beacon-1">
          <span class="fa fa-3x fa-refresh"></span>
        </div>
      </div>
    </div>

  </main>
</body>
              
            
!

CSS

              
                @import 'https://fonts.googleapis.com/css?family=Roboto+Condensed';
$base-font: 'Roboto Condensed', Helvetica, Arial, sans-serif;
$framework-timing: .3s;
$dark: #23292C;
$darker: mix($dark, #000, 50%);
$light: #E2E4E6;
$lighter: mix($light, #fff, 40%);
$base: #00BCD4;
$alert: #FF3B80;
$warning: #ff5722;
$caution: #ffca28;
$success: #cddc39;
$info: $base;
// keyframes
@keyframes beacon {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.35)
  }
  100% {
    box-shadow: 0 0 0 2rem transparent
  }
}

//utils
.row {
  display: flex;
  flex-flow: row;
}

.column {
  display: flex;
  flex-flow: column;
}

.align-center {
  align-items: center;
}

.between {
  justify-content: space-between;
}
.around {
  justify-content: space-around;
}


.chip {
  width: 1em;
  height: 1em;
  border-radius: 100%;
  display: flex;
  flex-flow: row;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0.2em 0.35em -0.15em rgba($dark, 0.5);
  .fa {
    font-size: 65%;
  }
}
// animations
.beacon-1 {
  animation: beacon 1s infinite linear
}

.beacon-2 {
  animation: beacon 1s infinite linear;
  animation-delay: .15s;
}

.beacon-3 {
  animation: beacon 1s infinite linear;
  animation-delay: .3s;
}

.bg-info {
  background: $info;
  color: $lighter;
}
.bg-success {
  background: $success;
  color: $lighter;
}
.bg-alert {
  background: $alert;
  color: $lighter;
}
.bg-warning {
  background: $warning;
  color: $lighter;
}

.bg-dark {
  background: $dark;
  color: $lighter;
}

.bg-light {
  background: $lighter;
  color: $dark;
}
.fg-light {
  color: $lighter;
}
.fg-dark {
  color: $dark;
}
.ghost {
  opacity: .35;
}

// flipper
.flip-container {
  perspective: 800;
  &.flip-me .flipper {
    transform: rotateY(180deg);
  }
}

.flip-container,
.front,
.back,
.answers,
footer {
  width: 100vw;
  text-align: center;
  margin: 0 auto;
}

.answers {
  font-size: 8vmax;
}
footer {
  font-size: 3vmax;
  h1 {
    margin: 0;
  }
}

.flipper {
  font-size: 35vmin;
  height: 1em;
  transition: 0.8s cubic-bezier(1, -0.5, 0.2, 1.5);
  transform-style: preserve-3d;
  position: relative;
  .front,
  .back {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    position: absolute;
    top: 0;
    height: 1em;
    left: 50%;
    transform: translate(-50%, 0%);
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 100%;
  }
  .front {
    z-index: 2;
    color: mix($dark, $light);
    transform: translate(-50%, 0%) rotateY(0deg)
  }
  .back {
    transform: translate(-50%, 0%) rotateY(180deg);
    width: 1em
  }
}

// layout
article {
  flex: 1;
  background-size: cover;
  background-position: center;
  justify-content: space-around;
  align-items: center;
}

main {
  flex: 1;
  transform-origin: center;
  justify-content: center;
  color: $lighter;
  background-color: $dark;
  background-image: linear-gradient(170deg, $success, $warning);
  background-size: cover;
  background-position: center;
  text-align: center;
  transform-origin: center;
  justify-content: center;
  .answered:not(.winner) {
    opacity: .5;
    background: none;
  }
  .flipper {
    // font-size: 29vmax;
    margin: 0 auto;
  }
  .message-wrap {
    bottom: 35%;
    left: 50%;
    position: absolute;
    transform: translateX(-50%) scale(0);
    transition: $framework-timing cubic-bezier(0.5, 0.1, 0.3, 1.4);
    transition-delay: 0s;
    z-index: 1;
    &.show {
      bottom: 50%;
      transform: translateX(-50%) scale(1);
      transition-delay: $framework-timing*3;
    }
    .message {
      padding: .5em 1em;
      justify-content: center;
      border-radius: 3em;
      box-shadow: 0 0 2em -.3em rgba($darker, .65);
      line-height: 1.5;
      opacity: .9;
    }
    .text {
      margin-right: 1em;
    }
    div {
      font-size: 1.5em;
    }
  }
}

// boring
html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-flow: column;
  font-family: $base-font;
}
              
            
!

JS

              
                (function($angular, _) {
  'use strict';
  var _prefix = 'hullabaloo';
  var _p1 = 'me';
  var _p2 = 'spock';
  var randum = function(max) {
    return Math.round(Math.random() * max);
  }

  var hexify = function(x) {
    return ('0' + parseInt(x).toString(16)).slice(-2);
  }

  var randex = function() {
    return '#' + hexify(randum(255)) + hexify(randum(255)) + hexify(randum(255));
  };

  var blender = function() {
    if (!!Math.round(Math.random())) {
      return 'radial-gradient(circle at ' + randum(100) + '% ' + randum(100) + '%, ' + randex() + ', ' + randex() + ')';
    } else {
      return 'linear-gradient(' + randum(360) + 'deg, ' + randex() + ', ' + randex() + ')';
    }
  };

  $angular.module('app', [])
    .run(['StorageService', function(storage) {
      var data = storage.get(_prefix);
      if (!data) {
        storage.save(_prefix, {
          me: 0,
          spock: 0
        });
      }
    }])
    .controller('ctrl', ['$scope', '$timeout', 'StorageService', function($scope, $timeout, storage) {
      var splashIconArray = [];
      splashIconArray = _.flatten(_.times(29, function(i) {
        var _arr = ['rock', 'paper', 'scissors'];
        if (i % 9 === 0) {
          _arr.push('spock');
        }
        return _arr;
      }));
  
      var init = function(){
        $scope.spocked = false;
        $scope.answered = false;
        $scope.score = storage.get(_prefix);
        $scope.b = blender();
      };

      var _recordScore = function(winner) {
        var _myScore = parseInt($scope.score.me),
          _spockScore = parseInt($scope.score.spock),
          _prefs;

        if (winner === _p1) {
          _myScore = parseInt($scope.score.me) + 1;
        }
        if (winner === _p2) {
          _spockScore = parseInt($scope.score.spock) + 1;
        }
        var _score = {
          me: _myScore,
          spock: _spockScore
        };
        storage.save(_prefix, _score);
        return _score;
      };

      $scope.uiPlay = function(hand) {
        if ($scope.answered) {
          return;
        }

        var _winner = false;
        var message = '';
        $scope.splashIcon = splashIconArray[_.random(0, splashIconArray.length - 1)];

        $scope.answered = hand;
        if ($scope.splashIcon === 'spock') {
          $scope.spocked = true;
          _winner = _p2;
          message = 'You\'ve been Spock\'d';
        } else {
          if (hand === $scope.splashIcon) {
            _winner = 'tie';
            message = 'It\'s a tie!';
          } else {
            if (hand === 'rock' && $scope.splashIcon === 'scissors' || hand === 'scissors' && $scope.splashIcon === 'paper' || hand === 'paper' && $scope.splashIcon === 'rock') {
              _winner = _p1;
              message = 'You won!';
            } else {
              _winner = _p2;
              message = 'You lost.';
            }
          }
        }
        if (_winner !== 'tie') {
          $scope.score = _recordScore(_winner);
        }
        $scope.winner = _winner;
        $scope.message = message;
      };

      $scope.uiSetMoveClasses = function(hand, n) {
        var classes = [];
        if ($scope.answered === hand) {
          classes.push('bg-dark');
          classes.push('answered');
          if ($scope.winner === _p1) {
            classes.push('winner');
          }
        } else if (!$scope.answered) {
          classes.push('bg-light');
          classes.push('beacon-' + n);
        }
        return classes.join(' ');
      };
  
      $scope.uiPlayAgain = function() {
        init();
      };
  
      init();
    }])
    .factory('StorageService', [function() {
      // get item out of local storage and if it's a string, turn it into a json object
      var get = function(key) {
        var item = window.localStorage.getItem(key);
        if (item && _.isString(item) && _.isEmpty(item) === false) {
          return $angular.fromJson(item);
        } else {
          return item;
        }
      };

      // save object as a json string
      var save = function(key, data) {
        window.localStorage.setItem(key, $angular.toJson(data));
      };
      // remove a specific item
      var remove = function(key) {
        window.localStorage.removeItem(key);
      };
      // blow them all away
      var clearAll = function() {
        window.localStorage.clear();
      };

      // Return array of keys for local storage
      // Example use: var keys = StorageService.keys()
      var keys = function(filter) {
        var prefix = _prefix + (filter || '');
        var prefixLength = prefix.length;
        var keys = [];
        for (var key in window.localStorage) {
          // Only return keys that are for this app
          if (key.substr(0, prefixLength) === prefix) {
            try {
              keys.push(key.substr(prefixLength + 1));
            } catch (e) {
              return [];
            }
          }
        }
        return keys;
      };

      return {
        get: get,
        save: save,
        remove: remove,
        clearAll: clearAll,
        keys: keys
      };
    }]);

})(window.angular, window._);
              
            
!
999px

Console