cutelee

feat: 서브메뉴 토글 기능 구현

...@@ -21,3 +21,5 @@ ...@@ -21,3 +21,5 @@
21 npm-debug.log* 21 npm-debug.log*
22 yarn-debug.log* 22 yarn-debug.log*
23 yarn-error.log* 23 yarn-error.log*
24 +
25 +.idea/
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
3 "version": "0.1.0", 3 "version": "0.1.0",
4 "private": true, 4 "private": true,
5 "dependencies": { 5 "dependencies": {
6 + "@fortawesome/fontawesome-free": "^5.13.0",
6 "@testing-library/jest-dom": "^4.2.4", 7 "@testing-library/jest-dom": "^4.2.4",
7 "@testing-library/react": "^9.5.0", 8 "@testing-library/react": "^9.5.0",
8 "@testing-library/user-event": "^7.2.1", 9 "@testing-library/user-event": "^7.2.1",
......
...@@ -4,6 +4,8 @@ import './index.css'; ...@@ -4,6 +4,8 @@ import './index.css';
4 import App from './App'; 4 import App from './App';
5 import * as serviceWorker from './serviceWorker'; 5 import * as serviceWorker from './serviceWorker';
6 6
7 +import "@fortawesome/fontawesome-free/css/all.min.css";
8 +
7 ReactDOM.render( 9 ReactDOM.render(
8 <React.StrictMode> 10 <React.StrictMode>
9 <App /> 11 <App />
......
1 .my-editor.tui-image-editor-container { 1 .my-editor.tui-image-editor-container {
2 + &.submenu-hidden {
3 + .tui-image-editor-submenu {
4 + left: -350px;
5 + transition: 0.5s ease-in-out;
6 + }
7 + }
8 +
9 + .tui-image-editor-controls {
10 + z-index: 10;
11 + }
12 +
13 + .tui-image-editor-submenu {
14 + left: 0;
15 + transition: 0.5s ease-in;
16 + }
17 +
2 .tui-image-editor-header { 18 .tui-image-editor-header {
3 display: none; 19 display: none;
4 } 20 }
......
...@@ -14,6 +14,27 @@ ...@@ -14,6 +14,27 @@
14 border-radius: 5px; 14 border-radius: 5px;
15 margin-right: 10px; 15 margin-right: 10px;
16 cursor: pointer; 16 cursor: pointer;
17 +
18 + &:focus {
19 + outline: none;
20 + }
21 + }
22 +
23 + .submenu-toggle {
24 + position: absolute;
25 + left: 90px;
26 + background: none;
27 + color: gray;
28 + font-size: 20px;
29 +
30 + &.activate {
31 + color: white;
32 + }
33 +
34 + &:hover {
35 + transform: scale(1.15);
36 + transition: 0.2s;
37 + }
17 } 38 }
18 39
19 .file-box { 40 .file-box {
......
1 import React, { ChangeEvent } from "react"; 1 import React, { ChangeEvent } from "react";
2 import ToastEditor from "tui-image-editor"; 2 import ToastEditor from "tui-image-editor";
3 +import { SubmenuContext } from "../EditorPage";
3 4
4 import "./EditorHeader.scss"; 5 import "./EditorHeader.scss";
5 6
...@@ -21,9 +22,24 @@ function EditorHeader({ editor, imageLoad }: EditorHeaderProps) { ...@@ -21,9 +22,24 @@ function EditorHeader({ editor, imageLoad }: EditorHeaderProps) {
21 } 22 }
22 } 23 }
23 24
25 + function toggleSubmenu() {
26 + console.log("toggle Submenu");
27 + }
28 +
24 return ( 29 return (
25 <div className="my-header"> 30 <div className="my-header">
26 - <button>다크모드</button> 31 + <SubmenuContext.Consumer>
32 + {({ visible, onChange }) => {
33 + console.log(visible);
34 + return (
35 + <button className={`submenu-toggle ${visible && "activate"}`} onClick={() => onChange()}>
36 + <i className="fas fa-list" />
37 + </button>
38 + );
39 + }}
40 + </SubmenuContext.Consumer>
41 +
42 + {/*<button>다크모드</button>*/}
27 {imageLoad ? ( 43 {imageLoad ? (
28 <> 44 <>
29 <button>다운로드</button> 45 <button>다운로드</button>
......
1 -import React, { useRef, useEffect, useState } from "react"; 1 +import React, { useRef, useEffect, useState, Context } from "react";
2 import ToastEditor from "tui-image-editor"; 2 import ToastEditor from "tui-image-editor";
3 3
4 import EditorHeader from "./EditorHeader"; 4 import EditorHeader from "./EditorHeader";
...@@ -12,9 +12,20 @@ import "./EditorPage.scss"; ...@@ -12,9 +12,20 @@ import "./EditorPage.scss";
12 // @ts-ignore 12 // @ts-ignore
13 const initialEditor:ToastEditor = new ToastEditor(document.querySelector("#hidden-editor"), editorOptions); 13 const initialEditor:ToastEditor = new ToastEditor(document.querySelector("#hidden-editor"), editorOptions);
14 14
15 +interface SubmenuContextType {
16 + visible: boolean,
17 + onChange: Function
18 +}
19 +
20 +export const SubmenuContext: Context<SubmenuContextType> = React.createContext<SubmenuContextType>({
21 + visible: true,
22 + onChange: () => {}
23 +});
24 +
15 function EditorPage() { 25 function EditorPage() {
16 const imageEditorRef = useRef<HTMLDivElement>(null); 26 const imageEditorRef = useRef<HTMLDivElement>(null);
17 const [editor, setEditor] = useState(initialEditor); 27 const [editor, setEditor] = useState(initialEditor);
28 + const [submenuVisible, setSubmenuVisible] = useState(true);
18 29
19 useEffect(() => { 30 useEffect(() => {
20 // @ts-ignore 31 // @ts-ignore
...@@ -25,10 +36,16 @@ function EditorPage() { ...@@ -25,10 +36,16 @@ function EditorPage() {
25 }; 36 };
26 }, []); 37 }, []);
27 38
39 + function onChangeSubmenuVisible() {
40 + setSubmenuVisible(!submenuVisible);
41 + }
42 +
28 return ( 43 return (
29 <> 44 <>
30 - <EditorHeader editor={editor} imageLoad={false} /> 45 + <SubmenuContext.Provider value={{ visible: submenuVisible, onChange: onChangeSubmenuVisible }}>
31 - <div className="my-editor" ref={imageEditorRef} /> 46 + <EditorHeader editor={editor} imageLoad={false} />
47 + <div className={`my-editor tui-image-editor-container left ${!submenuVisible && "submenu-hidden"}`} ref={imageEditorRef} />
48 + </SubmenuContext.Provider>
32 </> 49 </>
33 ); 50 );
34 } 51 }
......