Skip to content

Commit

Permalink
feat: StickyFooter 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
hanyugeon committed Aug 6, 2024
1 parent 4aefc19 commit cd95748
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 51 deletions.
23 changes: 0 additions & 23 deletions src/components/common/BottomActionButton.tsx

This file was deleted.

44 changes: 44 additions & 0 deletions src/components/common/StickyFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { useMemo } from 'react';

type Direction = 'row' | 'column';

type StickyFooterProps = {
children?: React.ReactNode;
direction?: Direction;
className?: string;
};

const getDirectionClass = (direction: Direction) => {
switch (direction) {
case 'row': {
return 'flex-row';
}
case 'column': {
return 'flex-col';
}
}
};

const BASE_STICKY_FOOTER_CLASSES =
'fixed bottom-0 left-0 right-0 z-10 mx-auto flex w-full max-w-[43rem] gap-[0.8rem] bg-white px-[2.0rem] pb-[calc(env(safe-area-inset-bottom)+1.5rem)] pt-[1.5rem]';

const StickyFooter = ({
children,
direction = 'row',
className,
}: StickyFooterProps) => {
const directionClass = useMemo(
() => getDirectionClass(direction),
[direction]
);

return (
<footer
className={`${BASE_STICKY_FOOTER_CLASSES} ${directionClass} ${className}`}
>
{children}
</footer>
);
};

export default StickyFooter;
28 changes: 0 additions & 28 deletions src/stories/common/BottomActionButton.stories.tsx

This file was deleted.

55 changes: 55 additions & 0 deletions src/stories/common/StickyFooter.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Button from '@/components/common/Button';
import StickyFooter from '@/components/common/StickyFooter';
import { Meta, StoryObj } from '@storybook/react';

const meta: Meta<typeof StickyFooter> = {
title: 'Common/StickyFooter',
component: StickyFooter,
tags: ['autodocs'],
parameters: {
docs: {
story: {
inline: false,
},
},
},
};

export default meta;

type Story = StoryObj<typeof StickyFooter>;

export const Default: Story = {
args: {},
render: () => (
<StickyFooter>
<Button size="full" onClick={() => alert('click!')}>
다음
</Button>
</StickyFooter>
),
};

export const Row: Story = {
args: { direction: 'row' },
render: args => (
<StickyFooter {...args}>
<Button size="full">1</Button>
<Button size="full" colorScheme="grey">
2
</Button>
</StickyFooter>
),
};

export const Column: Story = {
args: { direction: 'column' },
render: args => (
<StickyFooter {...args}>
<Button size="full">1</Button>
<Button size="full" colorScheme="grey">
2
</Button>
</StickyFooter>
),
};

0 comments on commit cd95748

Please sign in to comment.