Download tabler-react/src/components/Card/CardOptionsItem.react.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/Card/CardOptionsItem.react.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/Card/CardOptionsItem.react.js
-
curl -L -o CardOptionsItem.react.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/Card/CardOptionsItem.react.js
1.34 kB
| // @flow | |
| import * as React from "react"; | |
| import cn from "classnames"; | |
| import { Icon } from "../"; | |
| type Props = {| | |
| +children?: React.Node, | |
| +className?: string, | |
| +icon?: string, | |
| +type?: "collapse" | "close" | "fullscreen", | |
| +onClick?: () => mixed, | |
| |}; | |
| function CardOptionsItem({ | |
| className, | |
| children, | |
| icon, | |
| type, | |
| onClick, | |
| }: Props): React.Node { | |
| const classes = cn( | |
| { | |
| "card-options-collapse": type === "collapse", | |
| "card-options-remove": type === "close", | |
| "card-options-fullscreen": type === "fullscreen", | |
| }, | |
| className | |
| ); | |
| const dataToggle = ((): string => { | |
| switch (type) { | |
| case "collapse": | |
| return "card-collapse"; | |
| case "close": | |
| return "card-remove"; | |
| case "fullscreen": | |
| return "card-remove"; | |
| default: | |
| return ""; | |
| } | |
| })(); | |
| const iconName = ((): string => { | |
| if (icon) { | |
| return icon; | |
| } | |
| switch (type) { | |
| case "collapse": | |
| return "chevron-up"; | |
| case "close": | |
| return "x"; | |
| case "fullscreen": | |
| return "maximize"; | |
| default: | |
| return ""; | |
| } | |
| })(); | |
| return ( | |
| <a className={classes} data-toggle={dataToggle} onClick={onClick}> | |
| <Icon name={iconName} /> | |
| </a> | |
| ); | |
| } | |
| CardOptionsItem.displayName = "Card.OptionsItem"; | |
| export default CardOptionsItem; | |