Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
attempted to fix an error with context
Browse files Browse the repository at this point in the history
  • Loading branch information
raisfeld-ori committed Mar 15, 2024
1 parent a941c68 commit c1541b4
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function App() {
initialize();
}, []);
init();
document.addEventListener('contextmenu', function(e) {e.preventDefault();});
return <Routes>
<Route path="/" element={login()}></Route>
<Route path="/signup" element={signup()}></Route>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/login/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function loading(){
});
}, []);

return <div id='background'>
return <div id='background' onContextMenu={e => e.preventDefault()}>

<div className='triangle down'></div>
<div className='triangle left'></div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function login(){



return <div id='background'>
return <div id='background' onContextMenu={e => e.preventDefault()}>



Expand Down
2 changes: 1 addition & 1 deletion src/pages/login/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Login() {
}

return (
<div id='background'>
<div id='background' onContextMenu={e => e.preventDefault()}>
<div className='triangle down'></div>
<div className='triangle left'></div>
<button className='upperbutton' aria-current={false} onClick={() => navigate("/")}>Login</button>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/main_page/internal_apps/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,7 @@
}

.ContextMenu{
height: 10svh;
position: fixed;
background-color: aliceblue;
}
2 changes: 0 additions & 2 deletions src/pages/main_page/internal_apps/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//@ts-expect-error

import React, { useState, RefObject } from "react";

Check failure on line 1 in src/pages/main_page/internal_apps/App.tsx

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'useState' is declared but its value is never read.

Check failure on line 1 in src/pages/main_page/internal_apps/App.tsx

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'RefObject' is declared but its value is never read.
import { useDraggable } from '../Grid';
import './App.css';
Expand Down
23 changes: 11 additions & 12 deletions src/pages/main_page/internal_apps/file_system.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ function file_system() : [JSX.Element, React.Dispatch<React.SetStateAction<strin

const [{dx, dy}, set_positions] = useState({dx: 0, dy: 0});
const [ctx_display, set_ctx_display] = useState('none');
const right_click = (ev: MouseEvent) => {
useEffect(() => {
document.addEventListener("click", () => set_ctx_display('none'));
return () => document.removeEventListener("click", () => set_ctx_display('none'));
}, [])

const right_click = (ev: React.MouseEvent) => {
//set_context({x: ev.clientX, y: ev.clientY});
ev.preventDefault();
console.log("right clicked");
//set_menu(true);
set_ctx_display('inherit');
Expand All @@ -22,25 +28,18 @@ function file_system() : [JSX.Element, React.Dispatch<React.SetStateAction<strin
const left_click = () =>{

Check failure on line 28 in src/pages/main_page/internal_apps/file_system.tsx

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'left_click' is declared but its value is never read.
if (ctx_display) {set_ctx_display('none');}
}
useEffect(() => {
document.addEventListener('contextmenu', right_click);
document.addEventListener('click', left_click);
return () => {
document.removeEventListener('contextmenu', right_click);
document.removeEventListener('click', left_click);
};
}, []);
let Application = <div className='ApplicationDirectory'>
<h1 className='filesystemtxt2'>/{location}/</h1>

<div className='ContextMenu'
style={{
transform: `translate3d(${dx}px, ${dy}px, 0)`,
top: `${dy}px`,
left: `${dx}px`,
display: `${ctx_display}`,
}}
><h1>test</h1></div>
><h1>test</h1><h1>test 2</h1></div>
</div>
let app_html = <div className='frametest2'>
let app_html = <div className='frametest2' onContextMenu={right_click}>
{Application}
</div>;
const [display, set_display] = useState('none');
Expand Down
8 changes: 4 additions & 4 deletions src/pages/main_page/main_page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';

Check failure on line 1 in src/pages/main_page/main_page.tsx

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'useEffect' is declared but its value is never read.
import './main_page.css';
import Grid from './Grid';
import folder from './assets/folder.png';
Expand All @@ -17,10 +17,10 @@ export default function MainPage() {
const terminal = desktop_app("Terminal", terminald, () => {});
const [menu, set_menu] = useState(false);
return (
<div id='background'>
<div id='background' onContextMenu={e => {e.preventDefault();}}>
{app}
<Grid apps={[example_app, not_example_app, terminal]} gridSize={50} margin={120} />
<nav className='navbar'>
<Grid apps={[example_app, not_example_app, terminal]} gridSize={50} margin={120} />
<nav className='navbar' onContextMenu={e => e.preventDefault()}>
<img className='homeimg' onClick={() => set_menu(!menu)} src={menu_icon} alt="" />
<img className='searchimg' src={search} alt="" />
<img className='terminalimg' src={terminald} alt="" />
Expand Down

0 comments on commit c1541b4

Please sign in to comment.