Skip to content

Commit

Permalink
fix(theming): Add aria-pressed attribute to active background
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Oct 17, 2023
1 parent ff76e25 commit 8d57cdc
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 26 deletions.
6 changes: 4 additions & 2 deletions apps/theming/src/UserThemes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
<NcSettingsSection :name="t('theming', 'Appearance and accessibility')"
:limit-width="false"
class="theming">
<!-- eslint-disable-next-line vue/no-v-html -->
<p v-html="description" />
<!-- eslint-disable-next-line vue/no-v-html -->
<p v-html="descriptionDetail" />

<div class="theming__preview-list">
Expand Down Expand Up @@ -133,7 +135,7 @@ export default {
// using the `t` replace method escape html, we have to do it manually :/
return t(
'theming',
'Universal access is very important to us. We follow web standards and check to make everything usable also without mouse, and assistive software such as screenreaders. We aim to be compliant with the {guidelines}Web Content Accessibility Guidelines{linkend} 2.1 on AA level, with the high contrast theme even on AAA level.'
'Universal access is very important to us. We follow web standards and check to make everything usable also without mouse, and assistive software such as screenreaders. We aim to be compliant with the {guidelines}Web Content Accessibility Guidelines{linkend} 2.1 on AA level, with the high contrast theme even on AAA level.',
)
.replace('{guidelines}', this.guidelinesLink)
.replace('{linkend}', '</a>')
Expand All @@ -146,7 +148,7 @@ export default {
descriptionDetail() {
return t(
'theming',
'If you find any issues, do not hesitate to report them on {issuetracker}our issue tracker{linkend}. And if you want to get involved, come join {designteam}our design team{linkend}!'
'If you find any issues, do not hesitate to report them on {issuetracker}our issue tracker{linkend}. And if you want to get involved, come join {designteam}our design team{linkend}!',
)
.replace('{issuetracker}', this.issuetrackerLink)
.replace('{designteam}', this.designteamLink)
Expand Down
31 changes: 23 additions & 8 deletions apps/theming/src/components/BackgroundSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
<template>
<div class="background-selector" data-user-theming-background-settings>
<!-- Custom background -->
<button class="background background__filepicker"
:class="{ 'icon-loading': loading === 'custom', 'background--active': backgroundImage === 'custom' }"
<button :aria-pressed="backgroundImage === 'custom'"
:class="{
'icon-loading': loading === 'custom',
'background background__filepicker': true,
'background--active': backgroundImage === 'custom'
}"
:data-color-bright="invertTextColor(Theming.color)"
data-user-theming-background-custom
tabindex="0"
Expand All @@ -38,8 +42,12 @@
</button>

<!-- Default background -->
<button class="background background__default"
:class="{ 'icon-loading': loading === 'default', 'background--active': backgroundImage === 'default' }"
<button :aria-pressed="backgroundImage === 'default'"
:class="{
'icon-loading': loading === 'default',
'background background__default': true,
'background--active': backgroundImage === 'default'
}"
:data-color-bright="invertTextColor(Theming.defaultColor)"
:style="{ '--border-color': Theming.defaultColor }"
data-user-theming-background-default
Expand All @@ -62,8 +70,11 @@
</NcColorPicker>

<!-- Remove background -->
<button class="background background__delete"
:class="{ 'background--active': isBackgroundDisabled }"
<button :aria-pressed="isBackgroundDisabled"
:class="{
'background background__delete': true,
'background--active': isBackgroundDisabled
}"
data-user-theming-background-clear
tabindex="0"
@click="removeBackground">
Expand All @@ -77,11 +88,15 @@
:key="shippedBackground.name"
:title="shippedBackground.details.attribution"
:aria-label="shippedBackground.details.attribution"
:class="{ 'icon-loading': loading === shippedBackground.name, 'background--active': backgroundImage === shippedBackground.name }"
:aria-pressed="backgroundImage === shippedBackground.name"
:class="{
'background background__shipped': true,
'icon-loading': loading === shippedBackground.name,
'background--active': backgroundImage === shippedBackground.name
}"
:data-color-bright="shippedBackground.details.theming === 'dark'"
:data-user-theming-background-shipped="shippedBackground.name"
:style="{ backgroundImage: 'url(' + shippedBackground.preview + ')', '--border-color': shippedBackground.details.primary_color }"
class="background background__shipped"
tabindex="0"
@click="setShipped(shippedBackground.name)">
<Check :size="44" />
Expand Down
36 changes: 29 additions & 7 deletions cypress/e2e/theming/user-background.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ describe('User default background settings', function() {

it('See the user background settings', function() {
cy.visit('/settings/user/theming')
cy.get('[data-user-theming-background-settings]').scrollIntoView().should('be.visible')
cy.get('[data-user-theming-background-settings]').scrollIntoView()
cy.get('[data-user-theming-background-settings]').should('be.visible')
})

// Default cloud background is not rendered if admin theming background remains unchanged
Expand All @@ -50,6 +51,10 @@ describe('User default background settings', function() {
cy.get('[data-user-theming-background-default]').should('be.visible')
cy.get('[data-user-theming-background-default]').should('have.class', 'background--active')
})

it('Default background has accessibility attribute set', function() {
cy.get('[data-user-theming-background-default]').should('have.attr', 'aria-pressed', 'true')
})
})

