-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create ItemTableAppBarAction component with docs
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/components/ItemTableAppBarAction/ItemTableAppBarAction.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 /> | ||
}; |
58 changes: 58 additions & 0 deletions
58
src/components/ItemTableAppBarAction/ItemTableAppBarAction.stories.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./ItemTableAppBarAction"; |