Skip to content

Commit b3c7a1e

Browse files
committed
Add rate star svg and select previous logic
1 parent cb128ff commit b3c7a1e

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

src/assets/css/common.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,26 @@ header.vff-header svg.f-logo {
842842
.vff .field-iconrate ul.f-radios li .f-icon-wrap svg{
843843
height: 100%;
844844
width: 100%;
845+
max-height: 64px;
846+
max-width: 64px;
847+
fill: transparent;
848+
stroke: black;
849+
}
850+
851+
.vff .field-iconrate ul.f-radios li.f-selected,
852+
.vff .field-iconrate ul.f-radios li:active {
853+
border-color: unset;
854+
background-color: unset;
855+
}
856+
857+
.vff .field-iconrate ul.f-radios li:hover .f-icon-wrap svg {
858+
fill: var(--vff-tertiary-text-color);
859+
}
860+
861+
.vff .field-iconrate ul.f-radios li.f-selected .f-icon-wrap svg,
862+
.vff .field-iconrate ul.f-radios li.f-previous .f-icon-wrap svg,
863+
.vff .field-iconrate ul.f-radios li:active .f-icon-wrap svg {
864+
fill: #000;
845865
}
846866

847867
/*

src/components/QuestionTypes/OpinionScaleType.vue

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<li
55
v-for="(option, index) in question.options"
66
v-on:click.prevent="toggleAnswer(option)"
7-
v-bind:class="{'f-selected': option.selected}"
7+
v-bind:class="{'f-selected': option.selected, 'f-previous': isPreviousOption(option)}"
88
v-bind:key="'m' + index"
99
v-bind:aria-label="getLabel(option.value)"
1010
role="option"
@@ -14,7 +14,9 @@
1414
</div>
1515
<div v-else-if="isIconScale" class="f-icon-wrap">
1616
<div class="f-icon">
17-
<svg viewBox="0 0 58 47"><path class="symbolFill" d="M21 27.1L48.05.05l9.9 9.9L21 46.9.05 25.95l9.9-9.9z" fill-rule="nonzero"></path><path class="symbolOutline" d="M21 30.636L9.95 19.586 3.586 25.95 21 43.364 54.414 9.95 48.05 3.586 21 30.636zM48.05.05l9.9 9.9L21 46.9.05 25.95l9.9-9.9L21 27.1 48.05.05z" fill-rule="nonzero"></path></svg>
17+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
18+
<path d="M12 .587l3.668 7.568 8.332 1.151-6.064 5.828 1.48 8.279-7.416-3.967-7.417 3.967 1.481-8.279-6.064-5.828 8.332-1.151z"/>
19+
</svg>
1820
</div>
1921
<div class="f-key">{{ getToggleKey(option.value) }}</div>
2022
</div>
@@ -39,7 +41,8 @@
3941
4042
data() {
4143
return {
42-
isIconScale: false
44+
isIconScale: false,
45+
activeIndex: null
4346
}
4447
},
4548
@@ -89,7 +92,7 @@
8992
onKeyListener($event) {
9093
if (this.active && $event.key && $event.key.length === 1) {
9194
let keyCode = $event.key.toUpperCase().charCodeAt(0)
92-
console.log(keyCode)
95+
9396
if (keyCode >= 48 && keyCode <= 57) {
9497
let index = keyCode - 49
9598
@@ -108,17 +111,21 @@
108111
return this.language.ariaMultipleChoice.replace(':letter', this.getToggleKey(index))
109112
},
110113
114+
isPreviousOption(option) {
115+
return this.getPreviousOptions.includes(option)
116+
},
117+
111118
getToggleKey(num) {
112119
return num
113120
},
114121
115122
toggleAnswer(option) {
116123
for (let i = 0; i < this.question.options.length; i++) {
117-
let o = this.question.options[i]
124+
let o = this.question.options[i]
118125
119-
if (o.selected) {
120-
this._toggleAnswer(o)
121-
}
126+
if (o.selected) {
127+
this._toggleAnswer(o)
128+
}
122129
}
123130
124131
this._toggleAnswer(option)
@@ -130,6 +137,7 @@
130137
option.toggle()
131138
132139
this.dataValue = option.selected ? optionValue : null
140+
this.activeIndex = this.question.options.indexOf(option)
133141
134142
if (this.isValid() && this.question.nextStepOnAnswer && !this.disabled) {
135143
this.$emit('next')
@@ -154,6 +162,10 @@
154162
}
155163
156164
return false
165+
},
166+
167+
getPreviousOptions() {
168+
return this.question.options.filter((o, index) => index < this.activeIndex)
157169
}
158170
}
159171
}

0 commit comments

Comments
 (0)