describe('User select shipped backgrounds and remove background', function() {
Expand All @@ -61,7 +66,8 @@ describe('User select shipped backgrounds and remove background', function() {

it('See the user background settings', function() {
cy.visit('/settings/user/theming')
cy.get('[data-user-theming-background-settings]').scrollIntoView().should('be.visible')
cy.get('[data-user-theming-background-settings]').scrollIntoView()
cy.get('[data-user-theming-background-settings]').should('be.visible')
})

it('Select a shipped background', function() {
Expand All @@ -71,6 +77,9 @@ describe('User select shipped backgrounds and remove background', function() {
// Select background
cy.get(`[data-user-theming-background-shipped="${background}"]`).click()

// Set the accessibility state
cy.get(`[data-user-theming-background-shipped="${background}"]`).should('have.attr', 'aria-pressed', 'true')

// Validate changed background and primary
cy.wait('@setBackground')
cy.waitUntil(() => validateBodyThemingCss('#a53c17', background))
Expand All @@ -83,9 +92,12 @@ describe('User select shipped backgrounds and remove background', function() {
// Select background
cy.get(`[data-user-theming-background-shipped="${background}"]`).click()

// Set the accessibility state
cy.get(`[data-user-theming-background-shipped="${background}"]`).should('have.attr', 'aria-pressed', 'true')

// Validate changed background and primary
cy.wait('@setBackground')
cy.waitUntil(() => validateBodyThemingCss('#56633d', background, true))
cy.waitUntil(() => validateBodyThemingCss('#56633d', background))
})

it('Remove background', function() {
Expand All @@ -94,6 +106,9 @@ describe('User select shipped backgrounds and remove background', function() {
// Clear background
cy.get('[data-user-theming-background-clear]').click()

// Set the accessibility state
cy.get('[data-user-theming-background-clear]').should('have.attr', 'aria-pressed', 'true')

// Validate clear background
cy.wait('@clearBackground')
cy.waitUntil(() => validateBodyThemingCss('#56633d', ''))
Expand All @@ -109,7 +124,8 @@ describe('User select a custom color', function() {

it('See the user background settings', function() {
cy.visit('/settings/user/theming')
cy.get('[data-user-theming-background-settings]').scrollIntoView().should('be.visible')
cy.get('[data-user-theming-background-settings]').scrollIntoView()
cy.get('[data-user-theming-background-settings]').should('be.visible')
})

it('Select a custom color', function() {
Expand All @@ -135,7 +151,8 @@ describe('User select a bright custom color and remove background', function() {

it('See the user background settings', function() {
cy.visit('/settings/user/theming')
cy.get('[data-user-theming-background-settings]').scrollIntoView().should('be.visible')
cy.get('[data-user-theming-background-settings]').scrollIntoView()
cy.get('[data-user-theming-background-settings]').should('be.visible')
})

it('Remove background', function() {
Expand Down Expand Up @@ -204,7 +221,8 @@ describe('User select a custom background', function() {

it('See the user background settings', function() {
cy.visit('/settings/user/theming')
cy.get('[data-user-theming-background-settings]').scrollIntoView().should('be.visible')
cy.get('[data-user-theming-background-settings]').scrollIntoView()
cy.get('[data-user-theming-background-settings]').should('be.visible')
})

it('Select a custom background', function() {
Expand Down Expand Up @@ -243,7 +261,8 @@ describe('User changes settings and reload the page', function() {

it('See the user background settings', function() {
cy.visit('/settings/user/theming')
cy.get('[data-user-theming-background-settings]').scrollIntoView().should('be.visible')
cy.get('[data-user-theming-background-settings]').scrollIntoView()
cy.get('[data-user-theming-background-settings]').should('be.visible')
})

it('Select a custom background', function() {
Expand Down Expand Up @@ -283,5 +302,8 @@ describe('User changes settings and reload the page', function() {
it('Reload the page and validate persistent changes', function() {
cy.reload()
cy.waitUntil(() => validateBodyThemingCss(selectedColor, 'apps/theming/background?v='))

// validate accessibility state
cy.get('[data-user-theming-background-custom]').should('have.attr', 'aria-pressed', 'true')
})
})
4 changes: 2 additions & 2 deletions dist/614-614.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/614-614.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-unsupported-browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-unsupported-browser.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/theming-personal-theming.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/theming-personal-theming.js.map

Large diffs are not rendered by default.

0 comments on commit 8d57cdc

Please sign in to comment.