Skip to content

Commit f4e7769

Browse files
committed
feat(#711): adds rating appearance for range
1 parent 51b55d6 commit f4e7769

File tree

4 files changed

+37
-15
lines changed

4 files changed

+37
-15
lines changed

.changeset/wise-hoops-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@getodk/web-forms': minor
3+
---
4+
5+
Added support for 'rating' appearance to range question types

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ This section is auto generated. Please update `feature-matrix.json` and then run
8383
<summary>
8484

8585
<!-- prettier-ignore -->
86-
##### Appearances<br/>🟩🟩🟩🟩🟩🟩⬜⬜⬜⬜⬜⬜⬜⬜⬜ 41\%
86+
##### Appearances<br/>🟩🟩🟩🟩🟩🟩⬜⬜⬜⬜⬜⬜⬜⬜⬜ 43\%
8787

8888
</summary>
8989
<br/>
@@ -99,7 +99,7 @@ This section is auto generated. Please update `feature-matrix.json` and then run
9999
| [vertical](https://github.com/getodk/web-forms/issues/271) | |
100100
| [no-ticks](https://github.com/getodk/web-forms/issues/271) | |
101101
| picker | |
102-
| rating | |
102+
| [rating](https://github.com/getodk/web-forms/issues/711) | |
103103
| new | |
104104
| new-front | |
105105
| draw | |

feature-matrix.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"[vertical](https://github.com/getodk/web-forms/issues/271)": "",
4646
"[no-ticks](https://github.com/getodk/web-forms/issues/271)": "",
4747
"picker": "",
48-
"rating": "",
48+
"[rating](https://github.com/getodk/web-forms/issues/711)": "",
4949
"new": "",
5050
"new-front": "",
5151
"draw": "",

packages/web-forms/src/components/form-elements/range/RangeControl.vue

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts" setup>
22
import type { AnyRangeNode } from '@getodk/xforms-engine';
3+
import Rating from 'primevue/rating';
34
import { computed } from 'vue';
45
import ControlText from '../ControlText.vue';
56
import RangeSlider from './RangeSlider.vue';
@@ -43,24 +44,36 @@ const orientation = props.node.appearances.vertical ? 'vertical' : 'horizontal';
4344
<template>
4445
<ControlText :question="node" />
4546

46-
<div :class="['range-control-container', orientation]">
47-
<div class="range-bound range-min">
48-
{{ min }}
49-
</div>
50-
<RangeSlider
47+
<template v-if="props.node.appearances.rating">
48+
<Rating
5149
:id="node.nodeId"
5250
:disabled="node.currentState.readonly"
53-
:min="min"
54-
:max="max"
55-
:step="step"
56-
:orientation="orientation"
5751
:model-value="numberValue"
52+
:stars="max"
5853
@update:model-value="setValue"
5954
/>
60-
<div class="range-bound range-max">
61-
{{ max }}
55+
</template>
56+
57+
<template v-else>
58+
<div :class="['range-control-container', orientation]">
59+
<div class="range-bound range-min">
60+
{{ min }}
61+
</div>
62+
<RangeSlider
63+
:id="node.nodeId"
64+
:disabled="node.currentState.readonly"
65+
:min="min"
66+
:max="max"
67+
:step="step"
68+
:orientation="orientation"
69+
:model-value="numberValue"
70+
@update:model-value="setValue"
71+
/>
72+
<div class="range-bound range-max">
73+
{{ max }}
74+
</div>
6275
</div>
63-
</div>
76+
</template>
6477
</template>
6578

6679
<style scoped lang="scss">
@@ -197,4 +210,8 @@ const orientation = props.node.appearances.vertical ? 'vertical' : 'horizontal';
197210
z-index: var(--odk-z-index-form-content);
198211
}
199212
}
213+
214+
.p-rating {
215+
--p-rating-icon-size: 28px;
216+
}
200217
</style>

0 commit comments

Comments
 (0)