-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
updated
- Loading branch information
1 parent
445de85
commit 39f486b
Showing
4 changed files
with
92 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// ClickableScreen.js | ||
|
||
import React from 'react'; | ||
import ToggleButton from './ToggleButton'; | ||
import { useDrawerState } from '../state/useDrawerState'; | ||
import { useNavigatorState } from '../state/useNavigatorState'; | ||
const enabled=false; | ||
const ClickableScreen = ({ onTextClick,children }) => { | ||
|
||
const { setData:setDrawer,data:drawerData } = useDrawerState(); | ||
const { data } = useNavigatorState(); | ||
const [state,setState] = React.useState(false); | ||
const handleClick = (event) => { | ||
// Get the element that was clicked | ||
const clickedElement = event.target; | ||
|
||
// Extract text content from the clicked element | ||
const clickedText = clickedElement.textContent.trim(); | ||
|
||
// Call the callback with the clicked text | ||
console.log(clickedText,'clickedText'); | ||
state&& setDrawer({...drawerData,isOpen:!drawerData?.isOpen,clickedFrom:data?.currentScreen ,content:clickedText}) | ||
onTextClick?.(clickedText); | ||
setState(false); | ||
}; | ||
return ( | ||
<div | ||
// className="h-screen flex justify-center items-center bg-gray-200" | ||
> | ||
<div | ||
// className="p-6 bg-white shadow-lg rounded-md cursor-pointer" | ||
onClick={handleClick} | ||
> | ||
{!drawerData?.isOpen&&enabled&&<ToggleButton | ||
opened={state} | ||
onClick={(e)=>{ | ||
setState(!state); | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
}} | ||
// onClick={()=>setDrawer({...drawerData,isOpen:!drawerData?.isOpen,fromScreen:data?.currentScreen ,content:"Hii"})} | ||
></ToggleButton>} | ||
|
||
{/* <p className="mt-2 text-sm text-gray-600">Identify the text you clicked on.</p> | ||
<button | ||
className="mt-4 bg-indigo-500 text-white py-2 px-4 rounded-md hover:bg-indigo-600" | ||
onClick={handleClick} | ||
> | ||
Click Me | ||
</button> */} | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ClickableScreen; |
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,21 @@ | ||
// ToggleButton.js | ||
|
||
import React from 'react'; | ||
|
||
const ToggleButton = ({ onClick,opened }) => { | ||
return ( | ||
<> | ||
<button | ||
className={`fixed top-1/2 right-0 transform -translate-y-1/2 bg-indigo-500 text-white py-2 px-4 rounded-l-md hover:bg-indigo-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 z-50 ${opened ? 'opacity-50' : 'opacity-100'}`} | ||
onClick={onClick} | ||
> | ||
{opened?"Click on any text":"Enable Admin Mode"} | ||
</button> | ||
<div className={`fixed bottom-5 right-5 bg-white border border-gray-300 p-4 rounded-md shadow-md transition-opacity ${opened? 'opacity-90' : 'opacity-0'}`}> | ||
<h1 className="text-xl font-semibold text-gray-900">Click anywhere on the screen</h1> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default ToggleButton; |