Skip to content

Commit bd56fb2

Browse files
authored
1 parent f7ca38a commit bd56fb2

9 files changed

Lines changed: 22 additions & 1 deletion
3.27 KB
Loading
Loading
6.86 KB
Loading
Loading
Loading
Loading

src/__stories__/fixed-footer-layout-story.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,20 @@ const useTextLines = (): [Array<string>, () => void, () => void] => {
3333

3434
export const FooterWithButtonsOnly: StoryComponent = () => {
3535
const [isFooterVisible, isFooterVisibleCheckbox] = useCheckbox('isFooterVisible', true);
36+
const [footerScrollEffect, footerScrollEffectCheckbox] = useCheckbox('footerScrollEffect', true);
3637
const [textLines, loadMoreText, loadLessText] = useTextLines();
3738
return (
3839
<ButtonFixedFooterLayout
3940
button={<ButtonPrimary onPress={loadMoreText}>Load more text</ButtonPrimary>}
4041
secondaryButton={<ButtonSecondary onPress={loadLessText}>Load less text</ButtonSecondary>}
4142
isFooterVisible={isFooterVisible}
43+
footerScrollEffect={footerScrollEffect}
4244
>
4345
<ResponsiveLayout>
4446
<Box paddingY={16}>
4547
<Stack space={16}>
4648
{isFooterVisibleCheckbox}
49+
{footerScrollEffectCheckbox}
4750
{textLines.map((line, idx) => (
4851
<Text2 regular key={idx}>
4952
{line}
@@ -62,6 +65,7 @@ FooterWithButtonsOnly.parameters = {fullScreen: true};
6265
export const MoreComplexFooter: StoryComponent = () => {
6366
const [textLines, loadMoreText] = useTextLines();
6467
const [isFooterVisible, isFooterVisibleCheckbox] = useCheckbox('isFooterVisible', true);
68+
const [footerScrollEffect, footerScrollEffectCheckbox] = useCheckbox('footerScrollEffect', true);
6569
return (
6670
<FixedFooterLayout
6771
footer={
@@ -77,10 +81,12 @@ export const MoreComplexFooter: StoryComponent = () => {
7781
</ResponsiveLayout>
7882
}
7983
isFooterVisible={isFooterVisible}
84+
footerScrollEffect={footerScrollEffect}
8085
>
8186
<ResponsiveLayout>
8287
<Stack space={16}>
8388
{isFooterVisibleCheckbox}
89+
{footerScrollEffectCheckbox}
8490
<Text2 regular as="p">
8591
When you need a more elaborated thing for your footer (not just buttons), you can use
8692
FixedFooterLayout instead of ButtonFixedFooterLayout

src/button-fixed-footer-layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Props = {
1616
containerBgColor?: string;
1717
children: React.ReactNode;
1818
onChangeFooterHeight?: (heightInPx: number) => void;
19+
footerScrollEffect?: boolean;
1920
};
2021

2122
const ButtonFixedFooterLayout = ({
@@ -27,6 +28,7 @@ const ButtonFixedFooterLayout = ({
2728
footerBgColor,
2829
containerBgColor,
2930
onChangeFooterHeight,
31+
footerScrollEffect,
3032
}: Props): JSX.Element => {
3133
const hasButton = !!button || !!secondaryButton;
3234
return (
@@ -35,6 +37,7 @@ const ButtonFixedFooterLayout = ({
3537
isFooterVisible={hasButton && isFooterVisible}
3638
footerBgColor={footerBgColor}
3739
containerBgColor={containerBgColor}
40+
footerScrollEffect={footerScrollEffect}
3841
footer={
3942
<InternalResponsiveLayout shouldExpandWhenNested="desktop">
4043
<Box

src/fixed-footer-layout.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ type Props = {
4343
containerBgColor?: string;
4444
children: React.ReactNode;
4545
onChangeFooterHeight?: (heightInPx: number) => void;
46+
/**
47+
* @default true
48+
* When enabled an elevation will be displayed on the footer if it is fixed and there is scrollable content below it. Notice this layout is not fixed on Desktop.
49+
*/
50+
footerScrollEffect?: boolean;
4651
};
4752

4853
const MIN_AVAILABLE_HEIGHT_FOR_FIXED = 200;
@@ -56,6 +61,7 @@ const FixedFooterLayout = ({
5661
containerBgColor = vars.colors.background,
5762
children,
5863
onChangeFooterHeight,
64+
footerScrollEffect = true,
5965
}: Props): JSX.Element => {
6066
const [displayElevation, setDisplayElevation] = React.useState(false);
6167
const containerRef = React.useRef<HTMLDivElement>(null);
@@ -80,7 +86,12 @@ const FixedFooterLayout = ({
8086
* There is no elevation in desktop devices and we don't display it in acceptance tests or when the
8187
* content's height is too small, so we avoid unnecesary calculations in these cases.
8288
*/
83-
if (!isTabletOrSmaller || isRunningAcceptanceTest(platformOverrides) || !isFooterFixed) {
89+
if (
90+
!footerScrollEffect ||
91+
!isTabletOrSmaller ||
92+
isRunningAcceptanceTest(platformOverrides) ||
93+
!isFooterFixed
94+
) {
8495
setDisplayElevation(false);
8596
return;
8697
}
@@ -112,6 +123,7 @@ const FixedFooterLayout = ({
112123
platformOverrides,
113124
isTabletOrSmaller,
114125
isFooterFixed,
126+
footerScrollEffect,
115127
// `topDistance` and `contentHeight` dependencies are needed to recalculate the elevation state
116128
topDistance,
117129
contentHeight,

0 commit comments

Comments
 (0)