From e433a7d1cecb236889f14fc6f859f43a51d5dbc6 Mon Sep 17 00:00:00 2001 From: joostdecock Date: Sat, 19 Apr 2025 17:52:48 +0200 Subject: [PATCH] [org] fix: Menus in Editor --- .../Editor/components/Accordion.mjs | 42 ++++--- .../Editor/components/HeaderMenu.mjs | 108 +++++++++--------- .../Editor/components/PatternLayout.mjs | 23 +++- .../Editor/components/menus/Container.mjs | 2 +- .../Editor/components/menus/Input.mjs | 2 +- packages/react/components/Input/index.mjs | 10 +- sites/org/src/css/custom.css | 5 + .../src/pages/{typography.js => styles.js} | 23 +++- sites/org/tailwind-force.html | 37 ++++++ 9 files changed, 163 insertions(+), 89 deletions(-) rename sites/org/src/pages/{typography.js => styles.js} (86%) diff --git a/packages/react/components/Editor/components/Accordion.mjs b/packages/react/components/Editor/components/Accordion.mjs index 224f53583c5..6c597eeff7d 100644 --- a/packages/react/components/Editor/components/Accordion.mjs +++ b/packages/react/components/Editor/components/Accordion.mjs @@ -5,19 +5,21 @@ import React, { useState } from 'react' * So instead, we handle this in React state */ const getProps = (isActive = false) => ({ - className: `tw:p-2 tw:px-4 tw:rounded-lg tw:bg-transparent tw:shadow tw:hover:cursor-pointer - tw:w-full tw:h-auto tw:content-start tw:text-left - ${isActive ? 'tw:hover:bg-transparent' : 'tw:hover:bg-secondary/10'}`, + className: `tw:p-0 tw:rounded-lg tw:bg-transparent tw:hover:cursor-pointer + tw:w-full tw:h-auto tw:content-start tw:text-left tw:list-none`, }) const getSubProps = (isActive) => ({ - className: `tw:p-2 tw:px-4 tw:rounded-none tw:bg-transparent tw:w-full tw:h-auto - tw:content-start tw:bg-secondary/20 tw:text-left - ${isActive ? 'tw:bg-secondary tw:hover:bg-transparent tw:shadow' : 'tw:hover:bg-secondary/10 '}`, + className: `tw:p-0 tw:rounded-none tw:bg-transparent tw:w-full tw:h-auto + tw:content-start tw:bg-secondary/20 tw:text-left tw:list-none`, }) const components = { - button: (props) => , + button: (props) => ( +
  • + {props.children} +
  • + ), div: (props) =>
    {props.children}
    , } @@ -31,20 +33,24 @@ export const BaseAccordion = ({ const Component = components[component] return ( - + ) } diff --git a/packages/react/components/Editor/components/HeaderMenu.mjs b/packages/react/components/Editor/components/HeaderMenu.mjs index 4edfb2c6215..903cc86d09b 100644 --- a/packages/react/components/Editor/components/HeaderMenu.mjs +++ b/packages/react/components/Editor/components/HeaderMenu.mjs @@ -6,7 +6,6 @@ import { useBackend } from '@freesewing/react/hooks/useBackend' import { useDesignTranslation } from '@freesewing/react/hooks/useDesignTranslation' // Components import { Null } from '@freesewing/react/components/Null' -import { AsideViewMenuSpacer } from './AsideViewMenu.mjs' import { ViewIcon, viewLabels } from './views/index.mjs' import { Tooltip } from './Tooltip.mjs' import { @@ -118,7 +117,7 @@ export const HeaderMenuTestViewDesignMeasurements = (props) => { @@ -133,52 +132,56 @@ export const HeaderMenuTestViewDesignMeasurements = (props) => { export const HeaderMenuDropdown = (props) => { const { tooltip, toggle, open, setOpen, id, end = false } = props - /* - * We need to use both !fixed and md:!absolute here to override DaisyUI's - * classes on dropdown-content to force the dropdown to use the available - * screen space on mobile, rather than be positioned under its toggle button - */ + const [localOpen, setLocalOpen] = useState(false) + useEffect(() => { + if (open) { + if (open === id) setLocalOpen(true) + else setLocalOpen(false) + } + }, [open, id]) + + /* + * New DaisyUI 5 implementation + */ return props.disabled ? ( - - - + ) : ( - -
    +
    -
    setOpen(open === id ? false : id)} - > + setOpen(id)}> {toggle} -
    -
    +
      {props.children} -
    - {open === id && ( -
    setOpen(false)} - >
    - )} -
    -
    + + + {localOpen && ( +
    { + setOpen(false) + setLocalOpen(false) + }} + >
    + )} + ) } @@ -394,7 +397,7 @@ export const HeaderMenuUndoIcons = (props) => { } > {undos ? ( -
      + <> {undos.slice(0, 9).map((step, index) => (
    • @@ -411,7 +414,7 @@ export const HeaderMenuUndoIcons = (props) => {
    • -
    + ) : null}