Skip to content

Commit

Permalink
use computed properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkyProgrammer committed Dec 9, 2022
1 parent 9b40faf commit 5611cc5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/renderer/components/ft-prompt/ft-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export default Vue.extend({
promptButtons: []
}
},
computed: {
sanitizedLabel: function() {
return sanitizeForHtmlId(this.label)
}
},
beforeDestroy: function () {
document.removeEventListener('keydown', this.closeEventFunction, true)
},
Expand All @@ -48,7 +53,6 @@ export default Vue.extend({
this.focusItem(0)
},
methods: {
sanitizeForHtmlId,
hide: function() {
this.$emit('click', null)
},
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/ft-prompt/ft-prompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
>
<ft-card
class="promptCard"
:aria-labelledby="'dialog-' + sanitizeForHtmlId(label)"
:aria-labelledby="('dialog-' + sanitizedLabel)"
>
<slot>
<h2
:id="'dialog-' + sanitizeForHtmlId(label)"
:id="'dialog-' + sanitizedLabel"
class="center"
>
{{ label }}
Expand All @@ -28,13 +28,13 @@
<ft-flex-box>
<ft-button
v-for="(option, index) in optionNames"
:id="'prompt-' + sanitizeForHtmlId(label) + '-' + index"
:id="'prompt-' + sanitizedLabel + '-' + index"
:key="index"
:label="option"
@click="$emit('click', optionValues[index])"
/>
<ft-button
:id="'prompt-' + sanitizeForHtmlId(label) + '-close'"
:id="'prompt-' + sanitizedLabel + '-close'"
:label="$t('Close')"
tabindex="0"
text-color="'var(--accent-color)'"
Expand Down
6 changes: 4 additions & 2 deletions src/renderer/components/ft-select/ft-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default Vue.extend({
default: false
}
},
methods: {
sanitizeForHtmlId
computed: {
sanitizedPlaceholder: function() {
return sanitizeForHtmlId(this.placeholder)
}
}
})
6 changes: 3 additions & 3 deletions src/renderer/components/ft-select/ft-select.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<div class="select">
<select
:id="sanitizeForHtmlId(placeholder)"
:id="sanitizedPlaceholder"
class="select-text"
:class="{disabled: disabled}"
:value="value"
:name="sanitizeForHtmlId(placeholder)"
:name="sanitizedPlaceholder"
:disabled="disabled"
@change="$emit('change', $event.target.value)"
>
Expand All @@ -25,7 +25,7 @@
<span class="select-bar" />
<label
class="select-label"
:for="sanitizeForHtmlId(placeholder)"
:for="sanitizedPlaceholder"
:hidden="disabled"
>
{{ placeholder }}
Expand Down

0 comments on commit 5611cc5

Please sign in to comment.