JSFiddle - React, Tailwind, and code Playground

Delete Screen - VUE.js

by Hugo Carneiro

HTML

<script src="https://cdn.jsdelivr.net/vue/1.0.24/vue.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<!-- template for the modal component -->
<script type="x/template" id="modal-template">
  <div class="modal-mask" v-show="show" transition="modal">
    <div class="modal-wrapper">
      <div class="modal-container">

        <div class="modal-header danger">
          <slot name="header">
            <h4>Are you sure you want to delete this screen?</h4>
          </slot>
        </div>

        <div class="modal-body">
          <slot name="body">
            <p>All the content and progress saved on this screen will be lost permanently.</p>
            <p><strong>Are you sure you want to delete this screen?</strong></p>
          </slot>
        </div>

        <div class="modal-footer">
          <slot name="footer">
            <div class="btn btn-default" @click="show = false">Cancel</div>
            <div class="btn btn-danger" @click="show = false">Delete</div>
          </slot>
        </div>
      </div>
    </div>
  </div>
</script>

<!-- app -->
<div id="app">
  <ul class="menu">
    <li> <a href="#">Rename</a> </li>
    <li> <a href="#">Screen settings</a> </li>
    <li> <a href="#">Duplicate</a> </li>
    <li> <a href="#">Copy to...</a> </li>
    <li> <a href="#" id="show-modal-copy" @click="showModal = true">Delete</a> </li>
  </ul>
  <!-- use the modal component, pass in the prop -->
  <modal :show.sync="showModal">
    <!--
      you can use custom content here to overwrite
      default content
    -->
  </modal>
</div>

CSS

@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700);
html,
body {
  font-family: "Open Sans", "Helvetica Neue", Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: 15px;
}

.menu {
  position: relative;
  z-index: 1000;
  float: left;
  min-width: 160px;
  padding: 5px 0;
  margin: 2px 0 0;
  list-style: none;
  font-size: 14px;
  text-align: left;
  background-color: #fff;
  border: 1px solid #ccc;
  border: 1px solid rgba(0, 0, 0, .15);
  border-radius: 4px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
  background-clip: padding-box;
}

.menu>li>a {
  display: block;
  padding: 3px 20px;
  clear: both;
  font-weight: 400;
  line-height: 1.42857;
  color: #333;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}

.menu>li>a:focus,
.menu>li>a:hover {
  text-decoration: none;
  color: #262626;
  background-color: #f5f5f5;
}

.modal-mask {
  position: fixed;
  z-index: 9998;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, .5);
  display: table;
  transition: opacity .3s ease;
}

.modal-wrapper {
  display: table-cell;
  vertical-align: middle;
}

.modal-container {
  max-width: 500px;
  margin: 0px auto;
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
  transition: all .3s ease;
  overflow: hidden;
}

.modal-header {
  position: relative;
  z-index: 2;
  margin-top: 0;
  color: #14505e;
  padding: 20px;
  box-shadow: 0 0 10px rgba(51, 51, 51, .3);
}

.modal-header.danger {
  color: #c9302c;
}

.modal-body {
  padding: 30px 20px;
  background-color: #f2f6f7;
}

.modal-default-button {
  float: right;
}


/*
 * the following styles are auto-applied to elements with
 * v-transition="modal" when their visiblity is toggled
 * by Vue.js.
 *
 * You can easily play with the modal transition by editing
 * these styles.
 */

.modal-enter,
.modal-leave {
  opacity: 0;
}

.modal-enter .modal-container,
.modal-leave .modal-container {
 ...

JavaScript

// register modal component
Vue.component('modal', {
  template: '#modal-template',
  props: {
    show: {
      type: Boolean,
      required: true,
      twoWay: true
    }
  }
})

// start app
new Vue({
  el: '#app',
  data: {
    showModal: false
  }
})

$('#link-type').on('change', function() {
  var selectedValue = $(this).val();
  var selectedText = $(this).find("option:selected").text();
  $('.section.show').removeClass('show');
  $('#' + selectedValue).addClass('show');
  $(this).parents('.select-proxy-display').find('.select-value-proxy').html(selectedText);
});