// Storybook
import { ComponentStory, ComponentMeta } from '@storybook/react';
// React
import React, { useMemo } from "react";
// Geovisto
import { ISidebarFragment, ISidebarTabProps, SidebarFragment } from 'geovisto-sidebar';
// Internal imports
import { SidebarTab, SidebarTool, SelectionTool, ChoroplethLayerTool, MarkerLayerTool, ConnectionLayerTool } from '../react/components';
import { ISidebarTabDataProps } from '../react/types';
// Styles
import '../styles/common.scss';
// Stories internal helper components
import { ExportMapWrapper } from '../storiesHelpers/ExportMapWrapper';
// Data
import covidCzechDistricts from '../../static/data/covidCzechDistricts.json';
// Config
import czDefaultMapPosition from '../../static/config/defaultPosition/config-czDefaultPosition.json';
const SelectionToolDemo = (props: ISelectionToolDemoProps) : JSX.Element => {
const extendedProps = {
mapId: 'geovisto-map-selection-demo',
showBaseTileLayerMap: true,
data: covidCzechDistricts,
config: props.defaultMapPosition ? czDefaultMapPosition : undefined,
...props
};
const selectionFragment = useMemo((): [string, ISidebarFragment][] =>
[['geovisto-tool-selection', new SidebarFragment({ enabled:true })]]
, []);
return (
);
};
export default {
component: SelectionToolDemo,
title: 'Tools/Selection Tool',
argTypes: {
sidebarToolEnabled: {
name: "SidebarTool: Enabled",
description: "Enabled property of the SidebarTool instance.",
},
sidebarTabTool: {
name: "SidebarTab - SelectionTool",
description: "Properties of the sidebar tab of the SelectionTool.",
},
toolId: {
name: "Id",
description: "Id property of the SelectionTool instance.",
},
toolIcon: {
name: "Icon",
description: "Icon property of the SelectionTool instance.",
},
toolLabel: {
name: "Label",
description: "Label property of the SelectionTool instance.",
},
toolEnabled: {
name: "Enabled",
description: "Enabled property of the SelectionTool instance.",
},
toolSelection: {
name: "Selection",
description: "Selection property of the SelectionTool instance.",
},
defaultMapPosition: {
name: "Default map position (CZ):",
description: "Enables/Disables config with the center of the map set on Czech republic.",
}
},
} as ComponentMeta;
export type ISelectionToolDemoProps = {
defaultMapPosition: boolean,
toolId: string;
toolEnabled: boolean;
toolIcon: string;
toolLabel: string;
sidebarToolEnabled: boolean;
sidebarTabTool: ISidebarTabDataProps;
}
const Template : ComponentStory = args =>
export const GeovistoSelectionToolStory = Template.bind({});
GeovistoSelectionToolStory.storyName = 'Selection Tool';
GeovistoSelectionToolStory.args = {
defaultMapPosition: true,
toolEnabled: true,
toolId: 'geovisto-selection-tool-map',
toolIcon: '',
toolLabel: 'Selection Tool label',
sidebarToolEnabled: true,
sidebarTabTool: {
enabled: true,
name: 'Selection settings',
icon: '',
checkButton: true,
},
}