Skip to content

Commit

Permalink
add close button to ft-prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkyProgrammer committed Oct 12, 2022
1 parent 7ff59cb commit 2eb9b61
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/renderer/components/ft-button/ft-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export default Vue.extend({
backgroundColor: {
type: String,
default: 'var(--accent-color)'
},
id: {
type: String,
default: ''
}
}
})
1 change: 1 addition & 0 deletions src/renderer/components/ft-button/ft-button.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<button
:id="id.length > 0 ? id : null"
class="btn ripple"
:style="{
color: textColor,
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/components/ft-prompt/ft-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@ export default Vue.extend({
}
},
mounted: function () {
document.querySelector('.prompt button').focus({ focusVisible: true })
this.focusItem(0)
},
methods: {
removeWhitespace,
hide: function() {
this.$emit('click', null)
},
handleHide: function (event) {
if (event.target.getAttribute('role') === 'button' || event.target.className === 'prompt') {
this.$emit('click', null)
this.hide()
}
},
focusItem: function (index) {
document.querySelector(`#prompt-${removeWhitespace(this.label)}-${index}`)
.focus({ focusVisible: true })
}
}
})
10 changes: 10 additions & 0 deletions src/renderer/components/ft-prompt/ft-prompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@
<ft-flex-box>
<ft-button
v-for="(option, index) in optionNames"
:id="'prompt-' + removeWhitespace(label) + '-' + index"
:key="index"
:label="option"
@click="$emit('click', optionValues[index])"
@keydown.left.prevent="focusItem(index-1)"
@keydown.right.prevent="focusItem(index+1)"
/>
<ft-button
:label="'Close'"
tabindex="0"
text-color="'var(--accent-color)'"
background-color="'var(--text-with-accent-color)'"
@click="hide"
/>
</ft-flex-box>
</slot>
Expand Down

0 comments on commit 2eb9b61

Please sign in to comment.