diff --git a/sites/shared/components/accordion.mjs b/sites/shared/components/accordion.mjs new file mode 100644 index 00000000000..5958b6f2d7a --- /dev/null +++ b/sites/shared/components/accordion.mjs @@ -0,0 +1,58 @@ +import { useState } from 'react' +/* + * DaisyUI's accordion seems rather unreliable. + * So instead, we handle this in React state + */ +export const Accordion = ({ + items, // Items in the accordion +}) => { + const [active, setActive] = useState() + + return ( + + ) +} + +export const SubAccordion = ({ + items, // Items in the accordion +}) => { + const [active, setActive] = useState() + + return ( + + ) +} diff --git a/sites/shared/components/inputs.mjs b/sites/shared/components/inputs.mjs index 1031b908655..c86ef56bf65 100644 --- a/sites/shared/components/inputs.mjs +++ b/sites/shared/components/inputs.mjs @@ -109,14 +109,17 @@ export const ButtonFrame = ({ children, // Children of the button onClick, // onClick handler active, // Whether or not to render the button as active/selected + accordion = false, // Set this to true to not set a background color when active }) => ( - ) if (allowOverride) - openButtons.push( + buttons.push( ) const ResetButton = ({ open, disabled = false }) => ( ) - if (changed && !allowToggle) { - buttons.push() - } - - if (allowToggle) { - buttons.push() - } else { - openButtons.push() - } - - // props to pass to the ItemTitle - const titleProps = { - name, - t, - current: , - emoji: config.emoji, - Icon: config.icon, - } + buttons.push() return ( - } - title={} - buttons={buttons} - openButtons={openButtons} + {t([`${name}.d`, name])}} + docs={} + id={config.name} + labelBR={
{buttons}
} + labelBL={ + + {t(`workbench:youUse${changed ? 'Default' : 'Custom'}Value`)} + + } > -
+ ) } @@ -175,6 +168,7 @@ export const MenuItem = ({ * @param {Function} updateFunc the function called by change handlers on inputs within menu items * @param {Boolean} topLevel is this group the top level group? false for nested * @param {Function} t translation function + * @param {Function} getDocsPath returns the path to the docs for the current item */ export const MenuItemGroup = ({ collapsible = true, @@ -192,15 +186,79 @@ export const MenuItemGroup = ({ updateFunc, topLevel = false, t, + DynamicDocs, + language, + getDocsPath, + isDesignOptionsGroup = false, }) => { // map the entries in the structure const content = Object.entries(structure).map(([itemName, item]) => { // if it's the isGroup property, or it is false, it shouldn't be shown if (itemName === 'isGroup' || item === false) return null + if (!item) return null - // if the item is not a menu, it's an Item - if (!item.isGroup) - return ( + const ItemIcon = item.icon + ? item.icon + : item.isGroup + ? GroupIcon + : Icon + ? Icon + : () => {emoji} + const Value = item.isGroup + ? () => ( +
+ {Object.keys(item).filter((i) => i !== 'isGroup').length} + +
+ ) + : isDesignOptionsGroup + ? values[optionType(item)] + : values[itemName] + ? values[itemName] + : () => ¯\_(ツ)_/¯ + + return [ +
+
+ +
{t([`${itemName}.t`, itemName])}
+
+
+ +
+
, + item.isGroup ? ( + + ) : ( - ) - - // otherwise, it's a group - return ( - - ) + ), + ] }) // if it should be wrapped in a collapsible + /* if (collapsible) { // props to give to the group title const titleProps = { @@ -269,7 +307,8 @@ export const MenuItemGroup = ({ ) } + */ //otherwise just return the content - return content + return item !== null)} /> } diff --git a/sites/shared/components/workbench/menus/shared/values.mjs b/sites/shared/components/workbench/menus/shared/values.mjs index 5627e66c9ed..8598c8d3f97 100644 --- a/sites/shared/components/workbench/menus/shared/values.mjs +++ b/sites/shared/components/workbench/menus/shared/values.mjs @@ -7,7 +7,7 @@ import { formatMm } from 'shared/utils.mjs' /** The basis of it all. Handles the changed/unchanged styling for the wrapped value */ export const HighlightedValue = ({ changed, children }) => ( - {children} + {children} ) /** diff --git a/sites/shared/components/workbench/views/cut/index.mjs b/sites/shared/components/workbench/views/cut/index.mjs index d886fe37025..2ecae158564 100644 --- a/sites/shared/components/workbench/views/cut/index.mjs +++ b/sites/shared/components/workbench/views/cut/index.mjs @@ -11,6 +11,7 @@ import { useMaterialList, useMaterialLength, } from './hooks' +import { V3Wip } from 'shared/components/v3-wip.mjs' export const ns = [...menuNs, ...wrapperNs] @@ -110,21 +111,24 @@ export const CutView = ({ ), menu: ( - + <> + + + ), }} /> diff --git a/sites/shared/components/workbench/views/draft/menu.mjs b/sites/shared/components/workbench/views/draft/menu.mjs index 081277d9994..89f97e686d0 100644 --- a/sites/shared/components/workbench/views/draft/menu.mjs +++ b/sites/shared/components/workbench/views/draft/menu.mjs @@ -4,12 +4,15 @@ import { } from 'shared/components/workbench/menus/design-options/index.mjs' import { CoreSettings, - ClearAllButton, ns as coreMenuNs, } from 'shared/components/workbench/menus/core-settings/index.mjs' import { UiSettings, ns as uiNs } from 'shared/components/workbench/menus/ui-settings/index.mjs' +import { useTranslation } from 'next-i18next' +import { nsMerge } from 'shared/utils.mjs' +import { SettingsIcon, OptionsIcon, DesktopIcon } from 'shared/components/icons.mjs' +import { Accordion } from 'shared/components/accordion.mjs' -export const ns = [...coreMenuNs, ...designMenuNs, ...uiNs] +export const ns = nsMerge(coreMenuNs, designMenuNs, uiNs) export const DraftMenu = ({ design, @@ -24,6 +27,7 @@ export const DraftMenu = ({ view, setView, }) => { + const { t } = useTranslation() const control = account.control const menuProps = { design, @@ -36,12 +40,39 @@ export const DraftMenu = ({ control, } + const sections = [ + { + name: 'designOptions', + ns: 'design-options', + icon: , + menu: , + }, + { + name: 'coreSettings', + ns: 'core-settings', + icon: , + menu: , + }, + { + name: 'uiSettings', + ns: 'ui-settings', + icon: , + menu: , + }, + ] + return ( - + [ + <> +
+ {t(`${section.ns}:${section.name}.t`)} + {section.icon} +
+

{t(`${section.ns}:${section.name}.d`)}

+ , + section.menu, + ])} + /> ) } diff --git a/sites/shared/components/workbench/views/edit/index.mjs b/sites/shared/components/workbench/views/edit/index.mjs index 866c8b55c65..b586baa8ec5 100644 --- a/sites/shared/components/workbench/views/edit/index.mjs +++ b/sites/shared/components/workbench/views/edit/index.mjs @@ -5,6 +5,7 @@ import { useTranslation } from 'next-i18next' import { useToast } from 'shared/hooks/use-toast.mjs' import { CloseIcon } from 'shared/components/icons.mjs' import { capitalize } from 'shared/utils.mjs' +import { V3Wip } from 'shared/components/v3-wip.mjs' export const ns = ['wbedit'] @@ -52,6 +53,7 @@ export const EditView = ({ settings, setSettings, design, Design }) => { return (

{t('yamlEditViewTitleThing', { thing: capitalize(design) })}

+
{error && (
diff --git a/sites/shared/components/workbench/views/exporting/index.mjs b/sites/shared/components/workbench/views/exporting/index.mjs index 228519999ff..a24eeb0e872 100644 --- a/sites/shared/components/workbench/views/exporting/index.mjs +++ b/sites/shared/components/workbench/views/exporting/index.mjs @@ -9,6 +9,7 @@ import { handleExport, ns as exportNs, } from 'shared/components/workbench/exporting/export-handler.mjs' +import { V3Wip } from 'shared/components/v3-wip.mjs' export const ns = ['exporting', exportNs] @@ -45,6 +46,7 @@ export const ExportView = ({ settings, ui, design, Design }) => { return (

{t('export')}

+

{t('exportPattern-txt')}

{link && ( diff --git a/sites/shared/components/workbench/views/inspect/index.mjs b/sites/shared/components/workbench/views/inspect/index.mjs index 71afe4bec71..8a0875ad9f2 100644 --- a/sites/shared/components/workbench/views/inspect/index.mjs +++ b/sites/shared/components/workbench/views/inspect/index.mjs @@ -3,6 +3,7 @@ import { InspectorPattern } from './inspector/pattern.mjs' import { DraftMenu, ns as menuNs } from './menu.mjs' import { objUpdate } from 'shared/utils.mjs' import { PatternWithMenu, ns as wrapperNs } from '../pattern-with-menu.mjs' +import { V3Wip } from 'shared/components/v3-wip.mjs' export const ns = [...menuNs, ...wrapperNs] @@ -76,24 +77,27 @@ export const InspectView = ({ setSettings, pattern: output, menu: ( - + <> + + + ), }} /> diff --git a/sites/shared/components/workbench/views/logs/index.mjs b/sites/shared/components/workbench/views/logs/index.mjs index 81dba1326d8..7d556423409 100644 --- a/sites/shared/components/workbench/views/logs/index.mjs +++ b/sites/shared/components/workbench/views/logs/index.mjs @@ -5,6 +5,7 @@ import { ClearAllButton, ns as coreMenuNs, } from 'shared/components/workbench/menus/core-settings/index.mjs' +import { V3Wip } from 'shared/components/v3-wip.mjs' export const ns = ['logs', ...coreMenuNs] @@ -88,6 +89,7 @@ export const LogView = ({ pattern, settings, setSettings }) => {

{t('logs')}

+ {Object.entries(logs).map(([type, lines], key) => ( ))} diff --git a/sites/shared/components/workbench/views/print/index.mjs b/sites/shared/components/workbench/views/print/index.mjs index 5c901e38e43..e8443933daa 100644 --- a/sites/shared/components/workbench/views/print/index.mjs +++ b/sites/shared/components/workbench/views/print/index.mjs @@ -13,6 +13,7 @@ import { PrintIcon, RightIcon } from 'shared/components/icons.mjs' import { LoadingContext } from 'shared/context/loading-context.mjs' import { useToast } from 'shared/hooks/use-toast.mjs' import { PatternWithMenu, ns as wrapperNs } from '../pattern-with-menu.mjs' +import { V3Wip } from 'shared/components/v3-wip.mjs' const viewNs = ['print', ...exportNs] export const ns = [...viewNs, ...menuNs, ...wrapperNs] @@ -114,21 +115,24 @@ export const PrintView = ({ /> ), menu: ( - + <> + + + ), }} /> diff --git a/sites/shared/components/workbench/views/save/index.mjs b/sites/shared/components/workbench/views/save/index.mjs index e88dbde444b..687dbb57fab 100644 --- a/sites/shared/components/workbench/views/save/index.mjs +++ b/sites/shared/components/workbench/views/save/index.mjs @@ -10,6 +10,7 @@ import { useToast } from 'shared/hooks/use-toast.mjs' import { LoadingContext } from 'shared/context/loading-context.mjs' // Components import { Spinner } from 'shared/components/spinner.mjs' +import { V3Wip } from 'shared/components/v3-wip.mjs' export const ns = ['wbsave'] @@ -245,6 +246,7 @@ export const SaveView = ({ design, settings, from = false }) => { return (

{t('wbsave:title')}

+
{info.new ? : null} {info.edit ? : null} diff --git a/sites/shared/components/workbench/views/test/menu.mjs b/sites/shared/components/workbench/views/test/menu.mjs index 234a1909e49..8f8092f48c4 100644 --- a/sites/shared/components/workbench/views/test/menu.mjs +++ b/sites/shared/components/workbench/views/test/menu.mjs @@ -1,6 +1,29 @@ -import { TestOptions, ns as optionsNs } from './options.mjs' -import { TestMeasurements, ns as measieNs } from './measurements.mjs' -export const ns = [...optionsNs, ...measieNs] +import { ns as optionsNs } from './options.mjs' +import { ns as measieNs } from './measurements.mjs' +import { Accordion } from 'shared/components/accordion.mjs' +import { useTranslation } from 'next-i18next' +import { nsMerge } from 'shared/utils.mjs' +import { OptionsIcon, MeasieIcon, CommunityIcon } from 'shared/components/icons.mjs' +import { ListInput } from 'shared/components/inputs.mjs' +import { optionsMenuStructure } from 'shared/utils.mjs' +import { V3Wip } from 'shared/components/v3-wip.mjs' + +export const ns = nsMerge('workbench', optionsNs, measieNs) + +const flattenOptions = (options, list = false, path = []) => { + if (list === false) return flattenOptions(optionsMenuStructure(options), new Set()) + + for (const [key, option] of Object.entries(options)) { + if (key !== 'isGroup') { + if (!option.isGroup) list.add({ key, option, path }) + else list = flattenOptions(option, list, [...path, key]) + } + } + + return list +} + +const spacer = / export const TestMenu = ({ design, @@ -11,22 +34,72 @@ export const TestMenu = ({ account, DynamicDocs, }) => { - const control = account.control - const menuProps = { - design, - patternConfig, - settings, - update, - language, - account, - DynamicDocs, - control, - } + const { t } = useTranslation(ns) + + const allOptions = flattenOptions(patternConfig.options) return ( - + +
+ {t('workbench:testOptions')} + +
+

{t('workbench:testOptionsDesc')}

+ , + ({ + label: [ + ...option.path.map((p) => ( + <> + {t(`${p}.t`)} + {spacer} + + )), + {t(`${design}:${option.key}.t`)}, + ], + val: option.key, + }))} + update={(value) => { + if (value) update.settings(['sample'], { type: 'option', option: value }) + else update.settings(['sample']) + }} + current={settings.sample.option} + />, + ], + [ + <> +
+ {t('workbench:testMeasurements')} + +
+

{t('workbench:testOptionsDesc')}

+ , + ({ + label: t(m), + val: m, + }))} + update={(value) => { + if (value) update.settings(['sample'], { type: 'measurement', measurement: value }) + else update.settings(['sample']) + }} + current={settings.sample.measurement} + />, + ], + [ + <> +
+ {t('workbench:testSets')} + +
+

{t('workbench:testSetsDesc')}

+ , + , + ], + ]} + /> ) } diff --git a/sites/shared/components/workbench/views/view-header.mjs b/sites/shared/components/workbench/views/view-header.mjs index cbaa2824a94..93819718235 100644 --- a/sites/shared/components/workbench/views/view-header.mjs +++ b/sites/shared/components/workbench/views/view-header.mjs @@ -11,6 +11,7 @@ import { DetailIcon, IconWrapper, ClearIcon, + ResetIcon, } from 'shared/components/icons.mjs' import { ClearAllButton } from 'shared/components/workbench/menus/core-settings/index.mjs' import { shownHeaderSelector } from 'shared/components/wrappers/header.mjs' @@ -94,7 +95,7 @@ export const ViewHeader = ({ update, settings, ui, control, setSettings }) => { 'lg:top-24' )} transition-[top] duration-300 ease-in-out`} > -
+
{headerZoomButtons}
@@ -156,7 +157,34 @@ export const ViewHeader = ({ update, settings, ui, control, setSettings }) => {
- + +