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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <div id="app" class="container mx-auto py-6">
  <header>
    <div>
      <span id="logo">Liquid Gold Box</span>
    </div>
  </header>

  <div class="content">
    <h1 class="title">Coffee Plans</h1>

    <h2 class="subtitle">
      We travel the world to source the very best single origin coffee for you
    </h2>

    <!--<div class="plans">
		<!-- This is another better option to code it, using an array, v-for, v-bind -->
		<!--<plan v-for="plan in plans" :name="plan"></plan>
		
		<!-- This is one better option to code it, using vue props
		<plan name="The Single"></plan>
		<plan name="The Curious"></plan>
		<plan name="The Addict"></plan> -->

	  <!-- This is a verbose way to code it 	
      <div class="plan">
        <div class="description">
          <span class="title">
            The Single
          </span>
        </div>
      </div>
      <div class="plan">
        <div class="description">
          <span class="title">
            The Curious
          </span>
        </div>
      </div>
      <div class="plan">
        <div class="description">
          <span class="title">
            The Addict
          </span>
        </div>
      </div>-->
    <!--</div>-->
	
	<plan-picker></plan-picker>
	  
  </div>
</div>

<script type="text/x-template" id="plan-picker-template">
	<div class="plans">
		<!-- using v-on we listen for the select event in the parent, call the selectPlan method -->
		<plan-picker-item v-for="plan in plans" :name="plan" @select="selectPlan" :selected-plan="selectedPlan"></plan-picker-item>
	</div>
</script>

<script type="text/x-template" id="plan-picker-item-template">
	<!-- @click to listen to the event in this root element, class binding to dynamically add the active plan class when plan is selected -->
	<div @click="select" class="plan" :class="{'active-plan': isSelected}">
        <div class="description">
          <span class="title">
            {{name}}
          </span>
        </div>
     </div>
</script>

<script src="https://unpkg.com/vue"></script>
              
            
!

