css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              //- Card Mixin
mixin card(type, number, date, id, active)
  if type == 'amex'
    - var image = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/Amex.png'
  else if type == 'discovery'
    - image = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/Discover.png'
  else if type == 'visa'
    - var image = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/Visa.png'
  else if type == 'mastercard'
    - var image = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/MC.png'
  
  .card(class=active ? 'active': '' 
        data-id='#{id}')
    img(src='#{image}')
    .number=number
    .expiration Valid Thru: #{date}

// Transaction Item
mixin transaction(title, category, ref, date, price, type)
  .transaction
    .icon-type: .icon(class='#{type}')
    .description
      .info
        h3=title
        span=category
        | 
        span=ref 
        |  - 
        span=date
      .price(class='#{type}')!=price

.wallet
  .overlay
    .card-form
      header
        h2 
          .type Visa
          span Card Details
        .a.close(href='#')
      .form
        .form-row
          .input-group
            label(for='') Name on card
            input(id='cardName'
                  type='text' 
                  value=''
                  placeholder='')
        .form-row
          .input-group
            label(for='') Card Number
            input(id='cardNumber'
                  type='text' 
                  value=''
                  maxlength='16'
                  placeholder='')
        .form-row
            .input-group
              label(for='') Expiry Date
              input(id='cardDate'
                    type='month'
                    value=''
                    placeholder='')
            .input-group
              label(for='') CVS
              input(id='cardCVS'
                    type='text'
                    value=''
                    maxlength='4'
                    placeholder='')
      footer.footer
        button.button Complete Payment

  .cards
    header
      h2 My Wallet
      a#add(href='#')
    .content
      +card('amex', '**** **** **** 1234', '2015-09', '1234', 't')
      +card('visa', '**** **** **** 7864', '2015-09', '7864', '')
      +card('mastercard', '**** **** **** 6542', '2015-09', '6542', '')
      +card('discovery', '**** **** **** 3125', '2015-09', '3125', '')

  .activity.active(data-id='1234')
    header
      h2 Balance
      span $735.
        i 00
    .content
      - for(var i = 0; i < 42; i++)
        if i % 2 === 0 
          +transaction('Apple iPhone 6, 16 GB', 'Electronics', '#4', '12 July, 2015', '$650.<i>00</i>', 'minus')
        else
          +transaction('Funds Added', 'Uncategorized', '#3', '11 July, 2015', '$900.<i>00</i>', 'plus')

  .activity(data-id='7864')
    header
      h2 Balance
      span $12033.
        i 00
    .content
      - for(var i = 0; i < 42; i++)
        if i % 2 === 0 
          +transaction('Apple iPhone 6, 16 GB', 'Electronics', '#4', '12 July, 2015', '$650.<i>00</i>', 'minus')
        else
          +transaction('Funds Added', 'Uncategorized', '#3', '11 July, 2015', '$900.<i>00</i>', 'plus')

  .activity(data-id='6542')
    header
      h2 Balance
      span $531.
        i 00
    .content
      - for(var i = 0; i < 42; i++)
        if i % 2 === 0 
          +transaction('Apple iPhone 6, 16 GB', 'Electronics', '#4', '12 July, 2015', '$650.<i>00</i>', 'minus')
        else
          +transaction('Funds Added', 'Uncategorized', '#3', '11 July, 2015', '$900.<i>00</i>', 'plus')

  .activity(data-id='3125')
    header
      h2 Balance
      span $4235.
        i 00
    .content
      - for(var i = 0; i < 2; i++)
        if i % 2 === 0 
          +transaction('Apple iPhone 6, 16 GB', 'Electronics', '#4', '12 July, 2015', '$650.<i>00</i>', 'minus')
        else
          +transaction('Funds Added', 'Uncategorized', '#3', '11 July, 2015', '$900.<i>00</i>', 'plus')
            
          
!
            
              $width: 880px;

$ultra: 800;
$bold: 700;
$semibold: 600;
$regular: 400;
$light: 300;
$thin: 100;

$white: #FFF;
$black: #000;
$dark-gray: rgba($black, .8);
$gray: rgba($black, .6);
$light-gray: rgba($black, .4);
$lighter-gray: rgba($black, .2);

