Skip to content

Commit 332d859

Browse files
committed
feat(QInputChips): color refactoring
1 parent faf15e3 commit 332d859

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

dev/components/form/all2.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@
6161
<q-chips-input :dark="dark" class="q-my-sm" v-model="chips" float-label="Float Label" clearable suffix="SUF" prefix="PRE" />
6262
<q-chips-input :dark="dark" class="q-my-sm" v-model="chips" placeholder="Placeholder" float-label="With placeholder" clearable suffix="SUF" prefix="PRE" />
6363
<q-chips-input :dark="dark" class="q-my-sm" v-model="chips" placeholder="Placeholder" clearable suffix="SUF" prefix="PRE" />
64-
<q-chips-input :dark="dark" class="q-my-sm" color="amber-2" v-model="chips" stack-label="Stack Label" clearable suffix="SUF" prefix="PRE" />
64+
<q-chips-input :dark="dark" class="q-my-sm" color="amber-2" chips-color="amber-2" chips-bg-color="dark" v-model="chips" stack-label="Stack Label" clearable suffix="SUF" prefix="PRE" />
6565
<q-chips-input :dark="dark" class="q-my-sm" v-model="chips" inverted stack-label="Stack Label" clearable />
6666
<q-chips-input :dark="dark" class="q-my-sm" v-model="chips" inverted stack-label="Stack Label" clearable suffix="SUF" prefix="PRE" />
6767
<q-chips-input :dark="dark" class="q-my-sm" v-model="chips" inverted color="secondary" stack-label="With placeholder" placeholder="Placeholder" clearable suffix="SUF" prefix="PRE" />
6868
<q-chips-input :dark="dark" class="q-my-sm" color="amber-2" v-model="chips" inverted-light stack-label="Stack Label" clearable suffix="SUF" prefix="PRE" />
6969
<q-chips-input :dark="dark" class="q-my-sm" color="amber-2" v-model="chips" inverted-light float-label="With placeholder" placeholder="Placeholder" clearable suffix="SUF" prefix="PRE" />
7070
<q-chips-input :dark="dark" class="q-my-sm" color="white" v-model="chips" inverted-light stack-label="Stack Label" clearable suffix="SUF" prefix="PRE" />
71-
<q-chips-input :dark="dark" class="q-my-sm" inverted frame-color="dark" color="dark" v-model="chips" stack-label="Stack Label" clearable suffix="SUF" prefix="PRE" />
71+
<q-chips-input :dark="dark" class="q-my-sm" inverted color="dark" chips-color="black" chips-bg-color="lime" v-model="chips" stack-label="Stack Label" clearable suffix="SUF" prefix="PRE" />
7272
</div>
7373
<q-toggle v-model="dark" label="Dark" class="fixed-top-left bg-grey-5 q-pa-sm" style="top: 18px; left: 18px;" />
7474
</div>

src/components/chips-input/QChipsInput.vue

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
:hide-underline="hideUnderline"
1616
:before="before"
1717
:after="after"
18-
:color="computedColor"
18+
:color="color"
1919

2020
:focused="focused"
2121
:length="length"
@@ -29,7 +29,7 @@
2929
:closable="editable"
3030
v-for="(label, index) in model"
3131
:key="`${label}#${index}`"
32-
:color="computedChipColor"
32+
:color="computedChipBgColor"
3333
:text-color="computedChipTextColor"
3434
@blur="__onInputBlur"
3535
@blur.native="__onInputBlur"
@@ -91,7 +91,8 @@ export default {
9191
type: Array,
9292
required: true
9393
},
94-
frameColor: String,
94+
chipsColor: String,
95+
chipsBgColor: String,
9596
readonly: Boolean,
9697
addIcon: String
9798
},
@@ -115,24 +116,30 @@ export default {
115116
computedAddIcon () {
116117
return this.addIcon || this.$q.icon.chipsInput.add
117118
},
118-
computedColor () {
119-
return this.inverted || this.invertedLight ? this.frameColor || this.color : this.color
119+
computedChipTextColor () {
120+
if (this.chipsColor) {
121+
return this.chipsColor
122+
}
123+
if (this.inverted || this.invertedLight) {
124+
return this.color
125+
}
126+
return this.dark
127+
? this.color
128+
: 'white'
120129
},
121-
computedChipColor () {
130+
computedChipBgColor () {
131+
if (this.chipsBgColor) {
132+
return this.chipsBgColor
133+
}
122134
if (this.inverted) {
123135
return 'white'
124136
}
125137
if (this.invertedLight) {
126-
return 'grey-7'
138+
return 'grey-8'
127139
}
128-
return this.color
129-
},
130-
computedChipTextColor () {
131-
if (this.inverted || this.invertedLight) {
132-
return this.color
133-
}
134-
135-
return this.dark ? 'black' : 'white'
140+
return this.dark
141+
? 'white'
142+
: this.color
136143
}
137144
},
138145
methods: {

0 commit comments

Comments
 (0)