-
Notifications
You must be signed in to change notification settings - Fork 373
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
48 changed files
with
274 additions
and
168 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 was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
...el/input-panels/ContainerSidebarPanel.tsx → ...el/input-panels/ContainerSidebarPanel.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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions
16
packages/editor-sample/src/App/InspectorDrawer/ToggleInspectorPanelButton.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,16 @@ | ||
import React from 'react'; | ||
|
||
import { Button } from '@mui/material'; | ||
|
||
import { useEditorState } from '../../documents/editor/EditorContext'; | ||
|
||
export default function ToggleInspectorPanelButton() { | ||
const [{ inspectorDrawerOpen }, setEditorState] = useEditorState(); | ||
const handleClick = () => { | ||
setEditorState({ inspectorDrawerOpen: !inspectorDrawerOpen }); | ||
}; | ||
if (inspectorDrawerOpen) { | ||
return <Button onClick={handleClick}>CLOSE</Button>; | ||
} | ||
return <Button onClick={handleClick}>OPEN</Button>; | ||
} |
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,44 @@ | ||
import React from 'react'; | ||
|
||
import { Box, Drawer, Tab, Tabs } from '@mui/material'; | ||
|
||
import { useEditorState } from '../../documents/editor/EditorContext'; | ||
|
||
import ConfigurationPanel from './ConfigurationPanel'; | ||
import StylesPanel from './StylesPanel'; | ||
|
||
export const INSPECTOR_DRAWER_WIDTH = 400; | ||
|
||
export default function InspectorDrawer() { | ||
const [{ selectedSidebarTab, inspectorDrawerOpen }, setEditorState] = useEditorState(); | ||
|
||
const renderCurrentSidebarPanel = () => { | ||
switch (selectedSidebarTab) { | ||
case 'block-configuration': | ||
return <ConfigurationPanel />; | ||
case 'styles': | ||
return <StylesPanel />; | ||
} | ||
}; | ||
|
||
return ( | ||
<Drawer | ||
variant="persistent" | ||
anchor="right" | ||
open={inspectorDrawerOpen} | ||
sx={{ | ||
width: inspectorDrawerOpen ? INSPECTOR_DRAWER_WIDTH : 0, | ||
}} | ||
> | ||
<Box sx={{ width: INSPECTOR_DRAWER_WIDTH, height: 49, borderBottom: 1, borderColor: 'divider' }}> | ||
<Box px={2}> | ||
<Tabs value={selectedSidebarTab} onChange={(_, v) => setEditorState({ selectedSidebarTab: v })}> | ||
<Tab value="styles" label="Styles" /> | ||
<Tab value="block-configuration" label="Inspect" /> | ||
</Tabs> | ||
</Box> | ||
</Box> | ||
<Box sx={{ height: 'calc(100% - 49px)', overflow: 'auto' }}>{renderCurrentSidebarPanel()}</Box> | ||
</Drawer> | ||
); | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/editor-sample/src/App/SamplesDrawer/ToggleSamplesPanelButton.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,16 @@ | ||
import React from 'react'; | ||
|
||
import { Button } from '@mui/material'; | ||
|
||
import { useEditorState } from '../../documents/editor/EditorContext'; | ||
|
||
export default function ToggleSamplesPanelButton() { | ||
const [{ samplesDrawerOpen }, setEditorState] = useEditorState(); | ||
const handleClick = () => { | ||
setEditorState({ samplesDrawerOpen: !samplesDrawerOpen }); | ||
}; | ||
if (samplesDrawerOpen) { | ||
return <Button onClick={handleClick}>CLOSE</Button>; | ||
} | ||
return <Button onClick={handleClick}>OPEN</Button>; | ||
} |
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 @@ | ||
import React from 'react'; | ||
|
||
import { Box, Button, Drawer } from '@mui/material'; | ||
|
||
import { useEditorState } from '../../documents/editor/EditorContext'; | ||
|
||
export const SAMPLES_DRAWER_WIDTH = 400; | ||
|
||
export default function SamplesDrawer() { | ||
const [{ samplesDrawerOpen }] = useEditorState(); | ||
|
||
const select = (val: string) => { | ||
window.location.hash = `#sample/${val}`; | ||
}; | ||
|
||
return ( | ||
<Drawer | ||
variant="persistent" | ||
anchor="left" | ||
open={samplesDrawerOpen} | ||
sx={{ | ||
width: samplesDrawerOpen ? SAMPLES_DRAWER_WIDTH : 0, | ||
}} | ||
> | ||
<Box width={SAMPLES_DRAWER_WIDTH}> | ||
<Button onClick={() => select('one-time-password')}>one-time-password</Button> | ||
<Button onClick={() => select('order-ecomerce')}>order-ecomerce</Button> | ||
<Button onClick={() => select('post-metrics-report')}>post-metrics-report</Button> | ||
<Button onClick={() => select('reservation-reminder')}>reservation-reminder</Button> | ||
<Button onClick={() => select('reset-password')}>reset-password</Button> | ||
<Button onClick={() => select('respond-to-message')}>respond-to-message</Button> | ||
<Button onClick={() => select('subscription-receipt')}>subscription-receipt</Button> | ||
</Box> | ||
</Drawer> | ||
); | ||
} |
File renamed without changes.
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,62 @@ | ||
import React from 'react'; | ||
|
||
import { Box, Stack, Tab, Tabs } from '@mui/material'; | ||
|
||
import EditorBlock from '../../documents/editor/EditorBlock'; | ||
import { useEditorState } from '../../documents/editor/EditorContext'; | ||
import ReaderBlock from '../../documents/reader/ReaderBlock'; | ||
import { ReaderProvider } from '../../documents/reader/ReaderContext'; | ||
import ToggleInspectorPanelButton from '../InspectorDrawer/ToggleInspectorPanelButton'; | ||
import ToggleSamplesPanelButton from '../SamplesDrawer/ToggleSamplesPanelButton'; | ||
|
||
import HtmlPanel from './HtmlPanel'; | ||
import ShareButton from './ShareButton'; | ||
|
||
export default function TemplatePanel() { | ||
const [{ document, selectedMainTab }, setEditorState] = useEditorState(); | ||
|
||
const renderMainPanel = () => { | ||
switch (selectedMainTab) { | ||
case 'editor': | ||
return <EditorBlock id="root" />; | ||
case 'preview': | ||
return ( | ||
<ReaderProvider value={document}> | ||
<ReaderBlock id="root" /> | ||
</ReaderProvider> | ||
); | ||
case 'html': | ||
return <HtmlPanel />; | ||
case 'data': | ||
return ( | ||
<Box p={3}> | ||
<pre>{JSON.stringify(document, null, ' ')}</pre> | ||
</Box> | ||
); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Stack | ||
sx={{ height: 49, borderBottom: 1, borderColor: 'divider', backgroundColor: 'white' }} | ||
direction="row" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
> | ||
<ToggleSamplesPanelButton /> | ||
<Tabs value={selectedMainTab} onChange={(_, v) => setEditorState({ selectedMainTab: v })}> | ||
<Tab value="editor" label="Edit" /> | ||
<Tab value="preview" label="Preview" /> | ||
<Tab value="html" label="HTML" /> | ||
<Tab value="data" label="JSON" /> | ||
</Tabs> | ||
<Box pr={3}> | ||
<ShareButton /> | ||
<ToggleInspectorPanelButton /> | ||
</Box> | ||
</Stack> | ||
<Box sx={{ height: 'calc(100% - 49px)', overflow: 'auto' }}>{renderMainPanel()}</Box> | ||
</> | ||
); | ||
} |
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,83 +1,45 @@ | ||
import React from 'react'; | ||
|
||
import { Box, Grid, Stack, Tab, Tabs } from '@mui/material'; | ||
import { Stack, useTheme } from '@mui/material'; | ||
|
||
import EditorBlock from '../documents/editor/EditorBlock'; | ||
import { useEditorState } from '../documents/editor/EditorContext'; | ||
import ReaderBlock from '../documents/reader/ReaderBlock'; | ||
import { ReaderProvider } from '../documents/reader/ReaderContext'; | ||
|
||
import ExamplesButton from './ExamplesButton'; | ||
import HtmlPanel from './panels/HtmlPanel'; | ||
import ShareButton from './ShareButton'; | ||
import ConfigurationPanel from './sidebar/ConfigurationPanel'; | ||
import StylesPanel from './sidebar/StylesPanel'; | ||
import InspectorDrawer, { INSPECTOR_DRAWER_WIDTH } from './InspectorDrawer'; | ||
import SamplesDrawer, { SAMPLES_DRAWER_WIDTH } from './SamplesDrawer'; | ||
import TemplatePanel from './TemplatePanel'; | ||
|
||
export default function App() { | ||
const [{ document, selectedSidebarTab, selectedMainTab }, setEditorState] = useEditorState(); | ||
|
||
const renderCurrentSidebarPanel = () => { | ||
switch (selectedSidebarTab) { | ||
case 'block-configuration': | ||
return <ConfigurationPanel />; | ||
case 'styles': | ||
return <StylesPanel />; | ||
} | ||
}; | ||
const renderMainPanel = () => { | ||
switch (selectedMainTab) { | ||
case 'editor': | ||
return <EditorBlock id="root" />; | ||
case 'preview': | ||
return ( | ||
<ReaderProvider value={document}> | ||
<ReaderBlock id="root" /> | ||
</ReaderProvider> | ||
); | ||
case 'html': | ||
return <HtmlPanel />; | ||
case 'data': | ||
return ( | ||
<Box p={3}> | ||
<pre>{JSON.stringify(document, null, ' ')}</pre> | ||
</Box> | ||
); | ||
} | ||
}; | ||
const theme = useTheme(); | ||
const [{ inspectorDrawerOpen, samplesDrawerOpen }] = useEditorState(); | ||
|
||
return ( | ||
<Grid container height="100%"> | ||
<Grid item xs={6} sm={6} md="auto" sx={{ height: '100%', backgroundColor: 'white' }}> | ||
<Box sx={{ height: 49, width: 400, borderBottom: 1, borderColor: 'divider' }}> | ||
<Box px={2}> | ||
<Tabs value={selectedSidebarTab} onChange={(_, v) => setEditorState({ selectedSidebarTab: v })}> | ||
<Tab value="styles" label="Styles" /> | ||
<Tab value="block-configuration" label="Inspect" /> | ||
</Tabs> | ||
</Box> | ||
</Box> | ||
<Box sx={{ height: 'calc(100% - 49px)', overflow: 'auto' }}>{renderCurrentSidebarPanel()}</Box> | ||
</Grid> | ||
<Grid item xs height="100%" padding={0} margin={0} sx={{ overflowY: 'auto' }}> | ||
<Stack | ||
sx={{ height: 49, borderBottom: 1, borderColor: 'divider', backgroundColor: 'white' }} | ||
direction="row" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
> | ||
<Tabs value={selectedMainTab} onChange={(_, v) => setEditorState({ selectedMainTab: v })}> | ||
<Tab value="editor" label="Edit" /> | ||
<Tab value="preview" label="Preview" /> | ||
<Tab value="html" label="HTML" /> | ||
<Tab value="data" label="JSON" /> | ||
</Tabs> | ||
<Box pr={3}> | ||
<ExamplesButton /> | ||
<ShareButton /> | ||
</Box> | ||
</Stack> | ||
<Box sx={{ height: 'calc(100% - 49px)', overflow: 'auto' }}>{renderMainPanel()}</Box> | ||
</Grid> | ||
</Grid> | ||
<> | ||
<InspectorDrawer /> | ||
<SamplesDrawer /> | ||
|
||
<Stack | ||
sx={{ | ||
marginRight: inspectorDrawerOpen ? `${INSPECTOR_DRAWER_WIDTH}px` : 0, | ||
marginLeft: samplesDrawerOpen ? `${SAMPLES_DRAWER_WIDTH}px` : 0, | ||
|
||
transition: [ | ||
theme.transitions.create('margin-left', { | ||
easing: !samplesDrawerOpen ? theme.transitions.easing.sharp : theme.transitions.easing.easeOut, | ||
duration: !samplesDrawerOpen | ||
? theme.transitions.duration.leavingScreen | ||
: theme.transitions.duration.enteringScreen, | ||
}), | ||
theme.transitions.create('margin-right', { | ||
easing: !inspectorDrawerOpen ? theme.transitions.easing.sharp : theme.transitions.easing.easeOut, | ||
duration: !inspectorDrawerOpen | ||
? theme.transitions.duration.leavingScreen | ||
: theme.transitions.duration.enteringScreen, | ||
}), | ||
].join(', '), | ||
}} | ||
> | ||
<TemplatePanel /> | ||
</Stack> | ||
</> | ||
); | ||
} |
Oops, something went wrong.