Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions examples/questionnaire/Example.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@
v-on:click.prevent="onSendData()"
aria-label="Press to submit"
>
<span>{{ language.submitText }}</span>
<span>{{ language.submitText }}</span>
</button>
<a class="f-enter-desc"
href="#"
v-on:click.prevent="onSendData()">
{{ language.pressEnter }}</a>
v-on:click.prevent="onSendData()"
v-html="language.formatString(language.pressEnter)">
</a>
</div>

<p class="text-success" v-if="submitted">Submitted succesfully.</p>
Expand Down Expand Up @@ -290,7 +291,7 @@

return data
}
}
},
}
</script>

Expand Down
7 changes: 4 additions & 3 deletions examples/quiz/Example.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
<a
class="f-enter-desc"
href="#"
v-on:click.prevent="onQuizSubmit()">
{{ language.pressEnter }}</a>
v-on:click.prevent="onQuizSubmit()"
v-html="language.formatString(language.pressEnter)">
</a>
</div>
<p class="text-success" v-if="submitted && score < 4">"You scored {{ score }} out of {{ total }}. There's a lot of room for improvement."</p>
<p class="text-success" v-else-if="submitted && score < 7">"You scored {{ score }} out of {{ total }}. Not bad at all!"</p>
Expand Down Expand Up @@ -331,7 +332,7 @@
this.submitted = true
this.calculateScore()
}
}
},
}
</script>

Expand Down
6 changes: 5 additions & 1 deletion src/assets/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ svg.logo {
margin-bottom: 20px;
}

.f-uppercase {
text-transform: uppercase;
}

/*v-form*/
.v-form {
margin-top: 26vh;
Expand Down Expand Up @@ -398,7 +402,7 @@ span.f-sub {
margin-top: 6px;
}

span.f-sub span{
span.f-sub span:not(.f-uppercase) {
margin-right: .4rem;
}

Expand Down
7 changes: 4 additions & 3 deletions src/components/FlowForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
class="f-enter-desc"
href="#"
v-on:click.prevent="submit()"
v-if="!submitted">
{{ language.pressEnter }}</a>
v-if="!submitted"
v-html="language.formatString(language.pressEnter)">
</a>
</slot>
</div>
</div>
Expand Down Expand Up @@ -466,7 +467,7 @@
*/
blurFocus() {
document.activeElement && document.activeElement.blur && document.activeElement.blur()
}
},
}
}
</script>
Expand Down
8 changes: 5 additions & 3 deletions src/components/Question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<span class="f-sub" v-if="question.subtitle || question.type === QuestionType.LongText || question.multiple">
<span v-if="question.subtitle">{{ question.subtitle }}</span>

<span class="f-help" v-if="question.type === QuestionType.LongText && !isMobile">{{ question.helpText || language.longTextHelpText }}</span>
<span class="f-help" v-if="question.type === QuestionType.LongText && !isMobile" v-html="question.helpText || language.formatString(language.longTextHelpText)"></span>

<span class="f-help" v-if="question.multiple">{{ question.helpText || language.multipleChoiceHelpText }}</span>
</span>
Expand Down Expand Up @@ -66,8 +66,9 @@
class="f-enter-desc"
href="#"
v-if="question.type !== QuestionType.LongText || !isMobile"
v-on:click.prevent="onEnter">
{{ language.pressEnter }}</a>
v-on:click.prevent="onEnter"
v-html="language.formatString(language.pressEnter)">
</a>
</div>

<div v-if="showInvalid()" class="f-invalid" role="alert" aria-live="assertive">{{ language.invalidPrompt }}</div>
Expand Down Expand Up @@ -95,6 +96,7 @@
import FlowFormTextType from './QuestionTypes/TextType.vue'
import FlowFormUrlType from './QuestionTypes/UrlType.vue'
import { IsMobile } from '../mixins/IsMobile'


export default {
name: 'FlowFormQuestion',
Expand Down
2 changes: 1 addition & 1 deletion src/components/QuestionTypes/BaseType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
value: [String, Array]
},
mixins: [
IsMobile
IsMobile,
],
data() {
return {
Expand Down
24 changes: 21 additions & 3 deletions src/models/LanguageModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

export default class LanguageModel {
constructor(options) {
this.enterKey = 'Enter'
this.shiftKey = 'Shift'
this.ok = 'OK'
this.continue = 'Continue'
this.pressEnter = 'Press ENTER'
this.pressEnter = 'Press :enterKey'
this.multipleChoiceHelpText = 'Choose as many as you like'
this.otherPrompt = 'Other'
this.placeholder = 'Type your answer here...'
this.submitText = 'Submit'
this.longTextHelpText = 'SHIFT + ENTER to make a line break.'
this.longTextHelpText = ':shiftKey + :enterKey to make a line break.'
this.prev = 'Prev'
this.next = 'Next'
this.percentCompleted = ':percent% completed'
Expand All @@ -31,4 +33,20 @@ export default class LanguageModel {

Object.assign(this, options || {})
}
}

/**
* Inserts a new CSS class into the language model string to format the :string
* Use it in a component's v-html directive: v-html="language.formatString(language.languageString)"
*/
formatString(string) {
return string.replace(/:(\w+)/g, (match, word) => {
if (this[word]) {
return '<span class="f-uppercase">' + this[word] + '</span>'
}

return match
})
}
}