Add StackedButton component (#9086)
This commit is contained in:
@@ -37,6 +37,7 @@ module.exports = {
|
||||
'Toast.Action',
|
||||
'AgeAssuranceAdmonition',
|
||||
'Span',
|
||||
'StackedButton',
|
||||
],
|
||||
impliedTextProps: [],
|
||||
suggestedTextWrappers: {
|
||||
|
||||
@@ -837,3 +837,47 @@ export function ButtonIcon({
|
||||
</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,
|
||||
type ButtonSize,
|
||||
ButtonText,
|
||||
StackedButton,
|
||||
} from '#/components/Button'
|
||||
import {ChevronLeft_Stroke2_Corner0_Rounded as ChevronLeft} from '#/components/icons/Chevron'
|
||||
import {Globe_Stroke2_Corner0_Rounded as Globe} from '#/components/icons/Globe'
|
||||
@@ -18,6 +19,30 @@ export function Buttons() {
|
||||
<View style={[a.gap_md]}>
|
||||
<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',
|
||||
'secondary',
|
||||
|
||||
Reference in New Issue
Block a user