Skip to content

Commit bbc786e

Browse files
committed
feature: Update Rick Generator with instructions and a better templates
1 parent d353bfa commit bbc786e

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!DOCTYPE html>
12
<html lang="en">
23

34
<head>
@@ -9,29 +10,48 @@
910
<link href="https://fonts.googleapis.com/css?family=Frijole" rel="stylesheet">
1011
</head>
1112

13+
<!-- Instructions -->
14+
<!-- 1. Replace 'Static' with the data property `noun` -->
15+
<!-- 2. Wire up `input#noun` to dynamically update `noun` when you type in it -->
16+
<!-- 3. Use dynamic inline-styles to define a `backgroundImage` on `div#image-wrapper` that uses the data property `imageUrl` -->
17+
<!-- 4. Wire up `input#background-image` to dynamically update the data property `imageUrl` -->
18+
<!-- 5. Toggle `aside#side-menu` visibility when you click on `button#toggle-menu` -->
19+
<!-- 6. Challenge: Write a method that updates `div#template-wrapper` position when you click on `div#image-wrapper` -->
20+
1221
<body>
13-
<div class="app-wrapper">
14-
<div id="image-wrapper" class="image-wrapper" style="background-image: url('https://vignette.wikia.nocookie.net/clubpenguin/images/7/71/Pickle.png/revision/latest?cb=20140205184407')">
22+
<div id="app" class="app-wrapper">
23+
<div id="image-wrapper" class="image-wrapper">
1524
<div class="template-wrapper" id="template-wrapper">
1625
<div class="speech-bubble">
17-
<p>I'm Pickle Rick!</p>
26+
<p>I'm Static Rick!</p>
1827
</div>
1928
<img class="rick-face" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/262582/PickleRickFace.svg" alt="Rick Face Template">
2029
</div>
2130
</div>
22-
<button id="toggle-menu" class="toggle-menu">Toggle Menu</button>
31+
<button id="toggle-menu" class="toggle-menu" @click="showMenu = !showMenu">Toggle Menu</button>
2332

24-
<aside id="side-menu" class="side-menu">
33+
<aside v-if="showMenu" id="side-menu" class="side-menu">
2534
<form class="side-menu__form">
2635
<label for="noun">Noun</label>
27-
<input type="text" id="noun" />
36+
<input type="text" id="noun" v-model="noun" />
2837
<label for="background-image">Background Image</label>
29-
<input type="text" id="background-image" />
38+
<input type="text" id="background-image" v-model="imageUrl" />
3039
</form>
3140
</aside>
3241
</div>
3342

3443
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.3/vue.min.js"></script>
44+
<script>
45+
const app = new Vue({
46+
el: '#app',
47+
data: {
48+
noun: 'Pickle',
49+
showMenu: true,
50+
imageUrl: 'https://vignette.wikia.nocookie.net/clubpenguin/images/7/71/Pickle.png/revision/latest?cb=20140205184407'
51+
},
52+
methods: {}
53+
})
54+
</script>
3555
</body>
3656

3757
</html>

exercises/rick-generator/02-final-rick-generator.html

+8-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<body>
1414
<div id="app" class="app-wrapper">
15-
<div id="image-wrapper" class="image-wrapper" @click="updatePosition" :style="{ backgroundImage: 'url(' + imageUrl + ')' }">
15+
<div id="image-wrapper" class="image-wrapper" @click="updatePosition" :style="{ backgroundImage: `url('${imageUrl}')` }">
1616
<div class="template-wrapper" id="template-wrapper" :style="{ top: y, left: x, width: wrapperWidth }">
1717
<div class="speech-bubble">
1818
<p>I'm {{ noun }} Rick!</p>
@@ -36,15 +36,13 @@
3636
<script>
3737
const app = new Vue({
3838
el: '#app',
39-
data() {
40-
return {
41-
noun: 'Pickle',
42-
x: 20 + 'px',
43-
y: 50 + 'px',
44-
showMenu: true,
45-
wrapperWidth: 600 + 'px',
46-
imageUrl: 'https://vignette.wikia.nocookie.net/clubpenguin/images/7/71/Pickle.png/revision/latest?cb=20140205184407'
47-
}
39+
data: {
40+
noun: 'Pickle',
41+
x: 20 + 'px',
42+
y: 50 + 'px',
43+
showMenu: true,
44+
wrapperWidth: 600 + 'px',
45+
imageUrl: 'https://vignette.wikia.nocookie.net/clubpenguin/images/7/71/Pickle.png/revision/latest?cb=20140205184407'
4846
},
4947
methods: {
5048
updatePosition(event) {

exercises/rick-generator/rick-generator.css

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
right: 10px;
2525
padding: 20px;
2626
background-color: #eee;
27+
font-family: sans-serif;
2728
}
2829
.side-menu__form {
2930
display: -webkit-box;

0 commit comments

Comments
 (0)