Skip to content

Commit

Permalink
chore: 补充 AMapPolyline 编辑相关 story
Browse files Browse the repository at this point in the history
  • Loading branch information
xyy94813 committed Oct 28, 2023
1 parent 19b442b commit b8dd826
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/AMapPolyline/stories/AMapPolyline.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { actions } from '@storybook/addon-actions';
import {
AMapPolyline,
AMapPolylineProps,
AMapPolylineEditor,
AMapPolylineEditorProps,
} from '../../../index';

import withAutoFitView from '../../../storybook-decorators/withAutoFitView';
Expand Down Expand Up @@ -279,6 +281,21 @@ export const CommonUse: typeof Template = Template.bind({});
CommonUse.storyName = '一般使用';
CommonUse.args = {};

const { onChange } = actions('onChange');
const $polyline = React.createRef<AMap.Polyline>();
const computeTarget: AMapPolylineEditorProps['computeTarget'] = (polygons) => polygons?.find(
(polygon) => polygon === $polyline.current,
);

export const Editable: Story<AMapPolylineEditorProps> = (args) => (
<>
<AMapPolyline {...args} ref={$polyline} />
<AMapPolylineEditor computeTarget={computeTarget} onChange={onChange} />
</>
);
Editable.storyName = '支持编辑';
Editable.args = {};

export const Draggable: typeof Template = Template.bind({});
Draggable.storyName = '可拖拽';
Draggable.args = {
Expand Down

0 comments on commit b8dd826

Please sign in to comment.