Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
Button: Fix hover background-color
Browse files Browse the repository at this point in the history
This update fixes the Button V2 background-color for the hover state.
It was rendering as `undefined` due to an inproper `key` from the style
`config`.
  • Loading branch information
Jon Q committed Apr 9, 2019
1 parent 86af033 commit 5905ead
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/components/Button/Button.css.js
Expand Up @@ -240,7 +240,7 @@ export const config = {
},
}

export const makeButtonUI = (selector: 'button') => {
export const makeButtonUI = (selector = 'button') => {
return styled(selector)`
${baseStyles};
appearance: none;
Expand Down Expand Up @@ -311,18 +311,18 @@ export const makeButtonUI = (selector: 'button') => {
`
}

function makePrimaryStyles(name = 'primary', props: Object = {}): string {
function makePrimaryStyles(name = 'primary', props = {}) {
const theme = get(props, 'theme.brandColor', {})
const backgroundColor =
theme.backgroundColorUI || theme.brandColor || config[name].backgroundColor
const color =
theme.textColorInteractive || theme.brandTextColor || config[name].color

const backgroundColorHover =
theme.backgroundColorUIHover || config.backgroundColorHover
theme.backgroundColorUIHover || config[name].backgroundColorHover
const borderColorHover = backgroundColorHover
const backgroundColorActive =
theme.backgroundColorUIActive || config.backgroundColorActive
theme.backgroundColorUIActive || config[name].backgroundColorActive
const borderColorActive = backgroundColorActive

return makeButtonKindStyles(name, {
Expand All @@ -337,7 +337,7 @@ function makePrimaryStyles(name = 'primary', props: Object = {}): string {
})
}

function makeButtonKindStyles(kind: string, config: Object): string {
function makeButtonKindStyles(kind, config) {
return `
&.is-${kind} {
background: ${config.backgroundColor};
Expand Down Expand Up @@ -383,7 +383,7 @@ function makeButtonKindStyles(kind: string, config: Object): string {
`
}

function makeButtonStateStyles(config: Object, state: string): string {
function makeButtonStateStyles(config, state) {
if (!config.hasOwnProperty(state)) return ''

return `
Expand All @@ -406,19 +406,19 @@ function makeButtonStateStyles(config: Object, state: string): string {
`
}

function makeDangerStyles(config: Object): string {
function makeDangerStyles(config) {
return makeButtonStateStyles(config, 'danger')
}

function makeSuccessStyles(config: Object): string {
function makeSuccessStyles(config) {
return makeButtonStateStyles(config, 'success')
}

function makeWarningStyles(config: Object): string {
function makeWarningStyles(config) {
return makeButtonStateStyles(config, 'warning')
}

function makeDisabledStyles(content: string): string {
function makeDisabledStyles(content) {
return `
&.is-disabled,
&[disabled] {
Expand All @@ -429,7 +429,7 @@ function makeDisabledStyles(content: string): string {
`
}

function makeButtonSizeStyles(): string {
function makeButtonSizeStyles() {
return forEach(
config.size,
(size, props) => `
Expand All @@ -445,7 +445,7 @@ function makeButtonSizeStyles(): string {
)
}

function renderStyleForProp(config: Object, prop: string, attribute: ?string) {
function renderStyleForProp(config, prop, attribute) {
const attr = attribute || prop

return config.hasOwnProperty(prop)
Expand Down

0 comments on commit 5905ead

Please sign in to comment.