mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-15 17:30:30 +00:00
Feature: tabbed layouts (#1981)
This commit is contained in:
parent
768107cde8
commit
2d8160512f
4 changed files with 92 additions and 9 deletions
15
src/utils/contexts/tab.jsx
Normal file
15
src/utils/contexts/tab.jsx
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { createContext, useState, useMemo } from "react";
|
||||
|
||||
export const TabContext = createContext();
|
||||
|
||||
export function TabProvider({ initialTab, children }) {
|
||||
const [activeTab, setActiveTab] = useState(false);
|
||||
|
||||
if (initialTab) {
|
||||
setActiveTab(initialTab);
|
||||
}
|
||||
|
||||
const value = useMemo(() => ({ activeTab, setActiveTab }), [activeTab]);
|
||||
|
||||
return <TabContext.Provider value={value}>{children}</TabContext.Provider>;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue