Skip to content
This repository was archived by the owner on Feb 18, 2024. It is now read-only.

Commit d8f6e1a

Browse files
authored
Merge pull request #152 from PrivaNoteTeam/resize-panes
Resize Panes
2 parents 59b4284 + 3a5a541 commit d8f6e1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2596
-819
lines changed

client/package-lock.json

Lines changed: 1513 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
"@testing-library/react": "^12.1.2",
2525
"@testing-library/react-hooks": "^7.0.2",
2626
"@types/jest": "^27.0.2",
27+
"@types/marked": "^3.0.2",
2728
"@types/mock-fs": "^4.13.1",
28-
"@types/react": "^17.0.24",
29+
"@types/react": "^17.0.33",
2930
"@types/react-router": "^5.1.17",
3031
"@types/react-router-dom": "^5.3.2",
32+
"@types/react-syntax-highlighter": "^13.5.2",
3133
"autoprefixer": "^10.3.5",
3234
"babel-jest": "^27.2.5",
3335
"css-loader": "^6.3.0",
@@ -41,6 +43,7 @@
4143
"mini-css-extract-plugin": "^2.3.0",
4244
"mock-fs": "^5.1.1",
4345
"module-alias": "^2.2.2",
46+
"node-loader": "^2.0.0",
4447
"postcss-cli": "^8.3.1",
4548
"postcss-loader": "^6.1.1",
4649
"prettier": "2.4.1",
@@ -56,22 +59,33 @@
5659
},
5760
"dependencies": {
5861
"@hookform/resolvers": "^2.8.1",
62+
"@monaco-editor/react": "^4.3.1",
5963
"@svgr/webpack": "^5.5.0",
6064
"@tailwindcss/aspect-ratio": "^0.3.0",
6165
"@types/axios": "^0.14.0",
6266
"@types/react-dom": "^17.0.9",
6367
"axios": "^0.23.0",
6468
"babel-core": "^6.26.3",
6569
"babel-preset-react": "^6.24.1",
70+
"chokidar": "^3.5.2",
6671
"google-auth-library": "^7.10.1",
6772
"googleapis": "^89.0.0",
73+
"highlight.js": "^11.3.1",
74+
"html-react-parser": "^1.4.0",
75+
"markdown-to-jsx": "^7.1.3",
76+
"marked": "^3.0.8",
77+
"monaco-editor": "^0.29.1",
6878
"mrm": "^3.0.9",
79+
"node-watch": "^0.7.2",
6980
"nodemailer": "^6.7.0",
7081
"react": "^17.0.2",
82+
"react-collapse-pane": "^2.0.1",
7183
"react-dom": "^17.0.2",
84+
"react-dropzone": "^11.4.2",
7285
"react-hook-form": "^7.16.1",
7386
"react-router": "^5.2.1",
7487
"react-router-dom": "^5.3.0",
88+
"react-syntax-highlighter": "^15.4.4",
7589
"typesafe-actions": "^5.1.0",
7690
"yup": "^0.32.9"
7791
}

client/src/app/App.tsx

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@ import { SideMenu } from '@components/SideMenu';
99
import { getUser } from '@shared/Api/getUser';
1010
import { useIpcListeners } from './hooks/useIpcListeners';
1111
import { useGoogleDrive } from './hooks/useGoogleDrive';
12+
import { FileExplorer } from './components/FileExplorer';
13+
import { Placeholder } from './components/Placeholder';
14+
import { NotificationArea } from './components/NotificationArea';
15+
import { SplitPane } from 'react-collapse-pane';
1216

1317
export const editorReducer = (state: EditorState, action: EditorAction) => {
1418
switch (action.type) {
1519
case 'primarySelect':
16-
return { ...state, primarySelection: action.primarySelection };
20+
return { ...state, primarySelection: action.primarySelection! };
1721
case 'secondarySelect':
18-
return { ...state, secondarySelection: action.secondarySelection };
19-
case 'rename':
20-
return { ...state, isRenaming: action.isRenaming };
22+
return { ...state, secondarySelection: action.secondarySelection! };
2123
}
2224
};
2325

2426
export function App() {
25-
const [{ currentNote, notebook }] = useStore();
27+
const [{ currentFile, notebook }] = useStore();
2628
const [, userDispatch] = useUserStore();
2729

2830
useIpcListeners();
@@ -32,17 +34,34 @@ export function App() {
3234
getUser().then(({ user }) => {
3335
if (user) userDispatch({ type: 'login', user });
3436
});
35-
}, [currentNote, notebook]);
37+
}, [currentFile, notebook]);
3638

