wip: Updates to lab to support v3 patterns
This commit is contained in:
parent
d59bab6a6c
commit
a023f1810c
19 changed files with 101 additions and 155 deletions
|
@ -3,9 +3,11 @@ import { Chevron } from 'shared/components/navigation/primary.js'
|
|||
import OptionGroup from './option-group'
|
||||
import { Ul, Details, TopSummary, TopSumTitle } from 'shared/components/workbench/menu'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { optionsMenuStructure } from 'shared/utils.mjs'
|
||||
|
||||
const DesignOptions = props => {
|
||||
const { t } = useTranslation(['app'])
|
||||
const optionsMenu = optionsMenuStructure(props.design.config.options)
|
||||
|
||||
return (
|
||||
<Details open>
|
||||
|
@ -14,12 +16,14 @@ const DesignOptions = props => {
|
|||
<Chevron />
|
||||
</TopSummary>
|
||||
<Ul className="pl-5 list-inside">
|
||||
{Object.keys(props.design.config.optionGroups).map(group => (
|
||||
<OptionGroup {...props} group={group} key={group} />
|
||||
))}
|
||||
{Object.entries(optionsMenu).map(([group, options]) => typeof options === "string"
|
||||
? <p>top-level option</p>
|
||||
: <OptionGroup {...props} group={group} options={options} key={group} />
|
||||
)}
|
||||
</Ul>
|
||||
</Details>
|
||||
)
|
||||
}
|
||||
|
||||
export default DesignOptions
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import { useTranslation } from 'next-i18next'
|
|||
|
||||
const OptionGroup = props => {
|
||||
const { t } = useTranslation(['optiongroups'])
|
||||
const config = props.config || props.design.config.optionGroups[props.group]
|
||||
|
||||
return (
|
||||
<Li>
|
||||
<Details>
|
||||
|
@ -19,10 +19,10 @@ const OptionGroup = props => {
|
|||
<Chevron />
|
||||
</Summary>
|
||||
<Ul>
|
||||
{config.map(option =>
|
||||
typeof option === 'string' ? <Option {...props} option={option} key={option} />
|
||||
: Object.keys(option).map((sub) => <OptionGroup {...props} config={option[sub]} group={sub} key={sub}/>)
|
||||
)}
|
||||
{Object.entries(props.options).map(([option, type]) => typeof type === "string"
|
||||
? <Option {...props} type={type} option={option} key={option} />
|
||||
: <OptionGroup {...props} group={option} options={type} key={option}/>)
|
||||
}
|
||||
</Ul>
|
||||
</Details>
|
||||
</Li>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue