import type { Meta, StoryObj } from '@storybook/react/*'; import { SimpleRenderItemDecorator } from '../../../.storybook/decorators/with-simple-data'; import { Mask } from './mask'; import { PRIMARY, SECONDARY } from 'storybook-config/theme'; import { makeRootDocumentation, makeStory } from '@joint/react/src/stories/utils/make-story'; import { getAPILink } from '@joint/react/src/stories/utils/get-api-documentation-link'; import { forwardRef, type PropsWithChildren } from 'react'; import { useElement } from '../../hooks'; const API_URL = getAPILink('Highlighter.Mask', 'variables'); export type Story = StoryObj; const meta: Meta = { title: 'Components/Highlighter/Mask', component: Mask, decorators: [SimpleRenderItemDecorator], parameters: makeRootDocumentation({ description: ` Mask is a component that creates a mask around the children. It is used to highlight the children. `, apiURL: API_URL, code: `import { Highlighter } from '@joint/react' `, }), }; // we need to use forwardRef to pass the ref to the rect element, so highlighter can use it function RectRenderComponent(_: PropsWithChildren, ref: React.Ref) { const { width, height } = useElement(); return ; } const RectRender = forwardRef(RectRenderComponent); export default meta; export const Default = makeStory({ args: { stroke: SECONDARY, children: , }, apiURL: API_URL, description: 'Default mask highlighter with rectangle children.', code: ` `, }); export const WithPadding = makeStory({ args: { padding: 10, stroke: SECONDARY, children: , }, apiURL: API_URL, description: 'Mask highlighter with padding.', code: ` `, }); export const WithSVGProps = makeStory({ args: { padding: 10, stroke: SECONDARY, strokeWidth: 5, strokeLinejoin: 'bevel', children: , }, apiURL: API_URL, description: 'Mask highlighter with SVG Element props.', code: ` `, });