123

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.

            
              
<main id="vue-context">

	<form class="price" action="javascript:void()">
		<div class="display-total">bill: ${{subTotal}}</div> <br />

		<div class="min">$5</div>
		<input type="range" v-model='subTotal' min="5" max="300" />
		<div class="max">$300</div>
	</form>

	<figure class='big-face'>
		<div>{{face}}</div>
	</figure>

	<form class="feel" action="javascript:void()">
		<span>๐Ÿ˜ง</span>
		<input
			type="range"
			min="5" max="25" step="2"
			v-model='tipPercentage'
		/>
		<span>๐Ÿ˜ƒ</span>
	</form>

	<output class='outcome' v-if='subTotal'>
		<div class="sub-total">${{subTotal}}</div>
		<div class="tip">${{tip}}</div>
		<div class="to">${{totalWithTip}}</div>
		<div>{{tipPercentage}}%</div>
	</output>

</main>


<div class="thing">
	๐Ÿ˜กโ˜น๐Ÿ™๐Ÿ˜•๐Ÿ˜ถ๐Ÿ˜๐Ÿค”๐Ÿ™‚๐Ÿ˜„๐Ÿค—

	๐Ÿ˜๐Ÿ˜‹๐Ÿค—๐Ÿคญ๐Ÿค”๐Ÿคจ๐Ÿ˜
๐Ÿ˜‘๐Ÿ˜ถ๐Ÿ™„๐Ÿ˜ฌ๐Ÿ˜”๐Ÿคข๐Ÿ˜•๐Ÿ˜Ÿ
๐Ÿ™โ˜น๐Ÿ˜ฆ๐Ÿ˜ง๐Ÿ˜–๐Ÿ˜ ๐Ÿ˜ก๐Ÿ˜ž
๐Ÿคฎ๐Ÿ˜ƒ๐Ÿ˜€๐Ÿ˜„๐Ÿ™‚๐Ÿ˜Š
๐Ÿ˜ก๐Ÿ™๐Ÿ˜•๐Ÿ˜ฌ๐Ÿคญ๐Ÿ˜๐Ÿค”๐Ÿ™‚๐Ÿ˜„๐Ÿค—
</div>
            
          
!
            
              
html
	background: lightblue
	font-family: helvetica

body
	overflow: hidden
	
output
	display: block
	margin-top: 1rem
	span
		font-weight: bold

.field
	display: block
	margin-top: 1rem
	input
		padding: .5rem
		font-size: 18px
	&.tip
		opacity: .2

form
	margin-top: 1rem
	*
		display: inline-block
		vertical-align: middle
	span
		font-size: 40px


		
.price
	text-align: center
	width: 100%
	input
		width: 70vw
		max-width: 400px
	.display-total
		font-size: 50px
		
.feel
	text-align: center
	width: 100%
	input
		width: 70vw
		
.outcome
	border: 1px solid gray
	padding: .5rem
	font-size: 24px
	text-align: right
	max-width: 100px
	margin: 0 auto
	margin-top: 1rem
	.tip
		color: green
		
		
.thing
	font-size: 50px
	display: none
	
.big-face
	font-size: 200px
	display: flex
	flex-direction: row
	justify-content: center
	align-items: center
	margin-top: 2rem
            
          
!
            
              
const options = ['๐Ÿ˜ก','๐Ÿ˜ฆ','๐Ÿ™','๐Ÿ˜','๐Ÿ˜ฌ','๐Ÿ™‚','๐Ÿ˜Š','๐Ÿ˜€','๐Ÿ˜ƒ','๐Ÿค—', '๐Ÿ˜'];
																// ๐Ÿ˜ƒ๐Ÿ˜€๐Ÿ˜„๐Ÿ™‚๐Ÿ˜Š

new Vue({
	el: '#vue-context',
	data: function() {
		return {
			excerciseNumber: 0,
			subTotal: '40',
			tipPercentage: '15',
			optionsData: options,
		};
	},
	computed: {
		tip() {
			let tipInDecimal = this.tipPercentage / 100;
			let rawTip = this.subTotal * tipInDecimal;
			return rawTip.toFixed(2);
		},
		totalWithTip() {
			let tip = Number(this.tip);
			let subTotal = Number(this.subTotal);
			return (subTotal + tip).toFixed(2);
		},
		face() {
			let x = (this.tipPercentage - 5)/2;
			return this.optionsData[x];
		},
	},
});

            
          
!
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.

Console