chore: Linter warnings
This commit is contained in:
parent
347d666ce7
commit
a68f81ec73
22 changed files with 241 additions and 27 deletions
|
@ -1,7 +1,6 @@
|
|||
import { useState } from 'react'
|
||||
import { formatMm } from 'shared/utils.js'
|
||||
import ClearIcon from 'shared/components/icons/clear.js'
|
||||
import EditIcon from 'shared/components/icons/edit.js'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
const CoreSettingMm = props => {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { useState } from 'react'
|
||||
import { formatMm } from 'shared/utils.js'
|
||||
import ClearIcon from 'shared/components/icons/clear.js'
|
||||
import EditIcon from 'shared/components/icons/edit.js'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
const CoreSettingMm = props => {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Chevron } from 'shared/components/navigation/primary.js'
|
||||
import PctDegOption from 'shared/components/workbench/inputs/design-option-pct-deg'
|
||||
import CountOption from 'shared/components/workbench/inputs/design-option-count'
|
||||
import ListSetting from './core-setting-list'
|
||||
import OnlySetting from './core-setting-only'
|
||||
import MmSetting from './core-setting-mm'
|
||||
|
@ -8,7 +7,7 @@ import NrSetting from './core-setting-nr'
|
|||
import BoolSetting from './core-setting-bool.js'
|
||||
import SaBoolSetting from './core-setting-sa-bool.js'
|
||||
import SaMmSetting from './core-setting-sa-mm.js'
|
||||
import { formatMm, formatPercentage, optionType } from 'shared/utils.js'
|
||||
import { formatMm } from 'shared/utils.js'
|
||||
import { SecText, Li, Details, Summary, SumDiv, Deg } from 'shared/components/workbench/menu/index.js'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import ViewMenu from './view.js'
|
|||
import DesignOptions from './design-options'
|
||||
import CoreSettings from './core-settings'
|
||||
import Xray from './xray'
|
||||
import TestDesignOptions from './test-design-options'
|
||||
|
||||
export const Ul = props => <ul className="pl-5 list-inside">{props.children}</ul>
|
||||
export const Li = props => (
|
||||
|
@ -92,6 +93,11 @@ const WorkbenchMenu = props => {
|
|||
{props.gist.renderer === 'react' && <Xray {...props} />}
|
||||
</>
|
||||
)}
|
||||
{props.gist?._state?.view === 'test' && (
|
||||
<>
|
||||
<TestDesignOptions {...props} />
|
||||
</>
|
||||
)}
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import OptionsIcon from 'shared/components/icons/options.js'
|
||||
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'
|
||||
|
||||
const DesignOptions = props => {
|
||||
const { t } = useTranslation(['app'])
|
||||
|
||||
return (
|
||||
<Details open>
|
||||
<TopSummary icon={<OptionsIcon />}>
|
||||
<TopSumTitle>{t('designOptions')}</TopSumTitle>
|
||||
<Chevron />
|
||||
</TopSummary>
|
||||
<Ul className="pl-5 list-inside">
|
||||
{Object.keys(props.pattern.config.optionGroups).map(group => (
|
||||
<OptionGroup {...props} group={group} key={group} />
|
||||
))}
|
||||
</Ul>
|
||||
</Details>
|
||||
)
|
||||
}
|
||||
|
||||
export default DesignOptions
|
|
@ -0,0 +1,33 @@
|
|||
import { Chevron } from 'shared/components/navigation/primary.js'
|
||||
import Option from './option'
|
||||
import OptionSubGroup from './option-sub-group'
|
||||
import { Li, Ul, Details, Summary, SumDiv, Deg } from 'shared/components/workbench/menu'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
const OptionGroup = props => {
|
||||
const { t } = useTranslation(['optiongroups'])
|
||||
const config = props.config || props.pattern.config.optionGroups[props.group]
|
||||
return (
|
||||
<Li>
|
||||
<Details>
|
||||
<Summary>
|
||||
<SumDiv>
|
||||
<Deg />
|
||||
<span className="font-bold">
|
||||
{ t(props.group) }
|
||||
</span>
|
||||
</SumDiv>
|
||||
<Chevron />
|
||||
</Summary>
|
||||
<Ul>
|
||||
{config.map(option => typeof option === 'string'
|
||||
? <Option {...props} option={option} key={option} />
|
||||
: <OptionSubGroup {...props} sub={option} config={config} />
|
||||
)}
|
||||
</Ul>
|
||||
</Details>
|
||||
</Li>
|
||||
)
|
||||
}
|
||||
|
||||
export default OptionGroup
|
|
@ -0,0 +1,29 @@
|
|||
import { linkClasses, Chevron } from 'shared/components/navigation/primary.js'
|
||||
import Option from './option'
|
||||
import { Li, Ul, Details, Summary, SumButton, SumDiv, Deg } from 'shared/components/workbench/menu'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
const OptionSubGroup = props => {
|
||||
const { t } = useTranslation(['optiongroups'])
|
||||
return Object.keys(props.sub).map(name => (
|
||||
<Li>
|
||||
<Details>
|
||||
<Summary>
|
||||
<SumDiv>
|
||||
<Deg />
|
||||
<span className="font-bold">{ t(name) }</span>
|
||||
</SumDiv>
|
||||
<Chevron />
|
||||
</Summary>
|
||||
<Ul>
|
||||
{props.sub[name].map(option => typeof option === 'string'
|
||||
? <Option {...props} option={option} key={option} />
|
||||
: <OptionSubGroup {...props} sub={option} config={config} />
|
||||
)}
|
||||
</Ul>
|
||||
</Details>
|
||||
</Li>
|
||||
))
|
||||
}
|
||||
|
||||
export default OptionSubGroup
|
|
@ -0,0 +1,129 @@
|
|||
import { Chevron } from 'shared/components/navigation/primary.js'
|
||||
import PctDegOption from 'shared/components/workbench/inputs/design-option-pct-deg'
|
||||
import CountOption from 'shared/components/workbench/inputs/design-option-count'
|
||||
import ListOption from 'shared/components/workbench/inputs/design-option-list'
|
||||
import { formatMm, formatPercentage, optionType } from 'shared/utils.js'
|
||||
import { Li, Ul, Details, Summary, SumButton, SumDiv, Deg } from 'shared/components/workbench/menu'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
const values = {
|
||||
pct: props => {
|
||||
const val = (typeof props.gist?.options?.[props.option] === 'undefined')
|
||||
? props.pattern.config.options[props.option].pct/100
|
||||
: props.gist.options[props.option]
|
||||
return (
|
||||
<span className={
|
||||
val=== props.pattern.config.options[props.option].pct/100
|
||||
? 'text-secondary-focus'
|
||||
: 'text-accent'
|
||||
}>
|
||||
{formatPercentage(val)}
|
||||
{props.pattern.config.options[props.option]?.toAbs
|
||||
? ' | ' +formatMm(props.pattern.config.options[props.option]?.toAbs(val, props.gist))
|
||||
: null
|
||||
}
|
||||
</span>
|
||||
)
|
||||
},
|
||||
bool: props => {
|
||||
const { t } = useTranslation(['app'])
|
||||
const dflt = props.pattern.config.options[props.option].bool
|
||||
const current = props.gist?.options?.[props.option]
|
||||
return (
|
||||
<span className={
|
||||
(dflt==current || typeof current === 'undefined')
|
||||
? 'text-secondary-focus'
|
||||
: 'text-accent'
|
||||
}>
|
||||
{props.gist?.options?.[props.option]
|
||||
? t('yes')
|
||||
: t('no')
|
||||
}
|
||||
</span>
|
||||
)
|
||||
},
|
||||
count: props => {
|
||||
const dflt = props.pattern.config.options[props.option].count
|
||||
const current = props.gist?.options?.[props.option]
|
||||
return (dflt==current || typeof current === 'undefined')
|
||||
? <span className="text-secondary-focus">{dflt}</span>
|
||||
: <span className="text-accent">{current}</span>
|
||||
},
|
||||
list: props => {
|
||||
const dflt = props.pattern.config.options[props.option].dflt
|
||||
const current = props.gist?.options?.[props.option]
|
||||
const prefix = `${props.option}.o.`
|
||||
return (dflt==current || typeof current === 'undefined')
|
||||
? <span className="text-secondary-focus">{props.t(prefix+dflt)}</span>
|
||||
: <span className="text-accent">{props.t(prefix+current)}</span>
|
||||
},
|
||||
deg: props => {
|
||||
const dflt = props.pattern.config.options[props.option].deg
|
||||
const current = props.gist?.options?.[props.option]
|
||||
return (dflt==current || typeof current === 'undefined')
|
||||
? <span className="text-secondary-focus">{dflt}°</span>
|
||||
: <span className="text-accent">{current}°</span>
|
||||
},
|
||||
mm: props => {
|
||||
return <p>No mm val yet</p>
|
||||
},
|
||||
constant: props => {
|
||||
return <p>No constant val yet</p>
|
||||
},
|
||||
}
|
||||
|
||||
const Tmp = props => <p>not yet</p>
|
||||
|
||||
const inputs = {
|
||||
pct: PctDegOption,
|
||||
count: CountOption,
|
||||
deg: props => <PctDegOption {...props} type='deg' />,
|
||||
list: ListOption,
|
||||
mm: <p>Mm options are not supported. Please report this.</p>,
|
||||
constant: Tmp,
|
||||
}
|
||||
|
||||
|
||||
const Option = props => {
|
||||
const { t } = useTranslation([`o_${props.pattern.config.name}`])
|
||||
const type = optionType(props.pattern.config.options[props.option])
|
||||
const Input = inputs[type]
|
||||
const Value = values[type]
|
||||
|
||||
const toggleBoolean = () => {
|
||||
const dflt = props.pattern.config.options[props.option].bool
|
||||
const current = props.gist?.options?.[props.option]
|
||||
if (typeof current === 'undefined')
|
||||
props.updateGist(['options', props.option], !dflt)
|
||||
else props.unsetGist(['options', props.option])
|
||||
}
|
||||
|
||||
return (type === 'bool')
|
||||
? (
|
||||
<Li>
|
||||
<SumButton onClick={toggleBoolean}>
|
||||
<SumDiv>
|
||||
<Deg />
|
||||
<span>{t(`${props.option}.t`) }</span>
|
||||
</SumDiv>
|
||||
<Value type={type} {...props} t={t} />
|
||||
</SumButton>
|
||||
</Li>
|
||||
) : (
|
||||
<Li>
|
||||
<Details>
|
||||
<Summary>
|
||||
<SumDiv>
|
||||
<Deg />
|
||||
<span>{t(`${props.option}.t`)}</span>
|
||||
</SumDiv>
|
||||
<Value type={type} {...props} t={t} />
|
||||
<Chevron w={6} m={3}/>
|
||||
</Summary>
|
||||
<Input {...props} ot={t} />
|
||||
</Details>
|
||||
</Li>
|
||||
)
|
||||
}
|
||||
|
||||
export default Option
|
|
@ -1,5 +1,4 @@
|
|||
import MenuIcon from 'shared/components/icons/menu.js'
|
||||
import OptionsIcon from 'shared/components/icons/options.js'
|
||||
import { linkClasses, Chevron } from 'shared/components/navigation/primary.js'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
|
|
|
@ -15,8 +15,7 @@ const types = {
|
|||
const XrayList = props => {
|
||||
const { t } = useTranslation(['app', 'parts'])
|
||||
|
||||
let title = t(`parts:${props.partName}`)
|
||||
if (title !== props.partName || true) title + ` (${props.partName})`
|
||||
const title = t(`parts:${props.partName}`) + ` (${props.partName})`
|
||||
|
||||
const part = props.gist.xray.parts[props.partName]
|
||||
|
||||
|
@ -82,7 +81,7 @@ const XrayList = props => {
|
|||
</SumDiv>
|
||||
<button
|
||||
className={`px-3 hover:text-secondary-focus"
|
||||
${props.gist?.xray?.reveal?.[props.partName]?.[type]?.[id]
|
||||
${props.gist.xray?.reveal?.[props.partName]?.[type]?.[id]
|
||||
? 'text-accent'
|
||||
: 'text-secondary'
|
||||
}`}
|
||||
|
|
|
@ -9,12 +9,12 @@ const XrayPath = ({ pathName, partName, draft, t, units }) => {
|
|||
if (!path) return null
|
||||
return (
|
||||
<Ul>
|
||||
<Attributes attr={path?.attributes} />
|
||||
<Attributes attr={path.attributes} />
|
||||
<Li>
|
||||
<NoSumDiv>
|
||||
<Deg />
|
||||
<span className="font-bold mr-2">path.render =</span>
|
||||
<span>{JSON.stringify(path?.render)}</span>
|
||||
<span>{JSON.stringify(path.render)}</span>
|
||||
</NoSumDiv>
|
||||
</Li>
|
||||
<Li>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue