Deprecate 'variant' in favor of 'color'
This commit is contained in:
@@ -31,6 +31,7 @@ export type ButtonShape = 'round' | 'square' | 'default'
|
|||||||
export type VariantProps = {
|
export type VariantProps = {
|
||||||
/**
|
/**
|
||||||
* The style variation of the button
|
* The style variation of the button
|
||||||
|
* @deprecated Use `color` instead.
|
||||||
*/
|
*/
|
||||||
variant?: ButtonVariant
|
variant?: ButtonVariant
|
||||||
/**
|
/**
|
||||||
@@ -123,6 +124,15 @@ export const Button = React.forwardRef<View, ButtonProps>(
|
|||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
) => {
|
) => {
|
||||||
|
/**
|
||||||
|
* The `variant` prop is deprecated in favor of simply specifying `color`.
|
||||||
|
* If a `color` is set, then we want to use the existing codepaths for
|
||||||
|
* "solid" buttons. This is to maintain backwards compatibility.
|
||||||
|
*/
|
||||||
|
if (!variant && color) {
|
||||||
|
variant = 'solid'
|
||||||
|
}
|
||||||
|
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const [state, setState] = React.useState({
|
const [state, setState] = React.useState({
|
||||||
pressed: false,
|
pressed: false,
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ function StorybookInner() {
|
|||||||
<>
|
<>
|
||||||
<View style={[a.flex_row, a.align_start, a.gap_md]}>
|
<View style={[a.flex_row, a.align_start, a.gap_md]}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
|
||||||
color="primary"
|
color="primary"
|
||||||
size="small"
|
size="small"
|
||||||
label='Set theme to "system"'
|
label='Set theme to "system"'
|
||||||
@@ -60,7 +59,6 @@ function StorybookInner() {
|
|||||||
<ButtonText>System</ButtonText>
|
<ButtonText>System</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="small"
|
size="small"
|
||||||
label='Set theme to "light"'
|
label='Set theme to "light"'
|
||||||
@@ -68,7 +66,6 @@ function StorybookInner() {
|
|||||||
<ButtonText>Light</ButtonText>
|
<ButtonText>Light</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="small"
|
size="small"
|
||||||
label='Set theme to "dim"'
|
label='Set theme to "dim"'
|
||||||
@@ -79,7 +76,6 @@ function StorybookInner() {
|
|||||||
<ButtonText>Dim</ButtonText>
|
<ButtonText>Dim</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="small"
|
size="small"
|
||||||
label='Set theme to "dark"'
|
label='Set theme to "dark"'
|
||||||
@@ -94,7 +90,6 @@ function StorybookInner() {
|
|||||||
<Buttons />
|
<Buttons />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
color="primary"
|
color="primary"
|
||||||
size="small"
|
size="small"
|
||||||
onPress={() => navigation.navigate('SharedPreferencesTester')}
|
onPress={() => navigation.navigate('SharedPreferencesTester')}
|
||||||
@@ -129,7 +124,6 @@ function StorybookInner() {
|
|||||||
<Settings />
|
<Settings />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
color="primary"
|
color="primary"
|
||||||
size="large"
|
size="large"
|
||||||
label="Switch to Contained List"
|
label="Switch to Contained List"
|
||||||
@@ -140,7 +134,6 @@ function StorybookInner() {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
color="primary"
|
color="primary"
|
||||||
size="large"
|
size="large"
|
||||||
label="Switch to Storybook"
|
label="Switch to Storybook"
|
||||||
|
|||||||
Reference in New Issue
Block a user