diff --git a/packages/sdk-components-react-radix/src/accordion.tsx b/packages/sdk-components-react-radix/src/accordion.tsx index 15e4c821dbe8..6720a1c1e8f4 100644 --- a/packages/sdk-components-react-radix/src/accordion.tsx +++ b/packages/sdk-components-react-radix/src/accordion.tsx @@ -14,7 +14,10 @@ import { Trigger, Content, } from "@radix-ui/react-accordion"; -import { getIndexWithinAncestorFromProps } from "@webstudio-is/sdk/runtime"; +import { + getIndexWithinAncestorFromProps, + getTagFromProps, +} from "@webstudio-is/sdk/runtime"; import { getClosestInstance, type Hook } from "@webstudio-is/react-sdk/runtime"; export const Accordion = forwardRef< @@ -47,10 +50,18 @@ export const AccordionItem = forwardRef< return ; }); -export const AccordionHeader: ForwardRefExoticComponent< - Omit, "asChild"> & - RefAttributes -> = Header; +const defaultTag = "h1"; +type Props = ComponentProps; +export const AccordionHeader = forwardRef( + ({ ...props }, ref) => { + const Heading = getTagFromProps(props) ?? defaultTag; + return ( +
+ +
+ ); + } +); export const AccordionTrigger: ForwardRefExoticComponent< Omit, "asChild"> & diff --git a/packages/sdk-components-react-radix/src/accordion.ws.ts b/packages/sdk-components-react-radix/src/accordion.ws.ts index 2795935ac1f9..dc683356c1cd 100644 --- a/packages/sdk-components-react-radix/src/accordion.ws.ts +++ b/packages/sdk-components-react-radix/src/accordion.ws.ts @@ -6,7 +6,16 @@ import { ContentIcon, } from "@webstudio-is/icons/svg"; import type { WsComponentMeta } from "@webstudio-is/sdk"; -import { div, h3, button } from "@webstudio-is/sdk/normalize.css"; +import { + h1, + h2, + h3, + h4, + h5, + h6, + div, + button, +} from "@webstudio-is/sdk/normalize.css"; import { radix } from "./shared/meta"; import { buttonReset } from "./shared/preset-styles"; import { @@ -52,6 +61,28 @@ export const metaAccordionHeader: WsComponentMeta = { descendants: [radix.AccordionTrigger], }, presetStyle: { + h1: [ + ...h1, + { + property: "margin-top", + value: { type: "unit", unit: "px", value: 0 }, + }, + { + property: "margin-bottom", + value: { type: "unit", unit: "px", value: 0 }, + }, + ], + h2: [ + ...h2, + { + property: "margin-top", + value: { type: "unit", unit: "px", value: 0 }, + }, + { + property: "margin-bottom", + value: { type: "unit", unit: "px", value: 0 }, + }, + ], h3: [ ...h3, { @@ -63,8 +94,50 @@ export const metaAccordionHeader: WsComponentMeta = { value: { type: "unit", unit: "px", value: 0 }, }, ], + h4: [ + ...h4, + { + property: "margin-top", + value: { type: "unit", unit: "px", value: 0 }, + }, + { + property: "margin-bottom", + value: { type: "unit", unit: "px", value: 0 }, + }, + ], + h5: [ + ...h5, + { + property: "margin-top", + value: { type: "unit", unit: "px", value: 0 }, + }, + { + property: "margin-bottom", + value: { type: "unit", unit: "px", value: 0 }, + }, + ], + h6: [ + ...h6, + { + property: "margin-top", + value: { type: "unit", unit: "px", value: 0 }, + }, + { + property: "margin-bottom", + value: { type: "unit", unit: "px", value: 0 }, + }, + ], + }, + initialProps: ["tag"], + props: { + ...propsAccordionHeader, + tag: { + required: true, + control: "tag", + type: "string", + options: ["h1", "h2", "h3", "h4", "h5", "h6"], + }, }, - props: propsAccordionHeader, }; export const metaAccordionTrigger: WsComponentMeta = {