From e986ec33e924c26040d620fe7ef28007601ded20 Mon Sep 17 00:00:00 2001 From: joostdecock Date: Thu, 18 May 2023 14:06:22 +0200 Subject: [PATCH] fix(shared): Deal with list option inputs --- .../workbench/menus/design-options/index.mjs | 8 +++-- .../workbench/menus/design-options/inputs.mjs | 29 +++++-------------- .../workbench/menus/design-options/values.mjs | 2 +- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/sites/shared/components/workbench/menus/design-options/index.mjs b/sites/shared/components/workbench/menus/design-options/index.mjs index b70827b4abe..c2d11682c41 100644 --- a/sites/shared/components/workbench/menus/design-options/index.mjs +++ b/sites/shared/components/workbench/menus/design-options/index.mjs @@ -67,16 +67,18 @@ const values = { // Emojis for option groups :) const emojis = { + advanced: '🤓', fit: '👕', style: '💃đŸŊ', dflt: 'đŸ•šī¸', + groupDflt: '📁', } const GroupTitle = ({ group, t, open = false }) => (
- {emojis[group] ? emojis[group] : emojis.dflt} + {emojis[group] ? emojis[group] : emojis.groupDflt} {t(`design-options:${group}.t`)} {open ? ':' : ''} @@ -138,7 +140,7 @@ export const DesignOption = ({ , ] - if (['pct'].includes(type)) + if (['pct', 'count'].includes(type)) openButtons.push(
) -export const CountOptionInput = ({ name, config, current, update, t }) => { +export const CountOptionInput = ({ name, design, config, current, update, t, override }) => { const { count, max, min } = config if (typeof current === 'undefined') current = count const [value, setValue] = useState(current) - const [editCount, setEditCount] = useState(false) const handleChange = (evt) => { const newCurrent = evt.target.value @@ -43,10 +42,11 @@ export const CountOptionInput = ({ name, config, current, update, t }) => { } return ( -
+ <> +

{t(`${design}:o.${name}.d`)}

- {editCount ? ( - + {override ? ( + ) : ( <> {min} @@ -64,25 +64,10 @@ export const CountOptionInput = ({ name, config, current, update, t }) => { onChange={handleChange} className={` range range-sm mt-1 - ${val === count ? 'range-secondary' : 'range-accent'} + ${current === count ? 'range-secondary' : 'range-accent'} `} /> -
- -
- -
-
-
+ ) } diff --git a/sites/shared/components/workbench/menus/design-options/values.mjs b/sites/shared/components/workbench/menus/design-options/values.mjs index 9821e0cb0c5..d5470f7dec1 100644 --- a/sites/shared/components/workbench/menus/design-options/values.mjs +++ b/sites/shared/components/workbench/menus/design-options/values.mjs @@ -35,7 +35,7 @@ export const CountOptionValue = ({ name, config, current }) => ) export const ListOptionValue = ({ name, config, current, t }) => { - const translate = config.doNotTranslate ? (input) => input : (input) => t(`${option}.o.${input}`) + const translate = config.doNotTranslate ? (input) => input : (input) => t(`${name}.o.${input}`) return config.dflt == current || typeof current === 'undefined' ? ( {translate(config.dflt)}