-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from staruth0/clean-ups
reacions on testphase
- Loading branch information
Showing
17 changed files
with
390 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React, { useEffect, useRef, useState } from "react"; | ||
|
||
|
||
interface TabsProps { | ||
tabs: { id: number | string; title: JSX.Element }[]; | ||
activeTab: number | string; | ||
setActiveTab: (tabId: number | string) => void; | ||
scale?: boolean; | ||
borderBottom?: boolean; | ||
children?: React.ReactNode; | ||
} | ||
|
||
const ReactionTab: React.FC<TabsProps> = ({tabs,activeTab,setActiveTab,scale,borderBottom}) => { | ||
const [tabStyle, setTabStyle] = useState<React.CSSProperties>({}); | ||
const tabRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
const activeTabElement = tabRef.current?.querySelector( | ||
".active" | ||
) as HTMLElement; | ||
if (activeTabElement) { | ||
setTabStyle({ | ||
left: activeTabElement.offsetLeft, | ||
width: activeTabElement.offsetWidth, | ||
}); | ||
} | ||
}, [activeTab]); | ||
|
||
const handleTabClick = (tabId: number | string) => { | ||
setActiveTab(tabId); | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-col items-center backdrop-blur-sm"> | ||
{/* Tabs */} | ||
<div | ||
ref={tabRef} | ||
className={`relative flex justify-between w-full ${ | ||
borderBottom ? "border-b" : "" | ||
}`} | ||
> | ||
{tabs.map((tab) => ( | ||
<span | ||
key={tab.id} | ||
id={`tab-${tab.id}`} | ||
className={`px-2 py-2 cursor-pointer transition-all border-b-2 -mb-0 flex items-center ${ | ||
activeTab === tab.id | ||
? `border-primary-400 text-neutral-50 ${ | ||
scale ? "scale-110" : "" | ||
}` | ||
: "border-transparent text-neutral-50" | ||
}`} | ||
onClick={() => handleTabClick(tab.id)} | ||
> | ||
{tab.title} | ||
</span> | ||
))} | ||
{/* Tab slider */} | ||
<div | ||
className="absolute bottom-0 h-[2px] bg-primary-400 transition-all duration-300" | ||
style={tabStyle} | ||
></div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ReactionTab; |
Oops, something went wrong.