Skip to content

Commit

Permalink
fix(NcColorPicker): make palette a radio buttons group
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
  • Loading branch information
ShGKme committed Nov 17, 2023
1 parent d203fb1 commit c7c62e0
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/components/NcColorPicker/NcColorPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,19 @@ export default {
:class="{ 'color-picker--advanced-fields': advanced && advancedFields }">
<Transition name="slide" mode="out-in">
<div v-if="!advanced" class="color-picker__simple">
<button v-for="({ color, name }, index) in normalizedPalette"
<label v-for="({ color, name }, index) in normalizedPalette"
:key="index"
:style="{ backgroundColor: color }"
class="color-picker__simple-color-circle"
:class="{ 'color-picker__simple-color-circle--active' : color === currentColor }"
:aria-label="name"
type="button"
@click="pickColor(color)">
:aria-label="name">
<Check v-if="color === currentColor" :size="20" />
</button>
<input type="radio"
class="hidden-visually"
:name="`color-picker-${uid}`"
:checked="color === currentColor"
@click="pickColor(color)">
</label>
</div>
<Chrome v-if="advanced"
v-model="currentColor"
Expand Down Expand Up @@ -218,6 +221,7 @@ import NcButton from '../NcButton/index.js'
import NcPopover from '../NcPopover/index.js'
import { t } from '../../l10n.js'
import GenColors from '../../utils/GenColors.js'
import GenRandomId from '../../utils/GenRandomId.js'
import ArrowLeft from 'vue-material-design-icons/ArrowLeft.vue'
import Check from 'vue-material-design-icons/Check.vue'
Expand Down Expand Up @@ -314,6 +318,10 @@ export default {
: t('A color with a HEX value {hex}', { hex: item.color }),
}))
},
uid() {
return GenRandomId()
},
},
watch: {
Expand Down Expand Up @@ -416,6 +424,9 @@ export default {
border: 1px solid rgba(0, 0, 0, 0.25);
border-radius: 50%;
font-size: 16px;
&:focus-within {
outline: 2px solid var(--color-main-text);
}
&:hover {
opacity: .6;
}
Expand Down

0 comments on commit c7c62e0

Please sign in to comment.