Skip to content

Commit 9c4db56

Browse files
committed
match js button hover color logic exactly
1 parent 98d70bf commit 9c4db56

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/button.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { forwardRef, cloneElement } from 'react'
22
import { Box, BoxProps, ThemeUIStyleObject } from 'theme-ui'
33
import Link, { LinkProps } from './link'
44
import getSizeStyles from './utils/get-size-styles'
5-
import getSxColor from './utils/get-sx-color'
65

76
const hasHoverProp = (comp: unknown): comp is { hover: ThemeUIStyleObject } => {
87
if (comp == null) return false
@@ -54,12 +53,12 @@ const Button = (
5453
throw new Error('Size must be xs, sm, md, lg, or xl')
5554
}
5655

57-
const defaultColor = inverted ? 'secondary' : 'primary'
58-
const baseColor = getSxColor(sx, defaultColor)
59-
const hoverColor =
60-
baseColor !== defaultColor || inverted ? 'primary' : 'secondary'
61-
const { color: _, ...sxProp } =
56+
const { color: sxColor, ...sxProp } =
6257
sx && typeof sx === 'object' ? (sx as Record<string, unknown>) : {}
58+
const baseColor =
59+
(typeof sxColor === 'string' && sxColor) ||
60+
(inverted ? 'secondary' : 'primary')
61+
const hoverColor = sxColor ? 'primary' : inverted ? 'primary' : 'secondary'
6362

6463
const sizeConfig = {
6564
xs: {

0 commit comments

Comments
 (0)