From a9b7df6857aa7e540b9a42afed3a2fdf7bd5965b Mon Sep 17 00:00:00 2001 From: BFlat Date: Tue, 5 Dec 2023 01:18:15 +0700 Subject: [PATCH] padding prop for tab content --- .../src/components/common/Tabs/Tabs.tsx | 17 +++++++++++------ .../profile/profile_view/NewProfilePage.tsx | 5 ++++- .../profile/profile_view/tabs/BookmarksTab.tsx | 5 ++--- .../profile/profile_view/tabs/MediaTab.tsx | 5 ++--- .../profile/profile_view/tabs/WeightsTab.tsx | 5 ++--- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/fakeyou.com/src/components/common/Tabs/Tabs.tsx b/packages/fakeyou.com/src/components/common/Tabs/Tabs.tsx index 92dc47d34b..57ed3a9b5b 100644 --- a/packages/fakeyou.com/src/components/common/Tabs/Tabs.tsx +++ b/packages/fakeyou.com/src/components/common/Tabs/Tabs.tsx @@ -10,6 +10,7 @@ interface TabProps { label: string; content?: React.ReactNode; icon?: IconDefinition; + padding?: boolean; } interface TabsProps { @@ -18,6 +19,7 @@ interface TabsProps { interface TabContentProps { children: React.ReactNode; + padding?: boolean; } function Tab({ to, label, icon, onClick }: TabProps & { onClick: () => void }) { @@ -36,14 +38,15 @@ function Tab({ to, label, icon, onClick }: TabProps & { onClick: () => void }) { ); } -function TabContent({ children }: TabContentProps) { - return
{children}
; +function TabContent({ children, padding }: TabContentProps) { + const paddingClasses = padding ? "p-3 py-4 p-md-4" : ""; + return
{children}
; } function Tabs({ tabs }: TabsProps) { const location = useLocation(); const currentPath = location.pathname; - const initialTab = tabs.find((tab) => tab.to === currentPath) || tabs[0]; + const initialTab = tabs.find(tab => tab.to === currentPath) || tabs[0]; const [activeTab, setActiveTab] = useState(initialTab.to); const [fade, setFade] = useSpring(() => ({ @@ -68,10 +71,12 @@ function Tabs({ tabs }: TabsProps) { setTimeout(() => setActiveTab(tabTo), 50); }; + const activeTabProps = tabs.find(tab => tab.to === activeTab); + return (