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

              
                <!-- Make something fun and interactive -->
<!-- Press left or right on your keyboard! -->
<div id="vuenicorn-contest">
	<h1>Simon - A game of memory skill</h1>
	<p class="gameover" :class="{ hidden: !gameover }">GAMEOVER!</p>
	<button class="start-game" :class="{ hidden: !notPlaying }" @click="startGame">
		{{ gameover ? 'Retry' : 'Start Game'}}
	</button>

	<svg :width="windowWidth" 
		 :height="windowHeight"
	>
		<title>VueConf Toronto Logo</title>
		<g :transform="`translate(${logoPosition.x}, ${logoPosition.y})`">
			<g>
				<polygon @click="choose('darkBlue')" :fill="usedColors.darkBlue" 
					points="0.71875 98.9003906 36.0913086 99.5170898 18.375 69.0234375"></polygon>
				<polygon @click="choose('darkBlue')" :fill="usedColors.darkBlue" 
						 transform="translate(143.180054, 84.063232) scale(1, -1) translate(-143.180054, -84.063232)" 
						 points="125.901855 99.0178223 160.458252 99.5625 143.65625 68.5639648"></polygon>
				<polygon @click="choose('purple')" :fill="usedColors.purple" 
						 points="18 69.21875 35.8310547 99.3452148 53.6621094 69"></polygon>
				<polygon @click="choose('purple')" :fill="usedColors.purple" 
						 transform="translate(161.589844, 84.067383) scale(1, -1) translate(-161.589844, -84.067383)" 
						 points="143.517578 68.5175781 160.479492 99.6171875 179.662109 68.5175781"></polygon>
				<polygon @click="choose('pomegranate')" :fill="usedColors.pomegranate" 
						 points="0.931640625 99.015625 35.9980469 99.2988281 73.4584961 161.203125 55.1181641 192.684082"></polygon>
				<polygon @click="choose('pomegranate')" :fill="usedColors.pomegranate" 
						 transform="translate(116.946777, 115.671143) scale(-1, 1) translate(-116.946777, -115.671143)" 
						 points="89.9208984 98.7011719 107.97168 69 143.972656 131.498047 126.155762 162.342285"></polygon>
				<polygon @click="choose('skyBlue')" :fill="usedColors.skyBlue" 
						 points="35.7519531 98.9140625 53.6708984 68.8798828 89.9140625 131.990234 73.2851562 161.142578"></polygon>
				<polygon @click="choose('sunshine')" :fill="usedColors.sunshine" 
						 points="107.69873 162.451172 125.780273 192.767578 179.498047 99.5761719 143.942383 98.703125"></polygon>
				<polygon @click="choose('darkBlue')" :fill="usedColors.darkBlue" 
						 points="72.1601562 223.043945 54.9453125 192.087891 73.390625 160.777344 89.375 192.066406"></polygon>
				<polygon @click="choose('skyBlue')" :fill="usedColors.skyBlue" 
						 points="72.1193848 223.072388 107.859375 224.300781 125.692383 192.624023 89.0292969 192.624023"></polygon>
				<polygon @click="choose('purple')" :fill="usedColors.purple" 
						 points="72.8603516 162.036133 89.8085938 131.283203 125.591797 192.580078 88.7998047 192.580078"></polygon>
				<polygon @click="choose('darkBlue')" :fill="usedColors.darkBlue" 
						 points="65.9648438 44.6640625 113.873047 45.0136719 90.1796875 0.451171875"></polygon>
				<polygon @click="choose('skyBlue')" :fill="usedColors.skyBlue" 
						 transform="translate(89.954102, 66.281250) scale(1, -1) translate(-89.954102, -66.281250)" 
						 points="66 88.2128906 113.908203 88.5625 90.2148438 44"></polygon>
			</g>
		</g>
	</svg>
</div>

              
            
!

CSS

              
                // This certers the logo in the middle of the page
// Feel free to remove and customize to your liking
body {
	padding: 64px 0;
	display: flex;
	justify-content: center;
	align-items: center;
	min-height: 100vh;
}

#vuenicorn-contest {
	display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
}

.start-game {
	border: none;
	padding: 22px 32px;
	font-size: 24px;
	font-weight: bold;
	text-transform: uppercase;
	letter-spacing: 1px;
	border-radius: 8px;
	background-color: hotpink;
	color: #fff;
	margin-bottom: 32px;
}

.hidden {
	opacity: 0;
	pointer-events: none;
}

.gameover {
	font-size: 32px;
}

svg > g {
	margin: 0 auto;
}

h1 {
	padding: 0;
	margin: 0;
}
              
            
!

JS

              
                new Vue({
	el: '#vuenicorn-contest',
	data() {
		const windowWidth = window.innerWidth
		const windowHeight = window.innerHeight
		const logoWidth = 180
		const logoHeight = 225
		
		return {
			gameover: false,
			progress: 0,
			notPlaying: true,
			logoPosition: {
				x: (windowWidth - logoWidth) / 2,
				y: 64
			},
			colors: {
				purple: '#5D2B7B',
				purpleHighlight: '#7D4B5B',
				darkBlue: '#3A3A96',
				darkBlueHighlight: '#5A5AB6',
				pomegranate: '#ED3624',
				pomegranateHighlight: '#FD5644',
				sunshine: '#FEE104',
				sunshineHighlight: '#FEF124',
				skyBlue: '#30B9ED',
				skyBlueHighlight: '#50D9FD'
			},
			usedColors: {
				purple: '#5D2B7B',
				darkBlue: '#3A3A96',
				pomegranate: '#ED3624',
				sunshine: '#FEE104',
				skyBlue: '#30B9ED'
			},
			windowWidth,
			windowHeight,
			options: ['purple', 'darkBlue', 'pomegranate', 'sunshine', 'skyBlue'],
			pattern: []
		}
	},
	methods: {
		getRandomColor() {
			const random = Math.floor(Math.random() * this.options.length);
			
			return this.options[random];
		},
		highlightPattern() {
			this._highlight(0);
		},
		_highlight(index) {
			setTimeout(() => {
				this.usedColors[this.pattern[index]] = this.colors[`${this.pattern[index]}Highlight`];
			
				setTimeout(() => {
					this.usedColors[this.pattern[index]] = this.colors[`${this.pattern[index]}`];

					if (!this.pattern[index + 1]) { return; }
					this._highlight(index + 1);
				}, 500);
			}, 200);
		},
		gameLoop() {
			this.gameover = false;
			this.progress = 0;
			const randomColor = this.getRandomColor();
			this.pattern.push(randomColor);
			
			this.highlightPattern();
		},
		startGame() {
			this.notPlaying = false;
			setTimeout(() => {
				this.gameLoop();				
			}, 500);
		},
		choose(color) {			
			if (this.pattern[this.progress] === color) {
				this.progress++;
				
				this.usedColors[color] = this.colors[`${color}Highlight`];
			
				setTimeout(() => {
					this.usedColors[color] = this.colors[`${color}`];
				}, 300);
				
			} else {
				this.endGame();
				return;
			}
			
			if (this.progress >= this.pattern.length) {
				setTimeout(() => {
					this.gameLoop();
				}, 1000);
			}
		},
		endGame() {
			this.notPlaying = true;
			this.gameover = true;
			this.pattern = [];
			this.progress = 0;
		}
	}
})
              
            
!
999px

Console