diff --git a/apps/storybook/src/Annotation.stories.tsx b/apps/storybook/src/Annotation.stories.tsx index 6d68a2d1e..021c64b64 100644 --- a/apps/storybook/src/Annotation.stories.tsx +++ b/apps/storybook/src/Annotation.stories.tsx @@ -15,7 +15,11 @@ import { formatCoord } from './utils'; const meta = { title: 'Building Blocks/Annotation', - parameters: { layout: 'fullscreen' }, + component: Annotation, + parameters: { + layout: 'fullscreen', + controls: { sort: 'requiredFirst' }, + }, decorators: [ (Story) => ( ; export default meta; type Story = StoryObj; export const Default = { - render: () => ( - <> - - HTML annotation positioned at (10, 16) - - - Another annotation, centred on (10, 6) - - - <> -

- Annotations don't have to contain just text. You can also draw - shapes with CSS and SVG. -

- - - - + render: (args) => { + const { x, y, overflowCanvas, scaleOnZoom, center, style } = args; + + const features = [ + overflowCanvas ? 'overflows the canvas' : '', + scaleOnZoom ? 'scales on zoom' : '', + ] + .filter((str) => str.length > 0) + .join(' and '); + + return ( + +

+ Annotation {center ? 'centered on' : 'positioned at'} ({x}, {y}) + {features && <> that {features}} +

+ + + +
- - ), + ); + }, + args: { + x: 10, + y: 16, + }, } satisfies Story; -export const WithZoom = { - render: () => ( - <> - - HTML annotation at (10, 16) that scales with zoom. - - - Another annotation that scales with zoom but this time{' '} - centred on (25, 10) - - +export const OverflowCanvas = { + ...Default, + args: { + x: 6, + y: 16, + overflowCanvas: true, + }, +} satisfies Story; + +export const Centered = { + ...Default, + args: { + x: 5, + y: 14, + center: true, + }, +} satisfies Story; + +export const ScaleOnZoom = { + ...Default, + args: { + x: 10, + y: 16, + scaleOnZoom: true, + }, +} satisfies Story; + +export const ScaleOnZoomCentered = { + ...Default, + args: { + x: 10, + y: 16, + scaleOnZoom: true, + center: true, + }, +} satisfies Story; + +export const FollowPointer = { + render: (args) => ( + + {(x, y) => ( + {`x=${formatCoord(x)}, y=${formatCoord(y)}`} + )} + ), + args: { + x: 0, + y: 0, + }, + argTypes: { + x: { control: false }, + y: { control: false }, + }, } satisfies Story; function PointerTracker(props: { @@ -137,17 +171,3 @@ function PointerTracker(props: { // eslint-disable-next-line react/jsx-no-useless-fragment return <>{coords ? children(...coords) : null}; } - -export const FollowPointer = { - render: () => ( - - {(x, y) => ( - {`x=${formatCoord(x)}, y=${formatCoord(y)}`} - )} - - ), -} satisfies Story;