Skip to content
Snippets Groups Projects
Commit d3e73627 authored by chris's avatar chris
Browse files

layout

parent 838a136d
No related branches found
No related tags found
No related merge requests found
Pipeline #61490 passed with stages
in 3 minutes and 43 seconds
import React, { /* stylelint-disable no-descending-specificity */
useContext, import React, { useContext, useState, useCallback, useEffect } from 'react';
useState,
useCallback,
useEffect,
useMemo,
} from 'react';
import styled, { css, ThemeProvider } from 'styled-components'; import styled, { css, ThemeProvider } from 'styled-components';
import PanelGroup from 'react-panelgroup'; import PanelGroup from 'react-panelgroup';
import { import {
...@@ -21,6 +16,7 @@ const divider = css` ...@@ -21,6 +16,7 @@ const divider = css`
.panelGroup { .panelGroup {
background: #fff; background: #fff;
} }
.divider { .divider {
> div { > div {
background: ${th('colorBorder')}; background: ${th('colorBorder')};
...@@ -37,16 +33,17 @@ const divider = css` ...@@ -37,16 +33,17 @@ const divider = css`
const Wrapper = styled.div` const Wrapper = styled.div`
background: ${th('colorBackground')}; background: ${th('colorBackground')};
display: flex;
flex-direction: column;
font-family: ${th('fontInterface')}; font-family: ${th('fontInterface')};
font-size: ${th('fontSizeBase')}; font-size: ${th('fontSizeBase')};
height: 100%;
line-height: ${grid(4)}; line-height: ${grid(4)};
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
overflow: hidden; overflow: hidden;
width: 100%;
/* stylelint-disable-next-line order/properties-alphabetical-order */
${divider} ${divider}
* { * {
...@@ -61,25 +58,30 @@ const Main = styled.div` ...@@ -61,25 +58,30 @@ const Main = styled.div`
`; `;
const TopMenu = styled.div` const TopMenu = styled.div`
background: ${th('colorBackgroundToolBar')};
border-bottom: ${th('borderWidth')} ${th('borderStyle')} ${th('colorBorder')};
border-top: ${th('borderWidth')} ${th('borderStyle')} ${th('colorBorder')};
display: flex; display: flex;
min-height: 40px; min-height: 40px;
user-select: none; user-select: none;
background: ${th('colorBackgroundToolBar')};
border-top: ${th('borderWidth')} ${th('borderStyle')} ${th('colorBorder')}; > div:last-child {
border-bottom: ${th('borderWidth')} ${th('borderStyle')} ${th('colorBorder')}; margin-left: 0;
margin-right: ${grid(5)};
}
> div:not(:last-child) { > div:not(:last-child) {
border-right: ${th('borderWidth')} ${th('borderStyle')} border-right-color: ${th('colorFurniture')};
${th('colorFurniture')}; border-right-style: ${th('borderStyle')};
border-right-width: ${th('borderWidth')};
} }
> div:nth-last-of-type(-n + 2) { > div:nth-last-of-type(-n + 2) {
margin-left: auto; margin-left: auto;
} }
> div:last-child { > div[data-name='FullScreen'] {
margin-left: 0; margin: 0;
margin-right: ${grid(5)};
} }
> div[data-name='Tables'] { > div[data-name='Tables'] {
...@@ -88,10 +90,10 @@ const TopMenu = styled.div` ...@@ -88,10 +90,10 @@ const TopMenu = styled.div`
`; `;
const SideMenu = styled.div` const SideMenu = styled.div`
background: ${th('colorBackgroundToolBar')} background: ${th('colorBackgroundToolBar')};
border-right: ${th('borderWidth')} ${th('borderStyle')} ${th('colorBorder')}; border-right: ${th('borderWidth')} ${th('borderStyle')} ${th('colorBorder')};
min-width: 250px;
height: calc(100% - 16px); height: calc(100% - 16px);
min-width: 250px;
`; `;
const EditorArea = styled.div` const EditorArea = styled.div`
...@@ -99,19 +101,19 @@ const EditorArea = styled.div` ...@@ -99,19 +101,19 @@ const EditorArea = styled.div`
`; `;
const WaxSurfaceScroll = styled.div` const WaxSurfaceScroll = styled.div`
overflow-y: auto;
display: flex;
box-sizing: border-box; box-sizing: border-box;
display: flex;
height: 100%; height: 100%;
width: 100%; overflow-y: auto;
position: absolute; position: absolute;
/* PM styles for main content*/ width: 100%;
${EditorElements}; /* stylelint-disable-next-line order/properties-alphabetical-order */
${EditorElements}
`; `;
const EditorContainer = styled.div` const EditorContainer = styled.div`
width: 65%;
height: 100%; height: 100%;
width: 65%;
.ProseMirror { .ProseMirror {
box-shadow: 0 0 8px #ecedf1; box-shadow: 0 0 8px #ecedf1;
...@@ -123,38 +125,38 @@ const EditorContainer = styled.div` ...@@ -123,38 +125,38 @@ const EditorContainer = styled.div`
const CommentsContainer = styled.div` const CommentsContainer = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 35%;
height: 100%; height: 100%;
width: 35%;
`; `;
const CommentsContainerNotes = styled.div` const CommentsContainerNotes = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 35%;
height: 100%; height: 100%;
width: 35%;
`; `;
const CommentTrackToolsContainer = styled.div` const CommentTrackToolsContainer = styled.div`
background: white;
display: flex; display: flex;
position: fixed;
padding-top: 5px; padding-top: 5px;
position: fixed;
right: 30px; right: 30px;
z-index: 1;
background: white;
width: 25%; width: 25%;
z-index: 1;
`; `;
const CommentTrackTools = styled.div` const CommentTrackTools = styled.div`
margin-left: auto;
display: flex; display: flex;
margin-left: auto;
position: relative; position: relative;
z-index: 1; z-index: 1;
`; `;
const CommentTrackOptions = styled.div` const CommentTrackOptions = styled.div`
bottom: 5px;
display: flex; display: flex;
margin-left: 10px; margin-left: 10px;
bottom: 5px;
position: relative; position: relative;
`; `;
...@@ -162,10 +164,10 @@ const NotesAreaContainer = styled.div` ...@@ -162,10 +164,10 @@ const NotesAreaContainer = styled.div`
background: #fff; background: #fff;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
width: 100%;
height: 100%; height: 100%;
overflow-y: scroll; overflow-y: scroll;
position: absolute; position: absolute;
width: 100%;
/* PM styles for note content*/ /* PM styles for note content*/
.ProseMirror { .ProseMirror {
display: inline; display: inline;
...@@ -176,18 +178,19 @@ const NotesContainer = styled.div` ...@@ -176,18 +178,19 @@ const NotesContainer = styled.div`
counter-reset: footnote-view; counter-reset: footnote-view;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-top: 10px; height: 100%;
padding-bottom: ${grid(4)}; padding-bottom: ${grid(4)};
padding-left: ${grid(10)}; padding-left: ${grid(10)};
height: 100%; padding-top: 10px;
width: 65%; width: 65%;
${EditorElements}; /* stylelint-disable-next-line order/properties-alphabetical-order */
${EditorElements}
`; `;
const WaxBottomRightInfo = styled.div``; const WaxBottomRightInfo = styled.div``;
const InfoContainer = styled.div` const InfoContainer = styled.div`
bottom: 1px;
display: flex; display: flex;
position: fixed; position: fixed;
bottom: 1px;
right: 21px; right: 21px;
z-index: 999; z-index: 999;
`; `;
...@@ -216,80 +219,51 @@ const RightArea = ComponentPlugin('rightArea'); ...@@ -216,80 +219,51 @@ const RightArea = ComponentPlugin('rightArea');
const CommentTrackToolBar = ComponentPlugin('commentTrackToolBar'); const CommentTrackToolBar = ComponentPlugin('commentTrackToolBar');
const BottomRightInfo = ComponentPlugin('BottomRightInfo'); const BottomRightInfo = ComponentPlugin('BottomRightInfo');
const MyComp = ({ name }) => {
console.log(name);
return (
<div>
<span>{name}</span>
<button
onClick={() => {
console.log('ffff');
}}
>
{' '}
change config
</button>
</div>
);
};
const EditoriaLayout = props => { const EditoriaLayout = props => {
// const { const {
// pmViews: { main }, pmViews: { main },
// options, options,
// } = useContext(WaxContext); } = useContext(WaxContext);
let fullScreenStyles = {}; let fullScreenStyles = {};
// if (options.fullScreen) { if (options.fullScreen) {
// fullScreenStyles = { fullScreenStyles = {
// backgroundColor: '#fff', backgroundColor: '#fff',
// height: '100%', height: '100%',
// left: '0', left: '0',
// margin: '0', margin: '0',
// padding: '0', padding: '0',
// position: 'fixed', position: 'fixed',
// top: '0', top: '0',
// width: '100%', width: '100%',
// zIndex: '99999', zIndex: '99999',
// }; };
// } }
// const notes = main && getNotes(main); const notes = main && getNotes(main);
// const commentsTracksCount = const commentsTracksCount =
// main && DocumentHelpers.getCommentsTracksCount(main); main && DocumentHelpers.getCommentsTracksCount(main);
// const trackBlockNodesCount = const trackBlockNodesCount =
// main && DocumentHelpers.getTrackBlockNodesCount(main); main && DocumentHelpers.getTrackBlockNodesCount(main);
// const areNotes = notes && !!notes.length && notes.length > 0; const areNotes = notes && !!notes.length && notes.length > 0;
// const [hasNotes, setHasNotes] = useState(areNotes); const [hasNotes, setHasNotes] = useState(areNotes);
// const showNotes = () => { const showNotes = () => {
// setHasNotes(areNotes); setHasNotes(areNotes);
// }; };
// const delayedShowedNotes = useCallback(() => { const delayedShowedNotes = useCallback(
// const delayShowNotes = setTimeout(() => showNotes(), 100); setTimeout(() => showNotes(), 100),
// return clearInterval(delayShowNotes); [],
// }, []);
// useEffect(() => {}, [delayedShowedNotes]);
const EditoriaComponent = useMemo(
() => {
console.log('useMemo');
return <MyComp name={props?.name} />;
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[props?.name],
); );
// return <>{EditoriaComponent}</>;
console.log(props.app.id, 'layout'); useEffect(() => {}, [delayedShowedNotes]);
return ( return (
<ThemeProvider theme={cokoTheme}> <ThemeProvider theme={cokoTheme}>
<Wrapper style={fullScreenStyles} id="wax-container"> <Wrapper style={fullScreenStyles} id="wax-container">
{EditoriaComponent}
<TopMenu> <TopMenu>
<MainMenuToolBar /> <MainMenuToolBar />
</TopMenu> </TopMenu>
...@@ -303,24 +277,20 @@ const EditoriaLayout = props => { ...@@ -303,24 +277,20 @@ const EditoriaLayout = props => {
<PanelGroup <PanelGroup
direction="column" direction="column"
panelWidths={[ panelWidths={[
{ { size: surfaceHeight, resize: 'stretch' },
size: surfaceHeight, { size: notesHeight, resize: 'resize' },
resize: 'stretch',
},
{
size: notesHeight,
resize: 'resize',
},
]} ]}
onResizeEnd={onResizeEnd} onResizeEnd={onResizeEnd}
> >
<WaxSurfaceScroll> <WaxSurfaceScroll id="wax-surface-scroll" l>
<EditorContainer> <EditorContainer>
<WaxView {...props} /> <WaxView {...props} />
</EditorContainer> </EditorContainer>
<CommentsContainer> <CommentsContainer>
<CommentTrackToolsContainer> <CommentTrackToolsContainer>
<CommentTrackTools> <CommentTrackTools>
{commentsTracksCount + trackBlockNodesCount} COMMENTS AND
SUGGESTIONS
<CommentTrackOptions> <CommentTrackOptions>
<CommentTrackToolBar /> <CommentTrackToolBar />
</CommentTrackOptions> </CommentTrackOptions>
...@@ -329,6 +299,16 @@ const EditoriaLayout = props => { ...@@ -329,6 +299,16 @@ const EditoriaLayout = props => {
<RightArea area="main" /> <RightArea area="main" />
</CommentsContainer> </CommentsContainer>
</WaxSurfaceScroll> </WaxSurfaceScroll>
{hasNotes && (
<NotesAreaContainer>
<NotesContainer id="notes-container">
<NotesArea view={main} />
</NotesContainer>
<CommentsContainerNotes>
<RightArea area="notes" />
</CommentsContainerNotes>
</NotesAreaContainer>
)}
</PanelGroup> </PanelGroup>
</EditorArea> </EditorArea>
</Main> </Main>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment