Download spectrum/src/components/badges/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.05 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/components/badges/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/src/components/badges/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/components/badges/index.js
2.05 kB
| // @flow | |
| import * as React from 'react'; | |
| import compose from 'recompose/compose'; | |
| import { connect } from 'react-redux'; | |
| import type { Dispatch } from 'redux'; | |
| import { Span, ProBadge, BlockedBadge, PendingBadge, TeamBadge } from './style'; | |
| import { withCurrentUser } from 'src/components/withCurrentUser'; | |
| import Tooltip from 'src/components/tooltip'; | |
| type Props = { | |
| type: string, | |
| label?: string, | |
| onClick?: Function, | |
| tipText: string, | |
| currentUser: ?Object, | |
| dispatch: Dispatch<Object>, | |
| }; | |
| class Badge extends React.Component<Props> { | |
| render() { | |
| const { type, label, ...rest } = this.props; | |
| switch (type) { | |
| case 'beta-supporter': | |
| return ( | |
| <Tooltip content={'Beta Supporter'}> | |
| <ProBadge type={type} {...rest}> | |
| {label || 'Supporter'} | |
| </ProBadge> | |
| </Tooltip> | |
| ); | |
| case 'blocked': | |
| return ( | |
| <Tooltip content={this.props.tipText}> | |
| <BlockedBadge type={type} {...rest}> | |
| {label || type} | |
| </BlockedBadge> | |
| </Tooltip> | |
| ); | |
| case 'pending': | |
| return ( | |
| <Tooltip content={this.props.tipText}> | |
| <PendingBadge type={type} {...rest}> | |
| {label || type} | |
| </PendingBadge> | |
| </Tooltip> | |
| ); | |
| case 'moderator': | |
| case 'admin': | |
| return ( | |
| <Tooltip | |
| content={`${ | |
| type === 'moderator' ? 'Moderator' : 'Owner' | |
| } of this community`} | |
| > | |
| <TeamBadge type={type} {...rest}> | |
| Team | |
| </TeamBadge> | |
| </Tooltip> | |
| ); | |
| default: | |
| return ( | |
| <Tooltip content={this.props.tipText || label || ''}> | |
| <Span | |
| type={type} | |
| onClick={this.props.onClick && this.props.onClick} | |
| {...rest} | |
| > | |
| {label || type} | |
| </Span> | |
| </Tooltip> | |
| ); | |
| } | |
| } | |
| } | |
| export default compose( | |
| withCurrentUser, | |
| connect() | |
| )(Badge); | |