</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"
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'
Check,
Close,
ImageEdit,
+ NcButton,
NcColorPicker,
},
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;
border-color: var(--color-border);
}
- &__color {
- color: var(--color-primary-text);
- background-color: var(--color-primary-default);
- }
-
// Over a background image
&__default,
&__shipped {
*/
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'
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')
})
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')
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
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