CSS

              
                 /*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */
  
  html {
    line-height: 1.15;
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%
  }
  
  body {
    margin: 0
  }
  
  header,
  nav,
  section {
    display: block
  }
  
  h1 {
    font-size: 2em;
    margin: .67em 0
  }
  
  figcaption,
  main {
    display: block
  }
  
  hr {
    -webkit-box-sizing: content-box;
    box-sizing: content-box;
    height: 0;
    overflow: visible
  }
  
  a {
    background-color: transparent;
    -webkit-text-decoration-skip: objects
  }
  
  strong {
    font-weight: inherit;
    font-weight: bolder
  }
  
  code {
    font-family: monospace, monospace;
    font-size: 1em
  }
  
  dfn {
    font-style: italic
  }
  
  img {
    border-style: none
  }
  
  svg:not(:root) {
    overflow: hidden
  }
  
  button,
  input,
  textarea {
    font-family: sans-serif;
    font-size: 100%;
    line-height: 1.15;
    margin: 0
  }
  
  button,
  input {
    overflow: visible
  }
  
  button {
    text-transform: none
  }
  
  [type=reset],
  [type=submit],
  button,
  html [type=button] {
    -webkit-appearance: button
  }
  
  [type=button]::-moz-focus-inner,
  [type=reset]::-moz-focus-inner,
  [type=submit]::-moz-focus-inner,
  button::-moz-focus-inner {
    border-style: none;
    padding: 0
  }
  
  [type=button]:-moz-focusring,
  [type=reset]:-moz-focusring,
  [type=submit]:-moz-focusring,
  button:-moz-focusring {
    outline: 1px dotted ButtonText
  }
  
  legend {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    color: inherit;
    display: table;
    max-width: 100%;
    padding: 0;
    white-space: normal
  }
  
  textarea {
    overflow: auto
  }
  
  [type=checkbox],
  [type=radio] {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    padding: 0
  }
  
  [type=number]::-webkit-inner-spin-button,
  [type=number]::-webkit-outer-spin-button {
    height: auto
  }
  
  [type=search] {
    -webkit-appearance: textfield;
    outline-offset: -2px
  }
  
  [type=search]::-webkit-search-cancel-button,
  [type=search]::-webkit-search-decoration {
    -webkit-appearance: none
  }
  
  ::-webkit-file-upload-button {
    -webkit-appearance: button;
    font: inherit
  }
  
  details,
  menu {
    display: block
  }
  
  summary {
    display: list-item
  }
  
  canvas {
    display: inline-block
  }
  
  [hidden],
  template {
    display: none
  }
  
  html {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    font-family: sans-serif
  }
  
  *,
  :after,
  :before {
    -webkit-box-sizing: inherit;
    box-sizing: inherit
  }
  
  h1,
  h2,
  h3,
  p {
    margin: 0
  }
  
  button {
    background: transparent;
    padding: 0
  }
  
  button:focus {
    outline: 1px dotted;
    outline: 5px auto -webkit-focus-ring-color
  }
  
  *,
  :after,
  :before {
    border: 0 solid #dae1e7
  }
  
  img {
    border-style: solid
  }
  
  [type=button],
  [type=reset],
  [type=submit],
  button {
    border-radius: 0
  }
  
  textarea {
    resize: vertical
  }
  
  img {
    max-width: 100%;
    height: auto
  }
  
  button,
  input,
  textarea {
    font-family: inherit
  }
  
  input::-webkit-input-placeholder,
  textarea::-webkit-input-placeholder {
    color: inherit;
    opacity: .5
  }
  
  input:-ms-input-placeholder,
  input::-ms-input-placeholder,
  textarea:-ms-input-placeholder,
  textarea::-ms-input-placeholder {
    color: inherit;
    opacity: .5
  }
  
  input::placeholder,
  textarea::placeholder {
    color: inherit;
    opacity: .5
  }
  
  [role=button],
  button {
    cursor: pointer
  }
  
  .container {
    width: 100%
  }
  
  @media (min-width:576px) {
    .container {
      max-width: 576px
    }
  }
  
  @media (min-width:768px) {
    .container {
      max-width: 768px
    }
  }
  
  @media (min-width:992px) {
    .container {
      max-width: 992px
    }
  }
  
  @media (min-width:1200px) {
    .container {
      max-width: 1200px
    }
  }
  
  .hidden {
    display: none
  }
  
  .leading-normal {
    line-height: 1.5
  }
  
  .mx-auto {
    margin-left: auto;
    margin-right: auto
  }
  
  .py-6 {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem
  }
  
  .text-center {
    text-align: center
  }
  
  .w-1\/3 {
    width: 33.33333%
  }
  
  .w-2\/3 {
    width: 66.66667%
  }
  
  body {
    height: 100vh;
    -webkit-font-smoothing: auto;
    -moz-osx-font-smoothing: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: Roboto, sans-serif;
    background-color: #ccdcdc;
    background-image: url("/coffee.jpg");
    background-repeat: no-repeat;
    background-position: 100% 100%
  }
  
  .content {
    margin-left: auto;
    margin-right: auto;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    width: 620px
  }
  
  h1.title {
    text-align: center;
    font-size: 1.875rem;
    font-weight: 500;
    color: #2d3336
  }
  
  h2.subtitle {
    margin: .7rem auto;
    font-weight: 300;
    font-size: 1.5rem;
    text-align: center;
    line-height: 1.5;
    letter-spacing: 0;
    max-width: 500px;
    color: #5c6162
  }
  
  .progress-bar {
    width: 100%;
    border-radius: 9999px;
    position: relative;
    margin-top: 1rem;
    margin-bottom: 1rem;
    height: 12px;
    background: #c6c6c6
  }
  
  .progress-bar>div {
    border-radius: 9999px;
    position: absolute;
    height: 100%;
    background-color: #09848d;
    -webkit-transition: all .3s ease;
    transition: all .3s ease
  }
  
  span#logo {
    font-weight: 700;
    text-transform: uppercase;
    color: #5c6162;
    font-size: .875rem;
    letter-spacing: .05em;
    padding-left: .5rem;
    padding-right: .5rem;
    padding-bottom: 1rem;
    background: url("/logo.png") bottom no-repeat
  }
  
  .buttons {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: end;
    -ms-flex-pack: end;
    justify-content: flex-end
  }
  
  .buttons a:not(:last-of-type),
  .buttons button:not(:last-of-type) {
    margin-left: .75rem;
    margin-right: .75rem
  }
  
  .btn {
    display: inline-block;
    color: #fff;
    background-color: #09848d;
    padding: .75rem 1.5rem;
    text-decoration: none;
    border-radius: .25rem;
    text-transform: uppercase;
    font-weight: 500;
    font-size: .875rem;
    border-width: 2px;
    border-color: #09848d;
    letter-spacing: .2;
    -webkit-transition: all .3s ease;
    transition: all .3s ease
  }
  
  .btn:hover {
    background: rgba(37, 142, 149, .96);
    border-color: rgba(37, 142, 149, .96)
  }
  
  .btn:disabled {
    background-color: #127077;
    border-color: #127077;
    color: #9fc1c3
  }
  
  .btn-outlined {
    display: inline-block;
    color: #09848d;
    padding: .75rem 1.5rem;
    text-decoration: none;
    border-radius: .25rem;
    text-transform: uppercase;
    font-weight: 500;
    font-size: .875rem;
    position: relative;
    border-width: 2px;
    border-color: #09848d;
    letter-spacing: .2;
    -webkit-transition: all .3s ease;
    transition: all .3s ease
  }
  
  .btn-outlined:hover {
    color: #fff;
    background: rgba(37, 142, 149, .96);
    border-color: rgba(37, 142, 149, .96)
  }
  
  .plans {
    padding: 0 40px;
    margin-bottom: 40px
  }
  
  .plans .plan {
    background-color: #fff;
    -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .1);
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .1);
    margin-top: 1rem;
    margin-bottom: 1rem;
    border-radius: .25rem;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    cursor: pointer;
    position: relative;
    -webkit-transition: all .3s ease;
    transition: all .3s ease
  }
  
  .plans .plan,
  .plans .plan>.weight {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex
  }
  
  .plans .plan>.weight {
    width: 20%;
    font-size: 1.875rem;
    font-weight: 500;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    background-color: #7dacaf;
    color: #136268;
    border-top-left-radius: .25rem;
    border-bottom-left-radius: .25rem;
    height: 100px
  }
  
  .plans .plan>.description {
    width: 60%;
    padding: 1rem
  }
  
  .plans .plan>.description .title {
    color: #3d4852;
    display: block;
    font-weight: 700;
    margin-bottom: .25rem
  }
  
  .plans .plan>.description .description {
    font-size: .875rem;
    font-weight: 500;
    color: #8795a1;
    line-height: 1.5
  }
  
  .plans .plan>.price {
    width: 20%;
    color: #09848d;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    padding-top: 1.5rem;
    font-family: Crimson Text, serif;
    font-weight: 600
  }
  
  .plans .plan>.price .dollar-sign {
    font-size: 24px;
    font-weight: 700
  }
  
  .plans .plan>.price .number {
    font-size: 72px;
    line-height: .5
  }
  
  .plans .active-plan,
  .plans .plan:hover {
    -webkit-box-shadow: 0 15px 30px 0 rgba(0, 0, 0, .11), 0 5px 15px 0 rgba(0, 0, 0, .08);
    box-shadow: 0 15px 30px 0 rgba(0, 0, 0, .11), 0 5px 15px 0 rgba(0, 0, 0, .08)
  }
  
  .plans .active-plan:after,
  .plans .plan:hover:after {
    border-width: 2px;
    border-color: #7dacaf;
    border-radius: .25rem;
    content: "";
    position: absolute;
    display: block;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0
  }
  
  form.form {
    padding: .8rem 4rem
  }
  
  .form-group,
  form.form {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap
  }
  
  .form-group {
    width: 100%;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    margin: .5rem 2rem;
    -webkit-box-pack: end;
    -ms-flex-pack: end;
    justify-content: flex-end
  }
  
  .form-group .form-label {
    width: 20%;
    text-align: right;
    margin-right: 2rem;
    font-weight: 500;
    color: #5c6162
  }
  
  .form-group .form-control {
    -webkit-box-flex: 1;
    -ms-flex-positive: 1;
    flex-grow: 1;
    border-radius: .25rem;
    padding: .5rem .75rem;
    color: #5c6162;
    font-weight: 500;
    background-color: #f4f7f7
  }
  
  .form-group .form-control::-webkit-input-placeholder {
    font-weight: 400
  }
  
  .form-group .form-control:-ms-input-placeholder,
  .form-group .form-control::-ms-input-placeholder {
    font-weight: 400
  }
  
  .form-group .form-control::placeholder {
    font-weight: 400
  }
  
  .form-group .form-control:focus {
    background-color: #fff;
    -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .1);
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .1);
    outline: none
  }
  
  .summary {
    background-color: #fff;
    border-radius: .5rem;
    padding: 1.5rem;
    -webkit-box-shadow: 0 15px 30px 0 rgba(0, 0, 0, .11), 0 5px 15px 0 rgba(0, 0, 0, .08);
    box-shadow: 0 15px 30px 0 rgba(0, 0, 0, .11), 0 5px 15px 0 rgba(0, 0, 0, .08);
    margin-bottom: 2rem
  }
  
  .summary h3 {
    font-size: 1.125rem;
    color: #5c6162;
    margin-bottom: .5rem
  }
  
  .summary .description,
  .summary h3 {
    font-weight: 500;
    letter-spacing: .05em
  }
  
  .summary .description {
    color: #8795a1;
    font-size: .875rem;
    width: 66.66667%;
    line-height: 1.5
  }
  
  .summary hr {
    margin-top: 1rem;
    margin-bottom: 1rem
  }
  
  .summary .options {
    margin-top: 1rem;
    margin-bottom: 2rem
  }
  
  .summary .options .option {
    margin-top: .5rem;
    letter-spacing: .05em;
    color: #5c6162;
    font-weight: 500;
    font-size: .875rem
  }
  
  .summary .options .option input {
    margin-left: 1rem;
    margin-right: .5rem
  }
  
  .summary .address {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex
  }
  
  .error {
    width: 100%;
    margin-top: .25rem;
    color: #e3342f;
    text-align: right;
    font-weight: 500;
    font-size: .875rem;
    color: tomato
  }
  
  .loading-wrapper {
    margin-top: 4rem
  }
  
  .loading-wrapper,
  .loading-wrapper .loader {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex
  }
  
  .loading-wrapper .loader {
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    padding: .5rem;
    margin-left: auto;
    margin-right: auto;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    border-width: 2px;
    border-color: #09848d;
    border-radius: .5rem;
    font-size: 1.25rem;
    color: #5c6162
  }
  
  .loading-wrapper .loader p {
    margin-right: 1rem
  }
  
  .info {
    margin-top: .25rem;
    color: #5c6162;
    text-align: right;
    font-weight: 500;
    font-size: .875rem;
  }
  
  a {
    color: #09848d;
    text-decoration: none;
  }
  
  a:not(.btn):hover {
    color: #127077;
    text-decoration: underline;
  }
              
            
