-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat : Added layout Toggle and closes #338
- Loading branch information
1 parent
612fa7f
commit 0a761f0
Showing
13 changed files
with
215 additions
and
150 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use client'; | ||
import React, { useEffect } from 'react'; | ||
import { Grid3X3, Rows3 } from 'lucide-react'; | ||
import { useRecoilState } from 'recoil'; | ||
import { layoutToggle } from '@/store/atoms/layout'; | ||
|
||
const LayoutToggle = () => { | ||
const [layoutType, setLayoutType] = useRecoilState(layoutToggle); | ||
|
||
useEffect(() => { | ||
const storedLayout = localStorage.getItem('layout'); | ||
if (storedLayout !== null) { | ||
setLayoutType(parseInt(storedLayout, 10)); | ||
} | ||
}, []); | ||
|
||
const handleLayoutChange = (type: number) => { | ||
setLayoutType(type); | ||
localStorage.setItem('layout', type.toString()); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className="flex border w-[6rem] h-[2rem] justify-center rounded-full items-center"> | ||
<div | ||
onClick={() => handleLayoutChange(1)} | ||
className={`${layoutType === 1 ? 'bg-blue-500 rounded-sm text-black' : ''} w-[50%] flex cursor-pointer items-center justify-center h-full rounded-l-full`} | ||
> | ||
<Grid3X3 size={18} className={` `} /> | ||
</div> | ||
<div | ||
onClick={() => handleLayoutChange(2)} | ||
className={`${layoutType === 2 ? 'bg-blue-500 rounded-sm text-black' : ''} w-[50%] flex cursor-pointer items-center justify-center h-full rounded-r-full`} | ||
> | ||
<Rows3 size={18} className={``} /> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default LayoutToggle; |
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
Oops, something went wrong.