Download tabler-react/src/components/SocialNetworksList/SocialNetworksList.react.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/SocialNetworksList/SocialNetworksList.react.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/SocialNetworksList/SocialNetworksList.react.js
-
curl -L -o SocialNetworksList.react.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/SocialNetworksList/SocialNetworksList.react.js
1.53 kB
| // @flow | |
| import * as React from "react"; | |
| import cn from "classnames"; | |
| import { List, Icon, Button } from "../"; | |
| type itemObject = {| | |
| name: string, | |
| label?: string, | |
| to?: string, | |
| tooltip?: string, | |
| color?: string, | |
| |}; | |
| type Props = {| | |
| +children?: React.Node, | |
| +className?: string, | |
| +asButtons?: boolean, | |
| +prefix?: string, | |
| +itemsObjects?: Array<itemObject>, | |
| +items?: Array<React.Node>, | |
| |}; | |
| function listItemFromObjectFactory( | |
| asButtons: boolean = false, | |
| iconPrefix: string | |
| ) { | |
| return (item: itemObject) => { | |
| const itemContent = asButtons ? ( | |
| <Button to={item.to} social={item.name} color={item.color} size="sm"> | |
| {item.label} | |
| </Button> | |
| ) : ( | |
| <a href={item.to} data-original-title={item.tooltip}> | |
| <Icon prefix={iconPrefix} name={item.name} /> | |
| </a> | |
| ); | |
| return <List.Item inline>{itemContent}</List.Item>; | |
| }; | |
| } | |
| function SocialNetworksList(props: Props): React.Node { | |
| const { | |
| children, | |
| className, | |
| asButtons, | |
| prefix = "fe", | |
| items, | |
| itemsObjects, | |
| } = props; | |
| const classes = cn("social-links", className); | |
| const getObjectListItem = listItemFromObjectFactory(asButtons, prefix); | |
| const contents = | |
| (itemsObjects && itemsObjects.map(getObjectListItem)) || | |
| (items && items.map(item => <List.Item inline>{item}</List.Item>)) || | |
| children; | |
| return ( | |
| <List inline className={classes}> | |
| {contents} | |
| </List> | |
| ); | |
| } | |
| SocialNetworksList.displayName = "SocialNetworksList"; | |
| export default SocialNetworksList; | |