-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement metadata panel new design (#687)
- Loading branch information
Showing
33 changed files
with
439 additions
and
338 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,38 @@ | ||
import * as React from 'react' | ||
import capitalize from 'lodash/capitalize' | ||
import Box from '@mui/material/Box' | ||
import Columns from '../../Parts/Grids/Columns' | ||
import MenuTree from '../../Parts/Trees/Menu' | ||
import EditorHelp from '../Base/Help' | ||
import DialectSection from './Sections/Dialect' | ||
import FormatSection from './Sections/Format' | ||
import { useStore } from './store' | ||
import * as types from '../../../types' | ||
import { useTranslation } from 'react-i18next' | ||
import SimpleTabs from '../../Parts/Tabs/SimpleTabs' | ||
|
||
export default function Layout() { | ||
const externalMenu = useStore((state) => state.externalMenu) | ||
return ( | ||
<Box sx={{ height: '100%' }}> | ||
{!externalMenu ? <LayoutWithMenu /> : <LayoutWithoutMenu />} | ||
</Box> | ||
) | ||
} | ||
|
||
function LayoutWithMenu() { | ||
const format = useStore((state) => state.format) | ||
const section = useStore((state) => state.section) | ||
const updateHelp = useStore((state) => state.updateHelp) | ||
const updateState = useStore((state) => state.updateState) | ||
const { t } = useTranslation() | ||
|
||
const MENU_ITEMS: types.IMenuItem[] = [ | ||
{ section: 'dialect', name: t('dialect') }, | ||
{ section: 'dialect', name: t('default') }, | ||
{ section: 'dialect/format', name: capitalize(format) || t('format') }, | ||
] | ||
return ( | ||
<Columns spacing={3} layout={[2, 8]} columns={10}> | ||
<Box sx={{ padding: 2, borderRight: 'solid 1px #ddd', height: '100%' }}> | ||
<MenuTree | ||
menuItems={MENU_ITEMS} | ||
selected={section} | ||
defaultExpanded={['dialect']} | ||
onSelect={(section) => { | ||
updateHelp(section) | ||
updateState({ section }) | ||
}} | ||
/> | ||
</Box> | ||
<LayoutWithoutMenu /> | ||
</Columns> | ||
) | ||
} | ||
|
||
function LayoutWithoutMenu() { | ||
const section = useStore((state) => state.externalMenu?.section || state.section) | ||
const updateHelp = useStore((state) => state.updateHelp) | ||
const helpItem = useStore((state) => state.helpItem) | ||
React.useEffect(() => updateHelp(section), [section]) | ||
if (!section) return null | ||
const MENU_LABELS = MENU_ITEMS.map((item) => item.name) | ||
|
||
return ( | ||
<Columns spacing={3} layout={[5, 3]} columns={8}> | ||
<Box> | ||
<Box hidden={section !== 'dialect'}> | ||
<DialectSection /> | ||
</Box> | ||
<Box hidden={section !== 'dialect/format'}> | ||
<FormatSection /> | ||
</Box> | ||
</Box> | ||
<EditorHelp helpItem={helpItem} /> | ||
</Columns> | ||
<Box sx={{ height: '100%' }}> | ||
<SimpleTabs | ||
labels={MENU_LABELS} | ||
orientation="vertical" | ||
onChange={(newValue: number) => { | ||
updateHelp(MENU_ITEMS[newValue].section) | ||
updateState({ section: MENU_ITEMS[newValue].section }) | ||
}} | ||
> | ||
<DialectSection /> | ||
<FormatSection /> | ||
</SimpleTabs> | ||
</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
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.