Refactor tab component
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { IconBack } from "~assets/icons";
|
||||
import type { ReactNode, PropsWithChildren } from "react";
|
||||
|
||||
import styles from "./tab.module.less";
|
||||
|
||||
interface HeaderProps {
|
||||
title: ReactNode;
|
||||
onBack: () => void;
|
||||
}
|
||||
|
||||
function Tab({ children }: PropsWithChildren) {
|
||||
return (
|
||||
<div className={styles.tab}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Tab.Header = function Header({ title, onBack }: HeaderProps) {
|
||||
return (
|
||||
<header className={styles.header}>
|
||||
<button className={styles.back} onClick={onBack}>
|
||||
<IconBack />
|
||||
</button>
|
||||
<h2>{title}</h2>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
Tab.Body = function Body({ children }: PropsWithChildren) {
|
||||
return (
|
||||
<main className={styles.body}>
|
||||
{children}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
export default Tab;
|
||||
Reference in New Issue
Block a user