Skip to content

Commit 3aab62b

Browse files
committed
can add reviews
1 parent 6e0f10f commit 3aab62b

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

01-HelloWorld/04-ReviewableSocks.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Vue.component('product-review', {
2-
props: ['averageReviewScore'],
32
template: `
43
<form class="review-form" @submit.prevent="onSubmit">
5-
<h3 v-if="averageReviewScore">Score: {{ averageReviewScore }}</h3>
64
<h3>Add Review</h3>
75
<label>Name</label>
86
<input v-model="name">
@@ -42,6 +40,7 @@ Vue.component('product-review', {
4240

4341

4442

43+
4544

4645
Vue.component('product', {
4746
props: {
@@ -54,7 +53,10 @@ Vue.component('product', {
5453
</div>
5554
5655
<div class="product-info">
57-
<h1>{{ product }}</h1>
56+
<h1>
57+
{{ product }}
58+
<i v-for="i in averageReviewScore" class="fa fa-star"></i>
59+
</h1>
5860
5961
<div>
6062
<p v-if="inventory > 10">In Stock</p>
@@ -79,11 +81,8 @@ Vue.component('product', {
7981
:style="{backgroundColor: variant.color}"
8082
@mouseover="selectedVariantIndex = index">
8183
</div>
82-
83-
<product-review
84-
@add-review="addReview"
85-
:averageReviewScore="averageReviewScore"
86-
></product-review>
84+
85+
<product-review @add-review="addReview"></product-review>
8786
</div>
8887
</div>
8988
`,
@@ -106,7 +105,7 @@ Vue.component('product', {
106105
this.$emit('add-to-cart', {product: this.product, variant: selectedVariant});
107106
},
108107
addReview(review) {
109-
console.log('addReview', review);
108+
this.reviews.push(review.rating);
110109
}
111110
},
112111
computed: {

01-HelloWorld/assets/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ body {
2121
padding: 0rem 1rem;
2222
}
2323

24+
.fa.fa-star {
25+
color: rgb(219, 219, 91);
26+
font-size: 20px;
27+
}
28+
2429
img {
2530
border: 1px solid #d8d8d8;
2631
width: 70%;
@@ -80,6 +85,10 @@ button.add-to-cart {
8085
margin: 0px;
8186
}
8287

88+
h3 {
89+
margin-bottom: 6px;
90+
}
91+
8392
input {
8493
width: 100%;
8594
height: 25px;

0 commit comments

Comments
 (0)