This commit is contained in:
Julien Nahum 2023-09-08 18:45:03 +02:00
commit a81aa6a9e7
5 changed files with 18 additions and 8 deletions

View File

@ -57,8 +57,8 @@
<loader class="h-6 w-6 text-nt-blue mx-auto" /> <loader class="h-6 w-6 text-nt-blue mx-auto" />
</div> </div>
<template v-if="filteredOptions.length>0"> <template v-if="filteredOptions.length>0">
<li v-for="item in filteredOptions" :key="item[optionKey]" role="option" <li v-for="item in filteredOptions" :key="item[optionKey]" role="option" :style="optionStyle"
class="text-gray-900 cursor-default select-none relative py-2 pl-3 pr-9 cursor-pointer group hover:text-white hover:bg-nt-blue focus:outline-none focus:text-white focus:bg-nt-blue" class="text-gray-900 cursor-default select-none relative py-2 pl-3 pr-9 cursor-pointer group hover:text-white hover:bg-form-color focus:outline-none focus:text-white focus:bg-nt-blue"
:dusk="dusk+'_option'" @click="select(item)" :dusk="dusk+'_option'" @click="select(item)"
> >
<slot name="option" :option="item" :selected="isSelected(item)" /> <slot name="option" :option="item" :selected="isSelected(item)" />
@ -67,8 +67,8 @@
<p v-else-if="!loading && !(allowCreation && searchTerm)" class="w-full text-gray-500 text-center py-2"> <p v-else-if="!loading && !(allowCreation && searchTerm)" class="w-full text-gray-500 text-center py-2">
{{ (allowCreation ? 'Type something to add an option': 'No option available') }}. {{ (allowCreation ? 'Type something to add an option': 'No option available') }}.
</p> </p>
<li v-if="allowCreation && searchTerm" role="option" <li v-if="allowCreation && searchTerm" role="option" :style="optionStyle"
class="text-gray-900 cursor-default select-none relative py-2 pl-3 pr-9 cursor-pointer group hover:text-white hover:bg-nt-blue focus:outline-none focus:text-white focus:bg-nt-blue" class="text-gray-900 cursor-default select-none relative py-2 pl-3 pr-9 cursor-pointer group hover:text-white hover:bg-form-color focus:outline-none focus:text-white focus:bg-nt-blue"
@click="createOption(searchTerm)" @click="createOption(searchTerm)"
> >
Create <b class="px-1 bg-gray-300 rounded group-hover:text-black">{{ searchTerm }}</b> Create <b class="px-1 bg-gray-300 rounded group-hover:text-black">{{ searchTerm }}</b>
@ -127,6 +127,11 @@ export default {
} }
}, },
computed: { computed: {
optionStyle () {
return {
'--bg-form-color': this.color
}
},
inputStyle () { inputStyle () {
return { return {
'--tw-ring-color': this.color '--tw-ring-color': this.color

View File

@ -294,10 +294,10 @@ export default {
this.$store.commit('open/working_form/openSettingsForField', this.formFields.length-1) this.$store.commit('open/working_form/openSettingsForField', this.formFields.length-1)
}, },
removeBlock(blockIndex) { removeBlock(blockIndex) {
this.closeSidebar()
const newFields = clonedeep(this.formFields) const newFields = clonedeep(this.formFields)
newFields.splice(blockIndex, 1) newFields.splice(blockIndex, 1)
this.$set(this, 'formFields', newFields) this.$set(this, 'formFields', newFields)
this.closeSidebar()
}, },
closeSidebar() { closeSidebar() {
this.$store.commit('open/working_form/closeEditFieldSidebar') this.$store.commit('open/working_form/closeEditFieldSidebar')

View File

@ -121,18 +121,18 @@ export default {
this.$set(this.field, 'type', newType) this.$set(this.field, 'type', newType)
}, },
removeBlock() { removeBlock() {
this.closeSidebar()
const newFields = clonedeep(this.form.properties) const newFields = clonedeep(this.form.properties)
newFields.splice(this.selectedFieldIndex, 1) newFields.splice(this.selectedFieldIndex, 1)
this.$set(this.form, 'properties', newFields) this.$set(this.form, 'properties', newFields)
this.closeSidebar()
}, },
duplicateBlock() { duplicateBlock() {
this.closeSidebar()
const newFields = clonedeep(this.form.properties) const newFields = clonedeep(this.form.properties)
const newField = clonedeep(this.form.properties[this.selectedFieldIndex]) const newField = clonedeep(this.form.properties[this.selectedFieldIndex])
newField.id = this.generateUUID() newField.id = this.generateUUID()
newFields.push(newField) newFields.push(newField)
this.$set(this.form, 'properties', newFields) this.$set(this.form, 'properties', newFields)
this.closeSidebar()
}, },
closeSidebar() { closeSidebar() {
this.$store.commit('open/working_form/closeEditFieldSidebar') this.$store.commit('open/working_form/closeEditFieldSidebar')

View File

@ -18,6 +18,10 @@ body.dark * {
@layer base { @layer base {
:root {
--bg-form-color: #2563eb;
}
p, div { p, div {
@apply text-gray-900 dark:text-white; @apply text-gray-900 dark:text-white;
} }

3
tailwind.config.js vendored
View File

@ -68,7 +68,8 @@ module.exports = {
backgroundDark: '#272B2C', backgroundDark: '#272B2C',
help: '#37352f99', help: '#37352f99',
helpDark: '#fff9' helpDark: '#fff9'
} },
'form-color': 'var(--bg-form-color)'
}, },
transitionProperty: { transitionProperty: {
height: 'height', height: 'height',