feat(lab): Working on reporting back absolute options
This commit is contained in:
parent
ae78b16240
commit
5af516cc31
7 changed files with 202 additions and 7 deletions
|
@ -1,7 +1,46 @@
|
|||
import { linkClasses, Chevron } from 'shared/components/navigation/primary.js'
|
||||
import PercentOption from 'shared/components/workbench/inputs/design-option-percentage'
|
||||
import { formatMm, formatPercentage, optionType } from 'shared/utils.js'
|
||||
|
||||
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'
|
||||
: 'text-accent'
|
||||
}>
|
||||
{formatPercentage(val)}
|
||||
{props.pattern.config.options[props.option]?.toAbs
|
||||
? ' | ' +formatMm(props.pattern.config.options[props.option]?.toAbs(val, props.gist))
|
||||
: null
|
||||
}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const Tmp = props => <p>not yet</p>
|
||||
|
||||
const inputs = {
|
||||
pct: PercentOption,
|
||||
bool: Tmp,
|
||||
count: Tmp,
|
||||
deg: Tmp,
|
||||
list: Tmp,
|
||||
mm: Tmp,
|
||||
constant: Tmp,
|
||||
}
|
||||
|
||||
|
||||
const Option = props => {
|
||||
const type = optionType(props.pattern.config.options[props.option])
|
||||
const Input = inputs[type]
|
||||
const Value = values[type]
|
||||
|
||||
return (
|
||||
<li className="flex flex-row">
|
||||
<details className="grow">
|
||||
|
@ -30,16 +69,13 @@ const Option = props => {
|
|||
{ props.app.t(`options.${props.pattern.config.name}.${props.option}.title`) }
|
||||
</span>
|
||||
</div>
|
||||
<Value type={type} {...props} />
|
||||
<Chevron w={6} m={3}/>
|
||||
</summary>
|
||||
{props.pattern.config.options[props.option]?.pct && <PercentOption {...props} />}
|
||||
<pre>{JSON.stringify(props.pattern.config.options[props.option],null,2)}</pre>
|
||||
|
||||
fixme
|
||||
<Input {...props} />
|
||||
</details>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
//props.pattern.config.optionsgroups[props.group].map(option => (
|
||||
export default Option
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue