Skip to content

Commit d8701b7

Browse files
committed
fix(NcActionButtonGroup): Do not use icon but primary color to mark selected button
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 1954fbd commit d8701b7

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

src/components/NcActionButtonGroup/NcActionButtonGroup.vue

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,22 @@ This should be used sparingly for accessibility.
2929
<NcActions>
3030
<NcActionButtonGroup name="Text alignment">
3131
<NcActionButton aria-label="Align left"
32-
@click="showMessage('Align left')">
32+
:pressed="alignment === 'l'"
33+
@click="alignment = 'l'">
3334
<template #icon>
3435
<AlignLeft :size="20" />
3536
</template>
3637
</NcActionButton>
3738
<NcActionButton aria-label="Align center"
38-
@click="showMessage('Align center')">
39+
:pressed="alignment === 'c'"
40+
@click="alignment = 'c'">
3941
<template #icon>
4042
<AlignCenter :size="20" />
4143
</template>
4244
</NcActionButton>
4345
<NcActionButton aria-label="Align right"
44-
@click="showMessage('Align Right')">
46+
:pressed="alignment === 'r'"
47+
@click="alignment = 'r'">
4548
<template #icon>
4649
<AlignRight :size="20" />
4750
</template>
@@ -70,6 +73,9 @@ export default {
7073
AlignCenter,
7174
Plus,
7275
},
76+
data() {
77+
return { alignment: 'l' }
78+
},
7379
methods: {
7480
showMessage(msg) {
7581
alert(msg)
@@ -121,6 +127,7 @@ export default defineComponent({
121127
122128
ul.nc-button-group-content {
123129
display: flex;
130+
gap: 4px; // required for the focus-visible outline
124131
justify-content: space-between;
125132
li {
126133
flex: 1 1;
@@ -132,6 +139,20 @@ export default defineComponent({
132139
width: 100%;
133140
display: flex;
134141
justify-content: center;
142+
143+
&.action-button--active {
144+
background-color: var(--color-primary-element);
145+
border-radius: var(--border-radius-large);
146+
color: var(--color-primary-element-text);
147+
148+
&:hover, &:focus, &:focus-within {
149+
background-color: var(--color-primary-element-hover);
150+
}
151+
}
152+
153+
.action-button__pressed-icon {
154+
display: none;
155+
}
135156
}
136157
}
137158
}

0 commit comments

Comments
 (0)