Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
'Toast.Action',
'AgeAssuranceAdmonition',
'Span',
'StackedButton',
],
impliedTextProps: [],
suggestedTextWrappers: {
Expand Down
44 changes: 44 additions & 0 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@
)

const {baseStyles, hoverStyles} = React.useMemo(() => {
const baseStyles: ViewStyle[] = []

Check warning on line 219 in src/components/Button.tsx

View workflow job for this annotation

GitHub Actions / Run linters

'baseStyles' is already declared in the upper scope on line 218 column 12
const hoverStyles: ViewStyle[] = []

Check warning on line 220 in src/components/Button.tsx

View workflow job for this annotation

GitHub Actions / Run linters

'hoverStyles' is already declared in the upper scope on line 218 column 24

/*
* This is the happy path for new button styles, following the
Expand Down Expand Up @@ -772,7 +772,7 @@
* Copied here from icons/common.tsx so we can tweak if we need to, but
* also so that we can calculate transforms.
*/
const iconSize = {

Check warning on line 775 in src/components/Button.tsx

View workflow job for this annotation

GitHub Actions / Run linters

'iconSize' is already declared in the upper scope on line 756 column 10
xs: 12,
sm: 16,
md: 18,
Expand All @@ -785,7 +785,7 @@
* Goal here is to match rendered text size so that different size icons
* don't increase button size
*/
const iconContainerSize = {

Check warning on line 788 in src/components/Button.tsx

View workflow job for this annotation

GitHub Actions / Run linters

'iconContainerSize' is already declared in the upper scope on line 756 column 20
large: 20,
small: 17,
tiny: 15,
Expand Down Expand Up @@ -837,3 +837,47 @@
</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>
</>
)
}
25 changes: 25 additions & 0 deletions src/view/screens/Storybook/Buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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',
Expand Down
Loading