Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(theming): change color button contrast on user settings
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Jan 24, 2024
commit 1112b9e9a571828d908119c2401237c3cb37d1b3
37 changes: 22 additions & 15 deletions apps/theming/src/components/BackgroundSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@
</button>

<!-- Custom color picker -->
<NcColorPicker v-model="Theming.color" @input="debouncePickColor">
<button class="background background__color"
:data-color="Theming.color"
:data-color-bright="invertTextColor(Theming.color)"
:style="{ backgroundColor: Theming.color, '--border-color': Theming.color}"
data-user-theming-background-color
tabindex="0">
{{ t('theming', 'Change color') }}
</button>
</NcColorPicker>
<div class="background-color"
data-user-theming-background-color>
<NcColorPicker v-model="Theming.color"
@input="debouncePickColor">
<NcButton type="ternary">
{{ t('theming', 'Change color') }}
</NcButton>
</NcColorPicker>
</div>

<!-- Remove background -->
<button :aria-pressed="isBackgroundDisabled"
Expand Down Expand Up @@ -113,6 +112,7 @@ import { Palette } from 'node-vibrant/lib/color.js'
import axios from '@nextcloud/axios'
import debounce from 'debounce'
import NcColorPicker from '@nextcloud/vue/dist/Components/NcColorPicker.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import Vibrant from 'node-vibrant'

import Check from 'vue-material-design-icons/Check.vue'
Expand All @@ -133,6 +133,7 @@ export default {
Check,
Close,
ImageEdit,
NcButton,
NcColorPicker,
},

Expand Down Expand Up @@ -341,6 +342,17 @@ export default {
flex-wrap: wrap;
justify-content: center;

.background-color {
display: flex;
justify-content: center;
align-items: center;
width: 176px;
height: 96px;
margin: 8px;
border-radius: var(--border-radius-large);
background-color: var(--color-primary);
}

.background {
overflow: hidden;
width: 176px;
Expand Down Expand Up @@ -368,11 +380,6 @@ export default {
border-color: var(--color-border);
}

&__color {
color: var(--color-primary-text);
background-color: var(--color-primary-default);
}

// Over a background image
&__default,
&__shipped {
Expand Down
12 changes: 6 additions & 6 deletions cypress/e2e/theming/themingUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ export const validateBodyThemingCss = function(expectedColor = defaultPrimary, e
*/
export const validateUserThemingDefaultCss = function(expectedColor = defaultPrimary, expectedBackground: string|null = defaultBackground) {
const defaultSelectButton = Cypress.$('[data-user-theming-background-default]')
const customColorSelectButton = Cypress.$('[data-user-theming-background-color]')
if (defaultSelectButton.length === 0 || customColorSelectButton.length === 0) {
const customColor = Cypress.$('[data-user-theming-background-color]')
if (defaultSelectButton.length === 0 || customColor.length === 0) {
return false
}

const defaultOptionBackground = defaultSelectButton.css('background-image')
const colorPickerOptionColor = customColorSelectButton.css('background-color')
const colorPickerOptionColor = customColor.css('background-color')

const isValidBackgroundImage = !expectedBackground
? defaultOptionBackground === 'none'
Expand All @@ -71,15 +71,15 @@ export const validateUserThemingDefaultCss = function(expectedColor = defaultPri
return isValidBackgroundImage && colord(colorPickerOptionColor).isEqual(expectedColor)
}

export const pickRandomColor = function(pickerSelector: string): Cypress.Chainable<string> {
export const pickRandomColor = function(): Cypress.Chainable<string> {
// Pick one of the first 8 options
const randColour = Math.floor(Math.random() * 8)

// Open picker
cy.get(pickerSelector).click()
cy.get('button').contains('Change color').click()

// Return selected colour
return cy.get(pickerSelector).get('.color-picker__simple-color-circle').eq(randColour).then(($el) => {
return cy.get('.color-picker__simple-color-circle').eq(randColour).then(($el) => {
$el.trigger('click')
return $el.css('background-color')
})
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/theming/user-background.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('User select a custom color', function() {
it('Select a custom color', function() {
cy.intercept('*/apps/theming/background/color').as('setColor')

pickRandomColor('[data-user-theming-background-color]')
pickRandomColor()

// Validate custom colour change
cy.wait('@setColor')
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('User select a bright custom color and remove background', function() {
cy.intercept('*/apps/theming/background/color').as('setColor')

// Pick one of the bright color preset
cy.get('[data-user-theming-background-color]').click()
cy.get('button').contains('Change color').click()
cy.get('.color-picker__simple-color-circle:eq(4)').click()

// Validate custom colour change
Expand Down Expand Up @@ -286,7 +286,7 @@ describe('User changes settings and reload the page', function() {
it('Select a custom color', function() {
cy.intercept('*/apps/theming/background/color').as('setColor')

cy.get('[data-user-theming-background-color]').click()
cy.get('button').contains('Change color').click()
cy.get('.color-picker__simple-color-circle:eq(5)').click()

// Validate clear background
Expand Down