Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                #vue
  #shop.flex.x_center
    .product(v-for="product in products")
      img(:src="'//zupra.github.io/t-shirt_shop/img/test-2/'+product.id+'.png'")
      .product_name {{ product.name }}
      .flex.x_se
        .product_price {{ product.price }} ₽
        .product_count.flex.y_center
          .btn.qtyMinus(
            :class="{disabled: !product.qty}"
            @click="(product.qty > 1) ? product.qty -= 1 : $delete(product, 'qty')"
          )
          .W_2em {{ !product.qty ? 0 : product.qty }}
          .btn.qtyPlus(
            @click="addToCart(product)"
          )

  .Cart

    transition(name="cartUpdate")
      .cartUpdate(
        :key="count"
      ) 
        b {{count}} / {{total}} 
        | ₽
    .Cart_item.flex.y_center.x_sb(v-for="product,idx in cart")
      .flex.y_center
        | {{idx + 1}}) &nbsp;
        .name {{ product.name }} &nbsp;
        b {{ product.price }} ₽
      .flex.y_center
        .btn.qtyMinus(
          :class="{disabled: !product.qty}"
          @click="(product.qty > 1) ? product.qty -= 1 : ''"
        )
        center.W_2em {{ !product.qty ? 0 : product.qty }}
        .btn.qtyPlus(
          @click="addToCart(product)"
        )
        center.W_3em {{product.qty * product.price}}
        .Del(@click="$delete(product, 'qty')") ✖ 
        
              
            
!

CSS

              
                *
  margin 0
  padding 0
  box-sizing border-box
body
  font-family sans-serif
  color #262626

// ==== <GRID =====
.flex_col, .flex
  display flex
.flex_col
  flex-direction column
.x_start
  justify-content flex-start
.x_end
  justify-content flex-end
.x_center
  justify-content center
.x_se
  justify-content space-evenly
.x_sb
  justify-content space-between
.y_center
  align-items center
.y_start
  align-items flex-start
.y_end
  align-items flex-end
.y_base
  align-items baseline
// ==== </GRID =====
  

#shop
  flex-wrap wrap
.product  
  text-align center
  filter: drop-shadow(0 0 20px rgba(#000,.5));
  &_name
    margin-bottom .5em
  &_price
    font-size 1.2em
    display inline-block
    background #fffbd3
    padding .5em
    border-radius .5em
    vertical-align middle
  &_count
    user-select none
    font-size 2em
.Del, 
.qtyMinus,
.qtyPlus
  cursor pointer
  border-radius 50%
  width 22px
  height 22px
.Del
  background red
  line-height 22px

  
.btn
  &:hover
    background-color tomato
.qtyMinus
  background salmon url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'><line x1='0' y1='5' x2='10' y2='5' stroke='white'></line></svg>") center/60% no-repeat
.qtyPlus
  background salmon url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' stroke='white'><line x1='0' y1='5' x2='10' y2='5'></line><line x1='5' y1='0' x2='5' y2='10'></line></svg>") center/60% no-repeat
.disabled
  opacity .2
  cursor: not-allowed;
.product_count
  .qtyMinus,
  .qtyPlus
    width 30px
    height 30px



.Cart
  position fixed
  background rgba(#000, .6)
  color #FFF
  margin 1em   
  bottom 0
  right 0
  width 320px
  padding 2em .5em .5em
  text-align center
  &_item
    & + &
      border-top 1px dashed #999
    display flex
    align-items: center;
    padding .5em 0
    
  .name  
    color: aqua;

    
.W_2em
  width 2em
.W_3em
  width 3em
.cartUpdate
  font-size 1.4em
  height 1em
  line-height 1
  
  position absolute
  width 100%
  top .5em
  text-align center

.cartUpdate-enter-active 
  color: aqua;
  animation cartUpdate .5s
.cartUpdate-leave-active
  animation cartUpdate .3s reverse
@keyframes cartUpdate {
  from {
    transform: translate3d(0, 100%, 0) scale(1.2);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

              
            
!

JS

              
                var vm = new Vue({
  el: "#vue",
  data: {

    products: [{
        id: 1,
        name: "black",
        price: 99
    }, {
        id: 2,
        name: "dark-blue",
        price: 99
    }, {
        id: 3,
        name: "green",
        price: 99
    },  {
        id: 4,
        name: "grey",
        price: 99
    }, {
        id: 5,
        name: "light-blue",
        price: 99
    }, {
        id: 6,
        name: "pink",
        price: 99
    }, {
        id: 7,
        name: "purple",
        price: 99
    }, {
        id: 8,
        name: "red",
        price: 99
    }, {
        id: 9,
        name: "white",
        price: 99
    }],
  },
  computed: {
    cart() {
      return this.products.filter(i => i.qty)
    },
    count() {
      return this.cart.reduce( (n, cart) => cart.qty + n, 0)
    },
    total() {
      return this.cart.reduce( (n, cart) => cart.price * cart.qty + n, 0).toFixed(2);
    }
  },
  methods: {
    addToCart (product) {
      product.qty ? product.qty++ : this.$set(product, 'qty', +1)
    }
  }
});

              
            
!
999px

Console