Skip to content

Commit 0b3635b

Browse files
committed
docs(QRating): small adjustments
1 parent 19cb0cf commit 0b3635b

File tree

6 files changed

+74
-28
lines changed

6 files changed

+74
-28
lines changed

docs/src/examples/QRating/HalfSelected.vue

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
<template>
22
<div class="q-pa-md">
33
<div class="q-gutter-y-md column">
4-
<div>Average rating:</div>
5-
64
<q-rating
7-
:value="model"
8-
@input="addRating"
5+
v-model="model1"
96
max="7"
10-
size="3.5em"
7+
size="3em"
118
color="green-5"
129
icon="star_border"
1310
icon-selected="star"
1411
icon-half="star_half"
1512
/>
1613

1714
<q-rating
18-
:value="model"
19-
@input="addRating"
15+
v-model="model2"
2016
max="7"
21-
size="3.5em"
17+
size="3em"
2218
color="yellow"
2319
icon="star_border"
2420
icon-selected="star"
@@ -27,17 +23,25 @@
2723
/>
2824

2925
<q-rating
30-
:value="model"
31-
@input="addRating"
26+
v-model="model3"
3227
max="7"
33-
size="3.5em"
34-
color="grey-4"
35-
color-half="blue"
36-
color-selected="green"
28+
size="3em"
29+
color="red"
30+
color-selected="red-9"
3731
icon="favorite_border"
3832
icon-selected="favorite"
33+
icon-half="favorite"
3934
no-dimming
4035
/>
36+
37+
<div>
38+
<q-btn
39+
color="grey"
40+
no-caps
41+
label="Reset"
42+
@click="resetModels"
43+
/>
44+
</div>
4145
</div>
4246
</div>
4347
</template>
@@ -46,21 +50,17 @@
4650
export default {
4751
data () {
4852
return {
49-
ratingModel: [ 3.5 ]
50-
}
51-
},
52-
53-
computed: {
54-
model () {
55-
return this.ratingModel.length === 0
56-
? 0
57-
: this.ratingModel.reduce((acc, rating) => acc + rating, 0) / this.ratingModel.length
53+
model1: 3.5,
54+
model2: 2.3,
55+
model3: 4.5
5856
}
5957
},
6058
6159
methods: {
62-
addRating (value) {
63-
this.ratingModel.push(value)
60+
resetModels () {
61+
this.model1 = 3.5
62+
this.model2 = 2.3
63+
this.model3 = 4.5
6464
}
6565
}
6666
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<div class="q-pa-md">
3+
<q-rating
4+
v-model="model"
5+
max="5"
6+
size="3.5em"
7+
color="yellow"
8+
icon="star_border"
9+
icon-selected="star"
10+
icon-half="star_half"
11+
no-dimming
12+
/>
13+
</div>
14+
</template>
15+
16+
<script>
17+
export default {
18+
data () {
19+
return {
20+
model: 2.3
21+
}
22+
}
23+
}
24+
</script>

docs/src/pages/vue-components/rating.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ In the example below, when using the `icon-selected` prop, notice we can still u
2727

2828
<doc-example title="Different icon for each rating" file="QRating/ArrayIcon" />
2929

30-
<doc-example title="Different icon and color when half selected" file="QRating/HalfSelected" />
31-
3230
### Colors
3331

3432
<q-badge label="v1.5.0+" />
@@ -37,6 +35,18 @@ When using the `color-selected` prop, notice we can still use `color` as well. T
3735

3836
<doc-example title="Different color for each rating" file="QRating/Colors" />
3937

38+
### Floating number
39+
40+
<q-badge label="v1.7.4+" />
41+
42+
<doc-example title="Different icon and color when half selected" file="QRating/HalfSelected" />
43+
44+
### No dimming
45+
46+
<q-badge label="v1.7.4+" />
47+
48+
<doc-example title="No dimming" file="QRating/NoDimming" />
49+
4050
### Tooltips
4151

4252
<q-badge label="v1.5.0+" />

ui/dev/src/pages/form/rating.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@
5858
<q-rating size="3rem" color="red-10" color-half="red-5" v-model="halfModel" :max="6" icon-selected="favorite" icon-half="favorite" icon="favorite_border" />
5959
<q-rating size="3rem" color="red" v-model="halfModel" :max="6" icon="img:https://cdn.quasar.dev/logo/svg/quasar-logo.svg" icon-half="star_half" />
6060
<q-rating size="3rem" color="red" v-model="halfModel" :max="6" icon="star_border" icon-selected="star" icon-half="star_half" />
61+
<q-rating
62+
v-model="halfModel"
63+
max="7"
64+
size="2em"
65+
color="grey-4"
66+
color-half="blue"
67+
color-selected="green"
68+
icon="favorite_border"
69+
icon-selected="favorite"
70+
no-dimming
71+
/>
6172
</div>
6273

6374
<p class="caption q-mt-lg">

ui/src/components/rating/QRating.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export default Vue.extend({
138138
const
139139
active = (this.mouseModel === 0 && this.value >= i) || (this.mouseModel > 0 && this.mouseModel >= i),
140140
half = halfIndex === i && this.mouseModel < i,
141-
exSelected = this.mouseModel > 0 && ceil >= i && this.mouseModel < i,
141+
exSelected = this.mouseModel > 0 && (half === true ? ceil : this.value) >= i && this.mouseModel < i,
142142
name = half === true
143143
? (i <= icons.halfIconLen ? this.iconHalf[i - 1] : icons.halfIcon)
144144
: (

ui/src/components/rating/QRating.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"no-dimming": {
8787
"type": "Boolean",
8888
"desc": "Does not lower opacity for unselected icons",
89+
"category": "style",
8990
"addedIn": "v1.7.4"
9091
},
9192

0 commit comments

Comments
 (0)