1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00
vault-frontend/src/components/sidebar/SidebarStackCard/index.tsx
2022-08-15 12:32:44 +07:00

44 lines
1.1 KiB
TypeScript

import React, { FC, ReactNode, useMemo } from 'react';
import { Filler } from '~/components/containers/Filler';
import { Button } from '~/components/input/Button';
import styles from './styles.module.scss';
interface SidebarStackCardProps {
width?: number;
headerFeature?: 'back' | 'close';
title?: ReactNode;
onBackPress?: () => void;
}
const SidebarStackCard: FC<SidebarStackCardProps> = ({
children,
title,
width,
headerFeature,
onBackPress,
}) => {
const style = useMemo(() => ({ maxWidth: width, flexBasis: width }), [width]);
const backIcon = headerFeature === 'close' ? 'close' : 'right';
return (
<div style={style} className={styles.card}>
{!!(headerFeature || title) && (
<div className={styles.head}>
<Filler className={styles.title}>
{typeof title === 'string' ? <h6>{title}</h6> : title}
</Filler>
{!!(headerFeature && onBackPress) && (
<Button color="link" iconRight={backIcon} onClick={onBackPress} />
)}
</div>
)}
<div className={styles.content}>{children}</div>
</div>
);
};
export { SidebarStackCard };