3739
return (
3840
<>
39-
<div className='bg-gray-800 w-screen h-screen flex'>
41+
<div className='bg-gray-800 w-screen h-screen flex relative'>
4042
<SideMenu />
41-
<EditorProvider
42-
initialState={{ isRenaming: false }}
43-
reducer={editorReducer}
44-
>
45-
<EditorPanel />
43+
<EditorProvider initialState={{}} reducer={editorReducer}>
44+
{notebook ? (
45+
<div className='relative flex-grow z-auto'>
46+
<SplitPane
47+
split='vertical'
48+
initialSizes={[1, 5]}
49+
resizerOptions={{
50+
hoverCss: {
51+
backgroundColor: 'rgb(59, 130, 246)'
52+
}
53+
}}
54+
>
55+
<FileExplorer />
56+
<EditorPanel />
57+
</SplitPane>
58+
</div>
59+
) : (
60+
<div className='relative flex-grow flex flex-col'>
61+
<NotificationArea />
62+
<Placeholder text='Open a notebook to continue' />
63+
</div>
64+
)}
4665
</EditorProvider>
4766
<PageManager />
4867
<ModalManager />
Lines changed: 1 addition & 0 deletions
Loading

client/src/app/components/EditorPanel.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import { useEditorPanel } from './editorPanel/useEditorPanel';
33
import { UIEditorPanel } from './editorPanel/UIEditorPanel';
44

55
export function EditorPanel() {
6-
const { fileExplorerVisible } = useEditorPanel();
6+
const { text, setText, handlePreviewClose, livePreviewVisiable } =
7+
useEditorPanel();
78

8-
return <UIEditorPanel fileExplorerVisible={fileExplorerVisible} />;
9+
return (
10+
<UIEditorPanel
11+
livePreviewVisiable={livePreviewVisiable}
12+
text={text}
13+
setText={setText}
14+
handlePreviewClose={handlePreviewClose}
15+
/>
16+
);
917
}
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
import React from 'react';
2-
import { FileSystemItem } from '@types';
32
import { UIFileExplorer } from './fileExplorer/UIFileExplorer';
4-
53
import { useFileExplorer } from './fileExplorer/useFileExplorer';
64

7-
interface Props {
8-
items: FileSystemItem[];
9-
}
10-
11-
export function FileExplorer({ items }: Props) {
5+
export function FileExplorer() {
126
const {
7+
items,
138
handleAddDirectoryClick,
149
handleAddFileClick,
15-
handleOuterClick,
16-
renameText,
17-
setRenameText
10+
handleOuterClick
1811
} = useFileExplorer();
1912

2013
return (
@@ -23,8 +16,6 @@ export function FileExplorer({ items }: Props) {
2316
handleAddDirectoryClick={handleAddDirectoryClick}
2417
handleAddFileClick={handleAddFileClick}
2518
handleOuterClick={handleOuterClick}
26-
renameText={renameText}
27-
setRenameText={setRenameText}
2819
/>
2920
);
3021
}

client/src/app/components/ModalManager.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,29 @@ export function ModalManager() {
1717

1818
return (
1919
<>
20-
<Route path='/notebook/create' component={CreateNotebookModal} />
21-
<Route path='/login' component={LoginModal} />
22-
<Route path='/register' component={RegisterModal} />
23-
<Route path='/forgot-password' component={ForgotPasswordModal} />
24-
<Route path='/reset-password' component={ResetPasswordModal} />
25-
<Route path='/verification' component={VerificiationModal} />
26-
<Route path='/2fa' component={TwoFactorAuthModal} />
20+
<Route
21+
path='/notebook/create'
22+
children={<CreateNotebookModal />}
23+
exact
24+
/>
25+
<Route path='/login' children={<LoginModal />} exact />
26+
<Route path='/register' children={<RegisterModal />} exact />
27+
<Route
28+
path='/forgot-password'
29+
children={<ForgotPasswordModal />}
30+
exact
31+
/>
32+
<Route
33+
path='/reset-password'
34+
children={<ResetPasswordModal />}
35+
exact
36+
/>
37+
<Route
38+
path='/verification'
39+
children={<VerificiationModal />}
40+
exact
41+
/>
42+
<Route path='/2fa' children={<TwoFactorAuthModal />} exact />
2743
</>
2844
);
2945
}
File renamed without changes.

client/src/app/components/SideMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useStore } from '@hooks';
77
export function SideMenu() {
88
const [{ notebook }] = useStore();
99
return (
10-
<div className='flex flex-col-reverse bg-gray-700 p-3'>
10+
<div className='flex flex-col-reverse bg-gray-700 p-3 flex-0'>
1111
<div className='space-y-reverse space-y-2 inline-flex flex-col-reverse cursor-pointer'>
1212
{notebook && <SettingsButton />}
1313
<UserButton />

client/src/app/components/createNotebookModal/useCreateNotebookModal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function useCreateNotebookModal() {
6565

6666
dispatch({
6767
type: 'openNote',
68-
currentNote: undefined
68+
currentFile: undefined
6969
});
7070

7171
dispatch({

0 commit comments

Comments
 (0)