-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
510 additions
and
147 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
4 changes: 2 additions & 2 deletions
4
...in/editor/services/useDocumentServices.ts → ...omain/editor/hooks/useDocumentServices.ts
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,32 @@ | ||
import * as React from 'react'; | ||
import { useState, createContext, useEffect } from 'react'; | ||
import ErrorComponent from '@ui/components/error/Error'; | ||
|
||
const ERROR_TIMEOUT = 5000; | ||
|
||
export type ErrorContextType = { | ||
showError: (error: Error) => void; | ||
}; | ||
|
||
export const ErrorContext = createContext<ErrorContextType>({ | ||
showError: () => {}, | ||
}); | ||
|
||
export function ErrorProvider({ children }: { children: React.ReactNode }) { | ||
const [error, setError] = useState<Error | undefined>(); | ||
|
||
useEffect(() => { | ||
if (error) { | ||
setTimeout(() => { | ||
setError(undefined); | ||
}, ERROR_TIMEOUT); | ||
} | ||
}, [error]); | ||
|
||
return ( | ||
<ErrorContext.Provider value={{ showError: setError }}> | ||
{error && <ErrorComponent error={error} />} | ||
{children} | ||
</ErrorContext.Provider> | ||
); | ||
} |
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 { useContext } from 'react'; | ||
import { ErrorContext } from '@domain/error/ErrorContext'; | ||
|
||
function useError() { | ||
return useContext(ErrorContext); | ||
} | ||
|
||
export default useError; |
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,17 @@ | ||
import * as React from 'react'; | ||
import { useState, createContext } from 'react'; | ||
|
||
export type WorkspaceContextType = { | ||
filePath: string | undefined; | ||
setFilePath: (path: string) => void; | ||
}; | ||
|
||
export const WorkspaceContext = createContext<WorkspaceContextType>({ | ||
filePath: undefined, | ||
setFilePath: () => {}, | ||
}); | ||
|
||
export function WorkspaceProvider({ children }: { children: React.ReactNode }) { | ||
const [filePath, setFilePath] = useState<string | undefined>(undefined); | ||
return <WorkspaceContext.Provider value={{ filePath, setFilePath }}>{children}</WorkspaceContext.Provider>; | ||
} |
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 { useContext } from 'react'; | ||
import { WorkspaceContext } from '@domain/workspace/WorkspaceContext'; | ||
|
||
function useWorkspace() { | ||
return useContext(WorkspaceContext); | ||
} | ||
|
||
export default useWorkspace; |
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
2 changes: 1 addition & 1 deletion
2
...omain/editor/services/documentServices.ts → code/client/src/services/documentServices.ts
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
36 changes: 36 additions & 0 deletions
36
code/client/src/ui/components/context-menu/ContextMenu.scss
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,36 @@ | ||
.menu { | ||
ul { | ||
background-color: black; | ||
width: 100px; | ||
border-radius: 5px; | ||
} | ||
|
||
.menu-items { | ||
display: flex; | ||
flex-direction: column; | ||
background-color: black; | ||
|
||
button { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: left; | ||
color: white; | ||
background-color: black; | ||
border: none; | ||
padding: 2vh; | ||
margin: 0 1vh 0 1vh; | ||
font-size: 10px; | ||
cursor: pointer; | ||
transition: background-color 0.3s; | ||
|
||
&:hover { | ||
background-color: white; | ||
color: black; | ||
} | ||
|
||
:first-child { | ||
margin-right: 1.5vh; | ||
} | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
code/client/src/ui/components/context-menu/ContextMenu.tsx
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,43 @@ | ||
import { MouseEvent, ReactNode, useState } from 'react'; | ||
import { Menu, PopoverPosition } from '@mui/material'; | ||
import './ContextMenu.scss'; | ||
|
||
type ContextMenuProps = { | ||
item: ReactNode; | ||
children: ReactNode; | ||
}; | ||
|
||
function ContextMenu({ item, children }: ContextMenuProps) { | ||
const [mousePosition, setMousePosition] = useState<PopoverPosition | null>(null); | ||
|
||
function onContextMenu(e: MouseEvent<HTMLElement>) { | ||
if (mousePosition !== null) return; // don't show context menu if it's already open | ||
e.preventDefault(); | ||
setMousePosition({ | ||
left: e.clientX - 2, | ||
top: e.clientY - 4, | ||
}); | ||
} | ||
|
||
function onClose() { | ||
setMousePosition(null); | ||
} | ||
|
||
return ( | ||
<div onContextMenu={onContextMenu} onClick={onClose}> | ||
{item} | ||
<Menu | ||
className="menu" | ||
open={mousePosition !== null} | ||
onClose={onClose} | ||
anchorReference="anchorPosition" | ||
anchorPosition={mousePosition || undefined} | ||
keepMounted | ||
> | ||
<div className="menu-items">{children}</div> | ||
</Menu> | ||
</div> | ||
); | ||
} | ||
|
||
export default ContextMenu; |
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 |
---|---|---|
@@ -1,16 +1,21 @@ | ||
header { | ||
position: sticky; | ||
width: 100%; | ||
height: 5vh; | ||
top: 0; | ||
left: 0; | ||
color: black; | ||
background: white; | ||
width: 100%; | ||
padding: 1vh 0 1vh 5vh; | ||
padding: 1vh 0 1vh 15vh; | ||
box-shadow: black 0 0 1px; | ||
display: flex; | ||
align-items: center; | ||
z-index: 1; | ||
|
||
.title { | ||
font-size: 3vh; | ||
p { | ||
font-size: 2.5vh; | ||
padding: 1vh; | ||
margin: 0 0 0 1vh; | ||
margin: 0 0 0 2vh; | ||
font-weight: 500; | ||
} | ||
} |
Oops, something went wrong.