$accent: lighten(#00A6EA, 15%);
$secondary: lighten(#E39C14, 15%);

body {
  background: #FECB6E;
  padding: 40px;
  color: $gray;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: $secondary;
}

.wallet {
  position: relative;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  background: $white;
  max-width: $width;
  border-radius: 6px;
  margin: 0 auto;
  
  // Causes bugs
  /* overflow: hidden; */
}

.content {
  height: 600px;
  overflow-y: auto;
  overflow-x: hidden;
}

.cards {
  background: #F2F2F2;
  flex-basis: 40%;
  width: 40%;
  height: 100%;
  box-sizing: border-box;
  padding: 60px;
  
  header {
    display: flex;
    justify-content: space-between;
    flex-wrap: nowrap;
    align-items: center;
    margin: 0 0 60px;
  }
  
  h2 {
    color: $gray;
    font-size: 24px;
  }
  
  .content {
    margin: 0 -60px;
    padding: 0 60px;
  }
}
  
#add {
  position: relative;
  width: 24px;
  height: 24px;
  padding: 10px;
  cursor: pointer;

  &:before,
  &:after {
    content: '';
    display: block;
    background: #C5CBE0;
    width: 24px;
    height: 4px;
    border-radius: 10px;
    margin: 10px 0 0;
  }

  &:after {
    margin: -4px 0 0;
    transform: rotate(90deg);
  }
}

.card {
  background: $white;
  width: 100%;
  border: 3px solid rgba($black, .1);
  border-radius: 4px;
  box-sizing: border-box;
  margin: 0 0 40px;
  padding: 20px;
  transition: .3s ease;
  filter: grayscale(1);
  cursor: pointer;
  
  &:last-child {
    margin: 0;
  }
  
  &.active {
    border-color: $accent;
    filter: grayscale(0);
  }
  
  img {
    display: block;
    height: 45px;
    margin: 0 0 20px;
  }
  
  .number {
    margin: 0 0 10px;
    color: $gray;
    font-size: 18px;
  }
  
  .expiration {
    color: $light-gray;
    font-size: 14px;
  }
}

// Activity
.activity {
  flex-basis: 60%;
  width: 60%;
  padding: 60px;
  box-sizing: border-box;

  header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #F2F2F2;
    margin: 0 0 19px;
    padding: 0 0 40px;

    h2 {
      color: $gray;
      font-size: 24px;
      line-height: 44px;
    }

    span {
      display: inline-block;
      color: $dark-gray;
      font-size: 36px;
      font-weight: $bold;

      i {
        display: inline-block;
        font-size: 20px;
        vertical-align: top;
      }
    }
  }
}

// Transaction
.transaction {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  padding: 20px 0;
  
  .icon {
    display: block;
    width: 20px;
    height: 20px;
    border: 2px solid $light-gray;
    border-radius: 10px;
    box-sizing: border-box;
    margin: 0 20px 0 0;
    color: $dark-gray;
    font-size: 18px;
    font-weight: $bold;
    line-height: 16px;
    text-align: center;
    
    &.plus {
      &:before {
        content: '+';
      }
    }
    
    &.minus {
      line-height: 12px;

      &:before {
        content: '-';
      }
    }
  }
  
  .description {
    display: flex;
    justify-content: space-between;
    width: 100%;
    color: $light-gray;
  }
  
  h3 {
    display: block;
    width: 100%;
    margin: 0 0 10px;
    color: $dark-gray;
    font-size: 18px;
    font-weight: $semibold;
  }
  
  .price {
    font-size: 18px;
    font-weight: $semibold;
    
    &.plus {
      color: $secondary;
    }
    
    &.minus {
      color: $accent;
    }
    
    i {
      display: inline-block;
      font-size: 10px;
      vertical-align: top;
    }
  }
  
  &-empty {
    display: block;
    width: 100%;
    font-size: 14px;
    text-align: center;
  }
}

// Overlay
.overlay {
  z-index: 1;
  position: absolute;
  top: 0;
  left: 0;
  background: rgba($black, .8);
  width: 100%;
  height: 100%;
}

// Close Button
.close {
  @extend #add;
  position: absolute;
  top: 50%;
  right: 20px;
  border-radius: 100%;
  transform-origin: top;
  transform: rotate(45deg) translateY(-50%);
  transition: 0.3s ease;
  
  &:before,
  &:after {
    background: $white;
  }
  
  &:hover {
    background: $white;
    transform: rotate(225deg) translateY(-50%);
    
    &:before,
    &:after {
      background: $accent;
    }
  }
}

.card-form {
  z-index: 2;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: $white;
  width: 80%;
  border-radius: 4px;
  margin: auto;
  overflow: hidden;
  
  header {
    position: relative;
    background: $accent;
    
    h2 {
      padding: 20px;
      color: $white;
      font-size: 24px;
      font-weight: $bold;
      text-transform: uppercase;
    }
    
    input {
      outline: none;
      display: block;
      background: 0;
      border: 0;
      box-shadow: 0 2px 0 rgba($white, .4);
      margin: -5px 0 -4px;
      padding: 0;
      line-height: 1;
      color: $white;
      font-size: 24px;
      font-weight: $semibold;
      font-family: 'Open Sans';
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }
    
    span {
      display: block;
      margin: 10px 0 0;
      font-size: 14px;
    }
  }
  
  .footer {
    .button {
      outline: none;
      display: block;
      background: $accent;
      width: 100%;
      border: 0;
      padding: 20px 30px;
      color: $white;
      font-size: 14px;
      font-weight: $bold;
      text-transform: uppercase;
      cursor: pointer;
    }
  }
}


