@@ -40,7 +40,7 @@ export type ButtonColor =
40
40
| 'primary_subtle'
41
41
| 'negative_subtle'
42
42
export type ButtonSize = 'tiny' | 'small' | 'large'
43
- export type ButtonShape = 'round' | 'square' | 'default'
43
+ export type ButtonShape = 'round' | 'square' | 'stacked' | ' default'
44
44
export type VariantProps = {
45
45
/**
46
46
* The style variation of the button
@@ -509,6 +509,25 @@ export const Button = React.forwardRef<View, ButtonProps>(
509
509
baseStyles . push ( a . rounded_sm )
510
510
}
511
511
}
512
+ } else if ( shape === 'stacked' ) {
513
+ if ( size === 'large' ) {
514
+ // not implemented
515
+ baseStyles . push ( { } )
516
+ } else if ( size === 'small' ) {
517
+ baseStyles . push ( {
518
+ height : 80 ,
519
+ paddingHorizontal : 22 ,
520
+ borderRadius : 24 ,
521
+ gap : 4 ,
522
+ } )
523
+ } else if ( size === 'tiny' ) {
524
+ baseStyles . push ( {
525
+ paddingVertical : 10 ,
526
+ paddingHorizontal : 16 ,
527
+ borderRadius : 16 ,
528
+ gap : 2 ,
529
+ } )
530
+ }
512
531
}
513
532
514
533
return {
@@ -523,9 +542,10 @@ export const Button = React.forwardRef<View, ButtonProps>(
523
542
variant,
524
543
color,
525
544
size,
545
+ shape,
526
546
disabled : disabled || false ,
527
547
} ) ,
528
- [ state , variant , color , size , disabled ] ,
548
+ [ state , variant , color , size , shape , disabled ] ,
529
549
)
530
550
531
551
const flattenedBaseStyles = flatten ( [ baseStyles , style ] )
@@ -545,7 +565,7 @@ export const Button = React.forwardRef<View, ButtonProps>(
545
565
disabled : disabled || false ,
546
566
} }
547
567
style = { [
548
- a . flex_row ,
568
+ shape !== 'stacked' ? a . flex_row : undefined ,
549
569
a . align_center ,
550
570
a . justify_center ,
551
571
a . curve_continuous ,
@@ -571,7 +591,7 @@ Button.displayName = 'Button'
571
591
572
592
export function useSharedButtonTextStyles ( ) {
573
593
const t = useTheme ( )
574
- const { color, variant, disabled, size} = useButtonContext ( )
594
+ const { color, variant, disabled, size, shape } = useButtonContext ( )
575
595
return React . useMemo ( ( ) => {
576
596
const baseStyles : TextStyle [ ] = [ ]
577
597
@@ -751,22 +771,29 @@ export function useSharedButtonTextStyles() {
751
771
}
752
772
753
773
if ( size === 'large' ) {
754
- baseStyles . push ( a . text_md , a . leading_snug , a . font_medium )
774
+ baseStyles . push ( a . text_md , a . leading_snug , a . font_semi_bold )
755
775
} else if ( size === 'small' ) {
756
- baseStyles . push ( a . text_sm , a . leading_snug , a . font_medium )
776
+ baseStyles . push ( a . text_sm , a . leading_snug , a . font_semi_bold )
757
777
} else if ( size === 'tiny' ) {
758
- baseStyles . push ( a . text_xs , a . leading_snug , a . font_medium )
778
+ baseStyles . push ( a . text_xs , a . leading_snug , a . font_semi_bold )
779
+ }
780
+
781
+ if ( shape === 'stacked' ) {
782
+ baseStyles . push ( a . leading_tight )
759
783
}
760
784
761
785
return StyleSheet . flatten ( baseStyles )
762
- } , [ t , variant , color , size , disabled ] )
786
+ } , [ t , variant , color , size , shape , disabled ] )
763
787
}
764
788
765
789
export function ButtonText ( { children, style, ...rest } : ButtonTextProps ) {
766
790
const textStyles = useSharedButtonTextStyles ( )
767
791
768
792
return (
769
- < Text { ...rest } style = { [ a . text_center , textStyles , style ] } >
793
+ < Text
794
+ { ...rest }
795
+ style = { [ a . text_center , textStyles , style ] }
796
+ numberOfLines = { 2 } >
770
797
{ children }
771
798
</ Text >
772
799
)
@@ -783,7 +810,7 @@ export function ButtonIcon({
783
810
position ?: 'left' | 'right'
784
811
size ?: SVGIconProps [ 'size' ]
785
812
} ) {
786
- const { size : buttonSize } = useButtonContext ( )
813
+ const { size : buttonSize , shape } = useButtonContext ( )
787
814
const textStyles = useSharedButtonTextStyles ( )
788
815
const { iconSize, iconContainerSize} = React . useMemo ( ( ) => {
789
816
/**
@@ -813,6 +840,20 @@ export function ButtonIcon({
813
840
'2xl' : 32 ,
814
841
} [ iconSizeShorthand ]
815
842
843
+ if ( shape === 'stacked' ) {
844
+ const stackedIconSize = size
845
+ ? iconSize
846
+ : {
847
+ tiny : 16 ,
848
+ small : 24 ,
849
+ large : 24 ,
850
+ } [ buttonSize || 'small' ]
851
+ return {
852
+ iconSize : stackedIconSize ,
853
+ iconContainerSize : stackedIconSize ,
854
+ }
855
+ }
856
+
816
857
/*
817
858
* Goal here is to match rendered text size so that different size icons
818
859
* don't increase button size
@@ -827,7 +868,7 @@ export function ButtonIcon({
827
868
iconSize,
828
869
iconContainerSize,
829
870
}
830
- } , [ buttonSize , size ] )
871
+ } , [ buttonSize , size , shape ] )
831
872
832
873
return (
833
874
< View
0 commit comments