-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using state setters instead of setEditorState (#55)
- Loading branch information
Showing
14 changed files
with
179 additions
and
154 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 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
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
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
59 changes: 59 additions & 0 deletions
59
packages/editor-sample/src/App/TemplatePanel/MainTabsGroup.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,59 @@ | ||
import React from 'react'; | ||
|
||
import { CodeOutlined, DataObjectOutlined, EditOutlined, PreviewOutlined } from '@mui/icons-material'; | ||
import { Tab, Tabs, Tooltip } from '@mui/material'; | ||
|
||
import { setSelectedMainTab, useSelectedMainTab } from '../../documents/editor/EditorContext'; | ||
|
||
export default function MainTabsGroup() { | ||
const selectedMainTab = useSelectedMainTab(); | ||
const handleChange = (_: unknown, v: unknown) => { | ||
switch (v) { | ||
case 'data': | ||
case 'editor': | ||
case 'preview': | ||
case 'html': | ||
setSelectedMainTab(v); | ||
return; | ||
default: | ||
setSelectedMainTab('data'); | ||
} | ||
}; | ||
|
||
return ( | ||
<Tabs value={selectedMainTab} onChange={handleChange}> | ||
<Tab | ||
value="editor" | ||
label={ | ||
<Tooltip title="Edit"> | ||
<EditOutlined fontSize="small" /> | ||
</Tooltip> | ||
} | ||
/> | ||
<Tab | ||
value="preview" | ||
label={ | ||
<Tooltip title="Preview"> | ||
<PreviewOutlined fontSize="small" /> | ||
</Tooltip> | ||
} | ||
/> | ||
<Tab | ||
value="html" | ||
label={ | ||
<Tooltip title="HTML output"> | ||
<CodeOutlined fontSize="small" /> | ||
</Tooltip> | ||
} | ||
/> | ||
<Tab | ||
value="data" | ||
label={ | ||
<Tooltip title="JSON output"> | ||
<DataObjectOutlined fontSize="small" /> | ||
</Tooltip> | ||
} | ||
/> | ||
</Tabs> | ||
); | ||
} |
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
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
Oops, something went wrong.