!

JS

              
                // defining previously a Vue component as a JS object
let PlanPickerItemComponent = {
	template: '#plan-picker-item-template',
	props: {
		name: {
			type: String,
			required: true
		},
		// prop selectedPlan so that parent passes down the selected plan
		selectedPlan: {
			type: String
		}
	},
	computed: {
		//when active plan is selected, we dynamically add a class
		isSelected() {
			return this.name === this.selectedPlan
		}
	},
	methods: {
		select() {
			// to send custom event to the parent so that parent knows when user selects a plan. 'select' is the event name, and this.name is the data we want to pass along with the event called payload
			this.$emit('select', this.name)
		}
	}
}

// we can also register the plan picker component locally, since we don't need to use it in every page. Set it to a variable and define it in the parent - the root instance
let PlanPickerComponent = {
	template: '#plan-picker-template',
	// registering the plan template locally, with plan-picker as parent, and we cannot use it anymore outside of plan picker
	components: {
		'plan-picker-item': PlanPickerItemComponent
	},
	data() {
		return {
			plans: ['The Single', 'The Curious', 'The Addict'],
			//sets the default to not selected. The plan-picker needs to know which plan the user has selected
			selectedPlan: null
		}
	},
	// selectPlan method to receive the plan coming from the event's payload, and will set it to the selected plan
	methods: {
		selectPlan(plan) {
			this.selectedPlan = plan
		}
	}
}

/*Vue.component('plan-picker', {
	template: '#plan-picker-template',
	//including the data here so that the component is independent
	data() {
		return {
			plans: ['The Single', 'The Curious', 'The Addict']
		}
	}
})*/

/*Vue.component('plan', {
	template: '#plan-template',
	//Using props is one way to hardcode the plan names into html markup -->
	//props: ['name']
	props: {
		name: {
			type: String,
			required: true
		}
	}
})*/

new Vue({
	el: '#app',
	// Using an array is another way to pass the plans names dynamically instead of hardcoding them in the markup
	//Moved plans data into plan picker component so that component can access it directly 
	/*data: {
		plans: ['The Single', 'The Curious', 'The Addict']
	}*/
	components: {
		'plan-picker': PlanPickerComponent
	}
})
              
            
!
999px

Console