2021-03-07 11:57:26 +00:00
|
|
|
import React, { useState } from "react";
|
2021-03-03 08:53:37 +00:00
|
|
|
|
|
|
|
import ContextMenuButton from "./";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: "Components/ContextMenuButton",
|
|
|
|
component: ContextMenuButton,
|
2021-03-03 10:25:56 +00:00
|
|
|
argTypes: {
|
2021-03-07 11:57:26 +00:00
|
|
|
clickColor: { control: "color" },
|
|
|
|
color: { control: "color" },
|
|
|
|
getData: { required: true },
|
|
|
|
hoverColor: { control: "color" },
|
2021-03-03 10:25:56 +00:00
|
|
|
onClickLabel: { action: "onClickLabel", table: { disable: true } },
|
2021-03-07 11:57:26 +00:00
|
|
|
onMouseLeave: { action: "onMouseLeave" },
|
|
|
|
onMouseEnter: { action: "onMouseEnter" },
|
|
|
|
onMouseOver: { action: "onMouseOver" },
|
|
|
|
onMouseOut: { action: "onMouseOut" },
|
2021-03-03 10:25:56 +00:00
|
|
|
},
|
2021-03-03 08:53:37 +00:00
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
description: {
|
|
|
|
component: `ContextMenuButton is used for displaying context menu actions on a list's item`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-03-03 10:25:56 +00:00
|
|
|
const Template = (args) => {
|
2021-03-07 11:57:26 +00:00
|
|
|
const [isOpen, setIsOpen] = useState(args.opened);
|
|
|
|
const getData = () => {
|
2021-03-03 10:25:56 +00:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
key: "key1",
|
|
|
|
label: "label1",
|
|
|
|
onClick: () => args.onClickLabel("label1"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "key2",
|
|
|
|
label: "label2",
|
|
|
|
onClick: () => args.onClickLabel("label2"),
|
|
|
|
},
|
|
|
|
];
|
2021-03-07 11:57:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const onClickHandler = () => {
|
|
|
|
setIsOpen(!isOpen);
|
|
|
|
args.onClickLabel();
|
|
|
|
};
|
2021-03-03 10:25:56 +00:00
|
|
|
return (
|
2021-03-07 11:57:26 +00:00
|
|
|
<div style={{ height: "100px" }}>
|
|
|
|
<ContextMenuButton
|
|
|
|
{...args}
|
|
|
|
opened={isOpen}
|
|
|
|
getData={getData}
|
|
|
|
isDisabled={false}
|
|
|
|
onClick={onClickHandler}
|
|
|
|
/>
|
|
|
|
</div>
|
2021-03-03 10:25:56 +00:00
|
|
|
);
|
|
|
|
};
|
2021-03-03 08:53:37 +00:00
|
|
|
|
2021-03-07 11:57:26 +00:00
|
|
|
export const Default = Template.bind({});
|
|
|
|
Default.args = {
|
|
|
|
title: "Actions",
|
|
|
|
iconName: "/static/images/vertical-dots.react.svg",
|
|
|
|
size: 16,
|
|
|
|
directionX: "right",
|
|
|
|
isDisabled: false,
|
|
|
|
};
|