Skip to content

Commit

Permalink
Create ItemTableAppBarAction component with docs
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Jul 16, 2021
1 parent 72fd802 commit 59518c6
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/components/ItemTableAppBarAction/ItemTableAppBarAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from "react";
import PropTypes from 'prop-types';
import {Tooltip, IconButton, Zoom} from "@material-ui/core"
import DefaultIcon from '@material-ui/icons/CheckBoxOutlineBlank';

export default function ItemTableAppBarAction({title, onClick, icon}) {
return (
<Tooltip title={title}
arrow
onClick={onClick}
TransitionComponent={Zoom}
>
<IconButton color="inherit">
{icon}
</IconButton>
</Tooltip>
);
}

ItemTableAppBarAction.propTypes = {
/** The title of the action. */
"title": PropTypes.string,
/** Callback for clicking on action. */
"onClick": PropTypes.func.isRequired,
/** MUI Icon to go inside an <a href="https://material-ui.com/api/icon-button/">IconButton</a>. */
"icon": PropTypes.node
};

ItemTableAppBarAction.defaultProps = {
"title": "",
"icon": <DefaultIcon />
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs/blocks';
import ItemTableAppBarAction from "./ItemTableAppBarAction";
import NotificationImportantIcon from '@material-ui/icons/NotificationImportant';
import ItemTableAppBar from "../ItemTableAppBar";

<Meta
title="Components/ItemTableAppBarAction"
component={ItemTableAppBarAction}
argsTypes={{
onClick: {
control: {
type: "object"
}
},
icon: {
control: {
type: "object"
}
}
}}
/>

The ItemTableAppBarAction provides clickable toggles for global controls like dark mode and logout inside the [ItemTableAppBar](/?path=/docs/components-itemtableappbar). It accepts a title, an `onClick` function and an [MUI Icon](https://material-ui.com/components/material-icons/) element.

<Canvas>
<Story
name="Default"
args={{
title:"Alert User",
onClick: _ => alert("The British are coming!"),
icon: <NotificationImportantIcon />
}}
>
{ args => <ItemTableAppBarAction {...args} /> }
</Story>
</Canvas>

To use the ItemTableAppBarAction in the [ItemTableAppBar](/?path=/docs/components-itemtableappbar), put one or more ItemTableAppBarActions in an array and pass that array to the [ItemTableAppBar](/?path=/docs/components-itemtableappbar).

<Canvas>
<Story
name="Used In ItemTableAppBar"
args={{
title:"Alert User",
onClick: _ => alert("The British are coming!"),
icon: <NotificationImportantIcon />
}}
>
{ args => (
<ItemTableAppBar
title="webqueue2"
actions={[<ItemTableAppBarAction {...args} />]}
/>
)}
</Story>
</Canvas>

<ArgsTable of={ItemTableAppBarAction} />
1 change: 1 addition & 0 deletions src/components/ItemTableAppBarAction/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./ItemTableAppBarAction";

0 comments on commit 59518c6

Please sign in to comment.