import type { Meta, StoryObj } from '@storybook/react/*'; import { SimpleRenderItemDecorator } from '../../../.storybook/decorators/with-simple-data'; import { Opacity } from './opacity'; import { PRIMARY } 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.Opacity', 'variables'); export type Story = StoryObj; const meta: Meta = { title: 'Components/Highlighter/Opacity', component: Opacity, decorators: [SimpleRenderItemDecorator], parameters: makeRootDocumentation({ description: ` Opacity is a component that changes the opacity of 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: { alphaValue: 0.5, children: , }, apiURL: API_URL, description: 'Default opacity highlighter with rectangle children.', code: ` `, });