Skip to content

Commit

Permalink
feat(select-bottomsheet): add bottom sheet footer and header prop
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigosakamoto committed Sep 12, 2023
1 parent c084e80 commit c330fde
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/components/BottomSheet/BottomSheet.tsx
Expand Up @@ -35,6 +35,13 @@ const StyledRSBS = styled(RSBS)`
background-color: ${({ theme }) => theme.colors.neutral[400]};
}
}
[data-rsbs-footer] {
padding: ${({ theme }) =>
`${theme.spacings.xxxbig} ${theme.spacings.md} ${theme.spacings.xxsm}`};
box-shadow: none !important;
}
`;

export default function BottomSheet(props: ComponentProps<typeof RSBS>) {
Expand Down
4 changes: 4 additions & 0 deletions lib/components/Select2/Select.tsx
Expand Up @@ -95,6 +95,8 @@ function Select<
destructive,
spaceAfter,
useBottomSheet,
bottomSheetFooter,
bottomSheetHeader,
...props
}: Props<Option, IsMulti, Group> & CustomSelectProps) {
// only used for bottom sheet mode
Expand Down Expand Up @@ -229,6 +231,8 @@ function Select<
maxMenuHeight={useBottomSheet ? "100%" : 200}
label={label}
setMenuIsOpen={setMenuIsOpen}
bottomSheetHeader={bottomSheetHeader}
bottomSheetFooter={bottomSheetFooter}
/>
{helper && (
<HelperDiv>
Expand Down
2 changes: 2 additions & 0 deletions lib/components/Select2/Select.types.ts
Expand Up @@ -9,4 +9,6 @@ export interface CustomSelectProps {
destructive?: boolean;
required?: boolean;
useBottomSheet?: boolean;
bottomSheetFooter?: React.ReactNode;
bottomSheetHeader?: React.ReactNode;
}
6 changes: 6 additions & 0 deletions lib/components/Select2/SelectBottomSheet.tsx
Expand Up @@ -20,6 +20,10 @@ export default function SelectBottomSheet(props: MenuProps) {
const { label, onMenuClose, setMenuIsOpen, inputValue, onInputChange } =
props.selectProps;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const { bottomSheetFooter, bottomSheetHeader } = props.selectProps;

return (
<BottomSheet
open={true}
Expand Down Expand Up @@ -53,8 +57,10 @@ export default function SelectBottomSheet(props: MenuProps) {
<StyledText type="overlineLarge" color="neutral" shade="400">
{label}
</StyledText>
{bottomSheetHeader}
</>
}
footer={bottomSheetFooter}
>
{props.children}
</BottomSheet>
Expand Down
7 changes: 7 additions & 0 deletions src/stories/components/select/Select.stories.tsx
Expand Up @@ -143,3 +143,10 @@ AllInOne.args = {
label: "Turn everything ON at once!",
helper: "For all available options, see the react-select docs",
};

export const BottomSheetWithHeaderAndFooter = Template.bind({});
BottomSheetWithHeaderAndFooter.args = {
useBottomSheet: true,
bottomSheetHeader: <p>Header</p>,
bottomSheetFooter: <p>Footer</p>,
};

0 comments on commit c330fde

Please sign in to comment.