Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design2
/
2016104145
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
cutelee
2020-06-04 12:47:11 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9424629d0720a9b559034ab0980a06d572c2c9ff
9424629d
1 parent
83ab6b42
feat: 서브메뉴 토글 기능 구현
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
3 deletions
project/.gitignore
project/package.json
project/src/index.tsx
project/src/pages/Editor/Editor.scss
project/src/pages/Editor/EditorHeader/EditorHeader.scss
project/src/pages/Editor/EditorHeader/EditorHeader.tsx
project/src/pages/Editor/EditorPage.tsx
project/.gitignore
View file @
9424629
...
...
@@ -21,3 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea/
\ No newline at end of file
...
...
project/package.json
View file @
9424629
...
...
@@ -3,6 +3,7 @@
"version"
:
"0.1.0"
,
"private"
:
true
,
"dependencies"
:
{
"@fortawesome/fontawesome-free"
:
"^5.13.0"
,
"@testing-library/jest-dom"
:
"^4.2.4"
,
"@testing-library/react"
:
"^9.5.0"
,
"@testing-library/user-event"
:
"^7.2.1"
,
...
...
project/src/index.tsx
View file @
9424629
...
...
@@ -4,6 +4,8 @@ import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import "@fortawesome/fontawesome-free/css/all.min.css";
ReactDOM.render(
<React.StrictMode>
<App />
...
...
project/src/pages/Editor/Editor.scss
View file @
9424629
.my-editor.tui-image-editor-container
{
&
.submenu-hidden
{
.tui-image-editor-submenu
{
left
:
-350px
;
transition
:
0
.5s
ease-in-out
;
}
}
.tui-image-editor-controls
{
z-index
:
10
;
}
.tui-image-editor-submenu
{
left
:
0
;
transition
:
0
.5s
ease-in
;
}
.tui-image-editor-header
{
display
:
none
;
}
...
...
project/src/pages/Editor/EditorHeader/EditorHeader.scss
View file @
9424629
...
...
@@ -14,6 +14,27 @@
border-radius
:
5px
;
margin-right
:
10px
;
cursor
:
pointer
;
&
:focus
{
outline
:
none
;
}
}
.submenu-toggle
{
position
:
absolute
;
left
:
90px
;
background
:
none
;
color
:
gray
;
font-size
:
20px
;
&
.activate
{
color
:
white
;
}
&
:hover
{
transform
:
scale
(
1
.15
);
transition
:
0
.2s
;
}
}
.file-box
{
...
...
project/src/pages/Editor/EditorHeader/EditorHeader.tsx
View file @
9424629
import React, { ChangeEvent } from "react";
import ToastEditor from "tui-image-editor";
import { SubmenuContext } from "../EditorPage";
import "./EditorHeader.scss";
...
...
@@ -21,9 +22,24 @@ function EditorHeader({ editor, imageLoad }: EditorHeaderProps) {
}
}
function toggleSubmenu() {
console.log("toggle Submenu");
}
return (
<div className="my-header">
<button>다크모드</button>
<SubmenuContext.Consumer>
{({ visible, onChange }) => {
console.log(visible);
return (
<button className={`submenu-toggle ${visible && "activate"}`} onClick={() => onChange()}>
<i className="fas fa-list" />
</button>
);
}}
</SubmenuContext.Consumer>
{/*<button>다크모드</button>*/}
{imageLoad ? (
<>
<button>다운로드</button>
...
...
project/src/pages/Editor/EditorPage.tsx
View file @
9424629
import React, { useRef, useEffect, useState } from "react";
import React, { useRef, useEffect, useState
, Context
} from "react";
import ToastEditor from "tui-image-editor";
import EditorHeader from "./EditorHeader";
...
...
@@ -12,9 +12,20 @@ import "./EditorPage.scss";
// @ts-ignore
const initialEditor:ToastEditor = new ToastEditor(document.querySelector("#hidden-editor"), editorOptions);
interface SubmenuContextType {
visible: boolean,
onChange: Function
}
export const SubmenuContext: Context<SubmenuContextType> = React.createContext<SubmenuContextType>({
visible: true,
onChange: () => {}
});
function EditorPage() {
const imageEditorRef = useRef<HTMLDivElement>(null);
const [editor, setEditor] = useState(initialEditor);
const [submenuVisible, setSubmenuVisible] = useState(true);
useEffect(() => {
// @ts-ignore
...
...
@@ -25,10 +36,16 @@ function EditorPage() {
};
}, []);
function onChangeSubmenuVisible() {
setSubmenuVisible(!submenuVisible);
}
return (
<>
<SubmenuContext.Provider value={{ visible: submenuVisible, onChange: onChangeSubmenuVisible }}>
<EditorHeader editor={editor} imageLoad={false} />
<div className="my-editor" ref={imageEditorRef} />
<div className={`my-editor tui-image-editor-container left ${!submenuVisible && "submenu-hidden"}`} ref={imageEditorRef} />
</SubmenuContext.Provider>
</>
);
}
...
...
Please
register
or
login
to post a comment