Fork base styles codepath to make variant deprecation more obvious
This commit is contained in:
+141
-126
@@ -205,8 +205,13 @@ export const Button = React.forwardRef<View, ButtonProps>(
|
|||||||
const baseStyles: ViewStyle[] = []
|
const baseStyles: ViewStyle[] = []
|
||||||
const hoverStyles: ViewStyle[] = []
|
const hoverStyles: ViewStyle[] = []
|
||||||
|
|
||||||
if (color === 'primary') {
|
/*
|
||||||
if (variant === 'solid') {
|
* This is the happy path for new button styles, following the
|
||||||
|
* deprecation of `variant` prop. This redundant `variant` check is here
|
||||||
|
* just to make this handling easier to understand.
|
||||||
|
*/
|
||||||
|
if (variant === 'solid') {
|
||||||
|
if (color === 'primary') {
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
baseStyles.push({
|
baseStyles.push({
|
||||||
backgroundColor: t.palette.primary_500,
|
backgroundColor: t.palette.primary_500,
|
||||||
@@ -223,64 +228,14 @@ export const Button = React.forwardRef<View, ButtonProps>(
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (variant === 'outline') {
|
} else if (color === 'secondary') {
|
||||||
baseStyles.push(a.border, t.atoms.bg, {
|
|
||||||
borderWidth: 1,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!disabled) {
|
|
||||||
baseStyles.push(a.border, {
|
|
||||||
borderColor: t.palette.primary_500,
|
|
||||||
})
|
|
||||||
hoverStyles.push(a.border, {
|
|
||||||
backgroundColor: t.palette.primary_50,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
baseStyles.push(a.border, {
|
|
||||||
borderColor: t.palette.primary_200,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if (variant === 'ghost') {
|
|
||||||
if (!disabled) {
|
|
||||||
baseStyles.push(t.atoms.bg)
|
|
||||||
hoverStyles.push({
|
|
||||||
backgroundColor: t.palette.primary_100,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (color === 'secondary') {
|
|
||||||
if (variant === 'solid') {
|
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
baseStyles.push(t.atoms.bg_contrast_25)
|
baseStyles.push(t.atoms.bg_contrast_25)
|
||||||
hoverStyles.push(t.atoms.bg_contrast_50)
|
hoverStyles.push(t.atoms.bg_contrast_50)
|
||||||
} else {
|
} else {
|
||||||
baseStyles.push(t.atoms.bg_contrast_100)
|
baseStyles.push(t.atoms.bg_contrast_100)
|
||||||
}
|
}
|
||||||
} else if (variant === 'outline') {
|
} else if (color === 'secondary_inverted') {
|
||||||
baseStyles.push(a.border, t.atoms.bg, {
|
|
||||||
borderWidth: 1,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!disabled) {
|
|
||||||
baseStyles.push(a.border, {
|
|
||||||
borderColor: t.palette.contrast_300,
|
|
||||||
})
|
|
||||||
hoverStyles.push(t.atoms.bg_contrast_50)
|
|
||||||
} else {
|
|
||||||
baseStyles.push(a.border, {
|
|
||||||
borderColor: t.palette.contrast_200,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if (variant === 'ghost') {
|
|
||||||
if (!disabled) {
|
|
||||||
baseStyles.push(t.atoms.bg)
|
|
||||||
hoverStyles.push({
|
|
||||||
backgroundColor: t.palette.contrast_25,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (color === 'secondary_inverted') {
|
|
||||||
if (variant === 'solid') {
|
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
baseStyles.push({
|
baseStyles.push({
|
||||||
backgroundColor: t.palette.contrast_900,
|
backgroundColor: t.palette.contrast_900,
|
||||||
@@ -293,31 +248,7 @@ export const Button = React.forwardRef<View, ButtonProps>(
|
|||||||
backgroundColor: t.palette.contrast_600,
|
backgroundColor: t.palette.contrast_600,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (variant === 'outline') {
|
} else if (color === 'negative') {
|
||||||
baseStyles.push(a.border, t.atoms.bg, {
|
|
||||||
borderWidth: 1,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!disabled) {
|
|
||||||
baseStyles.push(a.border, {
|
|
||||||
borderColor: t.palette.contrast_300,
|
|
||||||
})
|
|
||||||
hoverStyles.push(t.atoms.bg_contrast_50)
|
|
||||||
} else {
|
|
||||||
baseStyles.push(a.border, {
|
|
||||||
borderColor: t.palette.contrast_200,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if (variant === 'ghost') {
|
|
||||||
if (!disabled) {
|
|
||||||
baseStyles.push(t.atoms.bg)
|
|
||||||
hoverStyles.push({
|
|
||||||
backgroundColor: t.palette.contrast_25,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (color === 'negative') {
|
|
||||||
if (variant === 'solid') {
|
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
baseStyles.push({
|
baseStyles.push({
|
||||||
backgroundColor: t.palette.negative_500,
|
backgroundColor: t.palette.negative_500,
|
||||||
@@ -334,33 +265,7 @@ export const Button = React.forwardRef<View, ButtonProps>(
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (variant === 'outline') {
|
} else if (color === 'negative_secondary') {
|
||||||
baseStyles.push(a.border, t.atoms.bg, {
|
|
||||||
borderWidth: 1,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!disabled) {
|
|
||||||
baseStyles.push(a.border, {
|
|
||||||
borderColor: t.palette.negative_500,
|
|
||||||
})
|
|
||||||
hoverStyles.push(a.border, {
|
|
||||||
backgroundColor: t.palette.negative_50,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
baseStyles.push(a.border, {
|
|
||||||
borderColor: t.palette.negative_200,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if (variant === 'ghost') {
|
|
||||||
if (!disabled) {
|
|
||||||
baseStyles.push(t.atoms.bg)
|
|
||||||
hoverStyles.push({
|
|
||||||
backgroundColor: t.palette.negative_100,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (color === 'negative_secondary') {
|
|
||||||
if (variant === 'solid') {
|
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
baseStyles.push({
|
baseStyles.push({
|
||||||
backgroundColor: select(t.name, {
|
backgroundColor: select(t.name, {
|
||||||
@@ -385,31 +290,141 @@ export const Button = React.forwardRef<View, ButtonProps>(
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (variant === 'outline') {
|
}
|
||||||
baseStyles.push(a.border, t.atoms.bg, {
|
} else {
|
||||||
borderWidth: 1,
|
/*
|
||||||
})
|
* BEGIN DEPRECATED STYLES
|
||||||
|
*/
|
||||||
|
if (color === 'primary') {
|
||||||
|
if (variant === 'outline') {
|
||||||
|
baseStyles.push(a.border, t.atoms.bg, {
|
||||||
|
borderWidth: 1,
|
||||||
|
})
|
||||||
|
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
baseStyles.push(a.border, {
|
baseStyles.push(a.border, {
|
||||||
borderColor: t.palette.negative_500,
|
borderColor: t.palette.primary_500,
|
||||||
})
|
})
|
||||||
hoverStyles.push(a.border, {
|
hoverStyles.push(a.border, {
|
||||||
backgroundColor: t.palette.negative_50,
|
backgroundColor: t.palette.primary_50,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
baseStyles.push(a.border, {
|
baseStyles.push(a.border, {
|
||||||
borderColor: t.palette.negative_200,
|
borderColor: t.palette.primary_200,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
} else if (variant === 'ghost') {
|
||||||
|
if (!disabled) {
|
||||||
|
baseStyles.push(t.atoms.bg)
|
||||||
|
hoverStyles.push({
|
||||||
|
backgroundColor: t.palette.primary_100,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (variant === 'ghost') {
|
} else if (color === 'secondary') {
|
||||||
if (!disabled) {
|
if (variant === 'outline') {
|
||||||
baseStyles.push(t.atoms.bg)
|
baseStyles.push(a.border, t.atoms.bg, {
|
||||||
hoverStyles.push({
|
borderWidth: 1,
|
||||||
backgroundColor: t.palette.negative_100,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!disabled) {
|
||||||
|
baseStyles.push(a.border, {
|
||||||
|
borderColor: t.palette.contrast_300,
|
||||||
|
})
|
||||||
|
hoverStyles.push(t.atoms.bg_contrast_50)
|
||||||
|
} else {
|
||||||
|
baseStyles.push(a.border, {
|
||||||
|
borderColor: t.palette.contrast_200,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else if (variant === 'ghost') {
|
||||||
|
if (!disabled) {
|
||||||
|
baseStyles.push(t.atoms.bg)
|
||||||
|
hoverStyles.push({
|
||||||
|
backgroundColor: t.palette.contrast_25,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (color === 'secondary_inverted') {
|
||||||
|
if (variant === 'outline') {
|
||||||
|
baseStyles.push(a.border, t.atoms.bg, {
|
||||||
|
borderWidth: 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!disabled) {
|
||||||
|
baseStyles.push(a.border, {
|
||||||
|
borderColor: t.palette.contrast_300,
|
||||||
|
})
|
||||||
|
hoverStyles.push(t.atoms.bg_contrast_50)
|
||||||
|
} else {
|
||||||
|
baseStyles.push(a.border, {
|
||||||
|
borderColor: t.palette.contrast_200,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else if (variant === 'ghost') {
|
||||||
|
if (!disabled) {
|
||||||
|
baseStyles.push(t.atoms.bg)
|
||||||
|
hoverStyles.push({
|
||||||
|
backgroundColor: t.palette.contrast_25,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (color === 'negative') {
|
||||||
|
if (variant === 'outline') {
|
||||||
|
baseStyles.push(a.border, t.atoms.bg, {
|
||||||
|
borderWidth: 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!disabled) {
|
||||||
|
baseStyles.push(a.border, {
|
||||||
|
borderColor: t.palette.negative_500,
|
||||||
|
})
|
||||||
|
hoverStyles.push(a.border, {
|
||||||
|
backgroundColor: t.palette.negative_50,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
baseStyles.push(a.border, {
|
||||||
|
borderColor: t.palette.negative_200,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else if (variant === 'ghost') {
|
||||||
|
if (!disabled) {
|
||||||
|
baseStyles.push(t.atoms.bg)
|
||||||
|
hoverStyles.push({
|
||||||
|
backgroundColor: t.palette.negative_100,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (color === 'negative_secondary') {
|
||||||
|
if (variant === 'outline') {
|
||||||
|
baseStyles.push(a.border, t.atoms.bg, {
|
||||||
|
borderWidth: 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!disabled) {
|
||||||
|
baseStyles.push(a.border, {
|
||||||
|
borderColor: t.palette.negative_500,
|
||||||
|
})
|
||||||
|
hoverStyles.push(a.border, {
|
||||||
|
backgroundColor: t.palette.negative_50,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
baseStyles.push(a.border, {
|
||||||
|
borderColor: t.palette.negative_200,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else if (variant === 'ghost') {
|
||||||
|
if (!disabled) {
|
||||||
|
baseStyles.push(t.atoms.bg)
|
||||||
|
hoverStyles.push({
|
||||||
|
backgroundColor: t.palette.negative_100,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* END DEPRECATED STYLES
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shape === 'default') {
|
if (shape === 'default') {
|
||||||
|
|||||||
Reference in New Issue
Block a user