.form {
  padding: 20px;
  
  &-row {
    display: flex;
    flex-direction: row;
    margin: 0 0 30px;

    &:last-child {
      margin: 0;

      .input-group {
        width: 75%;
        margin: 0 15px 0 0;

        &:last-child {
          width: 25%;
          margin: 0 0 15px;
        }
      }
    }
  }

  .input-group {
    width: 100%;
  }

  label {
    display: block;
    width: 100%;
    margin: 0 0 10px;
    color: $accent;
    font-size: 12px;
    font-weight: $bold;
    text-transform: uppercase;
  }

  input {
    outline: none;
    display: block;
    background: rgba($black, .1);
    width: 100%;
    border: 0;
    border-radius: 4px;
    box-sizing: border-box;
    margin: 0;
    padding: 15px;
    color: $light-gray;
    font-size: 12px;
    font-weight: $bold;
  }
}
            
          
!
            
              String.prototype.replaceAt = function(index, character) {
  return this.substr(0, index) + character + this.substr(index + character.length);
}

String.prototype.insert = function(index, string) {
  if (index > 0)
    return this.substring(0, index) + string + this.substring(index, this.length);
  else
    return string + this;
};

var typeValue,
  typeText,
  cardType,
  cardName,
  cardNumber,
  cardDate,
  cardId;

$('.overlay').hide();

$('#add').on('click', function(e) {
  e.preventDefault();
  $('.overlay').fadeIn(300);
});

$('.activity').not('.activity.active').hide();

function tabTrigger() {

  $('.card').click(function(e) {
    e.preventDefault();
    $('.card').removeClass('active');
    $(this).addClass('active');

    $('.activity').hide();
    $('.activity[data-id="' + $.attr(this, 'data-id') + '"').fadeIn();
  });
}

tabTrigger();

$('.card-form .button').on('click', function(e) {

  cardName = $('#cardName').val();
  cardNumber = $('#cardNumber').val();
  for (var i = 0; i < 12; i++) {
    cardNumber = cardNumber.replaceAt(i, "*");
  }
  cardDate = $('#cardDate').val();
  cardCVS = $('#cardCVS').val();

  if ($('.type-form').length) {
    alert('Please complete card type.');
  } else if (cardName == '') {
    alert('Card name appears to be empty.');
  } else if (cardNumber == '') {
    alert('Card number appears to be empty.');
  } else if (cardNumber.length != 16) {
    alert('Card number appears to be less then 16 characters.');
  } else if (cardDate == '') {
    alert('Card date appears to be empty.');
  } else if (cardCVS == '') {
    alert('Card CVS appears to be empty.');
  } else {
    for (var i = 1; i < 4; i++) {
      cardNumber = cardNumber.insert((5 * i) - 1, ' ');
    }

    cardType = $('.type').text();

    cardId = cardNumber.charAt(15);
    cardId += cardNumber.charAt(16);
    cardId += cardNumber.charAt(17);
    cardId += cardNumber.charAt(18);

    e.preventDefault();
    $('.overlay').fadeOut(300);

    $('.cards .content').append('<div class="card" data-id="' + cardId + '"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/' + cardType + '.png"/> <div class="number">' + cardNumber + '</div> <div class="expiration">Valid Thru: ' + cardDate + '</div> </div>');

    $('.wallet').append($('<div data-id="' + cardId + '" class="activity"> <header> <h2>Balance</h2><span>$0.<i>00</i></span> </header> <div class="content"> <div class="transaction transaction-empty">It seems you have no recent transactions.</div></div>').hide());

    tabTrigger();
    // Addin Account Balance

    $('.form input').val('');
  }
});

$('.close').on('click', function(e) {
  $('.overlay').fadeOut(300);
});

function typeChange() {
  typeText = $('.type').text();

  $('.type').on('click', function() {
    $(this).replaceWith('<input class="type-form" type="text" value="' + typeText + '" />')
  });
}

typeChange();

$(document).on('keydown', '.type-form', function(e) {
  if (e.keyCode == 13) {
    e.preventDefault();

    typeValue = $('.type-form').val();

    $('.type-form').replaceWith('<div class="type">' + typeValue + '</div>');

    typeChange();
  }
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console