Add StackedButton component
This commit is contained in:
@@ -37,6 +37,7 @@ module.exports = {
|
|||||||
'Toast.Action',
|
'Toast.Action',
|
||||||
'AgeAssuranceAdmonition',
|
'AgeAssuranceAdmonition',
|
||||||
'Span',
|
'Span',
|
||||||
|
'StackedButton',
|
||||||
],
|
],
|
||||||
impliedTextProps: [],
|
impliedTextProps: [],
|
||||||
suggestedTextWrappers: {
|
suggestedTextWrappers: {
|
||||||
|
|||||||
@@ -837,3 +837,47 @@ export function ButtonIcon({
|
|||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type StackedButtonProps = Omit<
|
||||||
|
ButtonProps,
|
||||||
|
keyof VariantProps | 'children'
|
||||||
|
> &
|
||||||
|
Pick<VariantProps, 'color'> & {
|
||||||
|
children: React.ReactNode
|
||||||
|
icon: React.ComponentType<SVGIconProps>
|
||||||
|
}
|
||||||
|
|
||||||
|
export function StackedButton({children, ...props}: StackedButtonProps) {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
{...props}
|
||||||
|
size="tiny"
|
||||||
|
style={[
|
||||||
|
a.flex_col,
|
||||||
|
{
|
||||||
|
height: 72,
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
borderRadius: 20,
|
||||||
|
gap: 4,
|
||||||
|
},
|
||||||
|
props.style,
|
||||||
|
]}>
|
||||||
|
<StackedButtonInnerText icon={props.icon}>
|
||||||
|
{children}
|
||||||
|
</StackedButtonInnerText>
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function StackedButtonInnerText({
|
||||||
|
children,
|
||||||
|
icon: Icon,
|
||||||
|
}: Pick<StackedButtonProps, 'icon' | 'children'>) {
|
||||||
|
const textStyles = useSharedButtonTextStyles()
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Icon width={24} fill={textStyles.color} />
|
||||||
|
<ButtonText>{children}</ButtonText>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
ButtonIcon,
|
ButtonIcon,
|
||||||
type ButtonSize,
|
type ButtonSize,
|
||||||
ButtonText,
|
ButtonText,
|
||||||
|
StackedButton,
|
||||||
} from '#/components/Button'
|
} from '#/components/Button'
|
||||||
import {ChevronLeft_Stroke2_Corner0_Rounded as ChevronLeft} from '#/components/icons/Chevron'
|
import {ChevronLeft_Stroke2_Corner0_Rounded as ChevronLeft} from '#/components/icons/Chevron'
|
||||||
import {Globe_Stroke2_Corner0_Rounded as Globe} from '#/components/icons/Globe'
|
import {Globe_Stroke2_Corner0_Rounded as Globe} from '#/components/icons/Globe'
|
||||||
@@ -18,6 +19,30 @@ export function Buttons() {
|
|||||||
<View style={[a.gap_md]}>
|
<View style={[a.gap_md]}>
|
||||||
<Text style={[a.font_bold, a.text_5xl]}>Buttons</Text>
|
<Text style={[a.font_bold, a.text_5xl]}>Buttons</Text>
|
||||||
|
|
||||||
|
<View style={[a.flex_row, a.gap_md, a.align_start, {maxWidth: 350}]}>
|
||||||
|
<StackedButton
|
||||||
|
label="stacked"
|
||||||
|
icon={Globe}
|
||||||
|
color="secondary"
|
||||||
|
style={[a.flex_1]}>
|
||||||
|
Bop it
|
||||||
|
</StackedButton>
|
||||||
|
<StackedButton
|
||||||
|
label="stacked"
|
||||||
|
icon={Globe}
|
||||||
|
color="negative_subtle"
|
||||||
|
style={[a.flex_1]}>
|
||||||
|
Twist it
|
||||||
|
</StackedButton>
|
||||||
|
<StackedButton
|
||||||
|
label="stacked"
|
||||||
|
icon={Globe}
|
||||||
|
color="primary"
|
||||||
|
style={[a.flex_1]}>
|
||||||
|
Pull it
|
||||||
|
</StackedButton>
|
||||||
|
</View>
|
||||||
|
|
||||||
{[
|
{[
|
||||||
'primary',
|
'primary',
|
||||||
'secondary',
|
'secondary',
|
||||||
|
|||||||
Reference in New Issue
Block a user