Skip to content

Commit 6daa77b

Browse files
authored
Merge pull request #42636 from nextcloud/fix/core/42596/fix-button-accessibility-in-view-profile-page
enh(core): replaced previous native a element with NcButton
2 parents d72db91 + 707c1c0 commit 6daa77b

3 files changed

Lines changed: 27 additions & 49 deletions

File tree

core/src/components/Profile/PrimaryActionButton.vue

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,33 @@
2121
-->
2222

2323
<template>
24-
<a class="profile__primary-action-button"
25-
:class="{ 'disabled': disabled }"
24+
<NcButton type="primary"
2625
:href="href"
26+
alignment="center"
2727
:target="target"
28-
rel="noopener noreferrer nofollow"
29-
v-on="$listeners">
30-
<img class="icon"
31-
:class="[icon, { 'icon-invert': colorPrimaryText === '#ffffff' }]"
32-
:src="icon">
28+
:disabled="disabled">
29+
<template #icon>
30+
<img class="icon"
31+
aria-hidden="true"
32+
:src="icon"
33+
alt="">
34+
</template>
3335
<slot />
34-
</a>
36+
</NcButton>
3537
</template>
3638

3739
<script>
38-
export default {
40+
import { defineComponent } from 'vue'
41+
import { NcButton } from '@nextcloud/vue'
42+
import { translate as t } from '@nextcloud/l10n'
43+
44+
export default defineComponent({
3945
name: 'PrimaryActionButton',
4046
47+
components: {
48+
NcButton,
49+
},
50+
4151
props: {
4252
disabled: {
4353
type: Boolean,
@@ -58,46 +68,14 @@ export default {
5868
},
5969
},
6070
61-
computed: {
62-
colorPrimaryText() {
63-
// For some reason the returned string has prepended whitespace
64-
return getComputedStyle(document.body).getPropertyValue('--color-primary-element-text').trim()
65-
},
71+
methods: {
72+
t,
6673
},
67-
}
74+
})
6875
</script>
6976

7077
<style lang="scss" scoped>
71-
.profile__primary-action-button {
72-
font-size: var(--default-font-size);
73-
font-weight: bold;
74-
width: 188px;
75-
height: 44px;
76-
padding: 0 16px;
77-
line-height: 44px;
78-
text-align: center;
79-
border-radius: var(--border-radius-pill);
80-
color: var(--color-primary-element-text);
81-
background-color: var(--color-primary-element);
82-
overflow: hidden;
83-
white-space: nowrap;
84-
text-overflow: ellipsis;
85-
86-
.icon {
87-
display: inline-block;
88-
vertical-align: middle;
89-
margin-bottom: 2px;
90-
margin-right: 4px;
91-
92-
&.icon-invert {
93-
filter: invert(1);
94-
}
95-
}
96-
97-
&:hover,
98-
&:focus,
99-
&:active {
100-
background-color: var(--color-primary-element-light);
101-
}
78+
.icon {
79+
filter: var(--primary-invert-if-dark);
10280
}
10381
</style>

0 commit comments

Comments
 (0)