generated from yuminn-k/yuminnk-nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat : Create a Dashboard component
- Selecting a tab on the dashboard allows you to load the components you've linked - The tabsMapping is responsible for rendering the components to be linked Related issue: #49
- Loading branch information
Showing
6 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use client'; | ||
|
||
import {DashboardProps} from '@/src/interfaces/group'; | ||
|
||
const Dashboard = ({tabs, activeTab, setActiveTab}: DashboardProps) => { | ||
const handleClick = (tab: React.SetStateAction<string>) => { | ||
setActiveTab(tab); | ||
}; | ||
return ( | ||
<nav className="mt-4 flex"> | ||
{tabs.map(tab => ( | ||
<div | ||
key={tab} | ||
className={`grid place-items-center w-24 h-10 border-r border-gray-400 px-4 hover:cursor-pointer ${ | ||
activeTab === tab | ||
? 'text-black bg-sky-50' | ||
: 'text-gray-400 hover:bg-slate-100 ' | ||
}`} | ||
onClick={() => handleClick(tab)} | ||
> | ||
{tab} | ||
</div> | ||
))} | ||
</nav> | ||
); | ||
}; | ||
|
||
export default Dashboard; |
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,8 @@ | ||
import {TabsMappingProps} from '@/src/interfaces/group'; | ||
import React from 'react'; | ||
|
||
const TabsMapping = ({activeTab, tabMapping}: TabsMappingProps) => { | ||
return <>{tabMapping[activeTab]}</>; | ||
}; | ||
|
||
export default TabsMapping; |
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,4 @@ | ||
import Dashboard from './Dashboard'; | ||
import TabsMapping from './TabsMapping'; | ||
|
||
export {Dashboard, TabsMapping}; |
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,7 @@ | ||
interface DashboardProps { | ||
activeTab: string; | ||
setActiveTab: React.Dispatch<React.SetStateAction<string>>; | ||
tabs: string[]; | ||
} | ||
|
||
export type {DashboardProps}; |
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,2 @@ | ||
export type {DashboardProps} from './dashboardProps'; | ||
export type {TabsMappingProps} from './tabsMappingProps'; |
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,8 @@ | ||
interface TabsMappingProps { | ||
activeTab: string; | ||
tabMapping: { | ||
[key: string]: JSX.Element; | ||
}; | ||
} | ||
|
||
export type {TabsMappingProps}; |