Download spectrum/src/components/hoverProfile/userProfile.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.88 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/src/components/hoverProfile/userProfile.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/src/components/hoverProfile/userProfile.js
-
curl -L -o userProfile.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/src/components/hoverProfile/userProfile.js
2.88 kB
| // @flow | |
| import React, { Component } from 'react'; | |
| import compose from 'recompose/compose'; | |
| import { connect } from 'react-redux'; | |
| import { withRouter } from 'react-router'; | |
| import AvatarImage from 'src/components/avatar/image'; | |
| import { Link } from 'react-router-dom'; | |
| import Badge from 'src/components/badges'; | |
| import { OutlineButton } from 'src/components/button'; | |
| import ConditionalWrap from 'src/components/conditionalWrap'; | |
| import type { GetUserType } from 'shared/graphql/queries/user/getUser'; | |
| import type { Dispatch } from 'redux'; | |
| import renderTextWithLinks from 'src/helpers/render-text-with-markdown-links'; | |
| import { withCurrentUser } from 'src/components/withCurrentUser'; | |
| import { | |
| HoverWrapper, | |
| ProfileCard, | |
| CoverContainer, | |
| CoverPhoto, | |
| ProfilePhotoContainer, | |
| Content, | |
| Title, | |
| Username, | |
| Description, | |
| Actions, | |
| } from './style'; | |
| type ProfileProps = { | |
| user: GetUserType, | |
| dispatch: Dispatch<Object>, | |
| currentUser: ?Object, | |
| ref: (?HTMLElement) => void, | |
| style: CSSStyleDeclaration, | |
| }; | |
| class HoverProfile extends Component<ProfileProps> { | |
| render() { | |
| const { user, currentUser, ref, style } = this.props; | |
| const me = currentUser && currentUser.id === user.id; | |
| return ( | |
| <HoverWrapper popperStyle={style} ref={ref}> | |
| <ProfileCard> | |
| <ConditionalWrap | |
| condition={!!user.username} | |
| wrap={children => ( | |
| <Link to={`/users/${user.username}`}>{children}</Link> | |
| )} | |
| > | |
| <CoverContainer> | |
| <CoverPhoto src={user.coverPhoto ? user.coverPhoto : null} /> | |
| <ProfilePhotoContainer> | |
| <AvatarImage | |
| src={user.profilePhoto} | |
| alt={user.name} | |
| type={'user'} | |
| size={40} | |
| /> | |
| </ProfilePhotoContainer> | |
| </CoverContainer> | |
| </ConditionalWrap> | |
| <Content> | |
| <ConditionalWrap | |
| condition={!!user.username} | |
| wrap={children => ( | |
| <Link to={`/users/${user.username}`}>{children}</Link> | |
| )} | |
| > | |
| <Title>{user.name}</Title> | |
| <Username>@{user.username}</Username> | |
| </ConditionalWrap> | |
| {user.betaSupporter && ( | |
| <span style={{ display: 'inline-block', marginBottom: '4px' }}> | |
| <Badge type="beta-supporter" /> | |
| </span> | |
| )} | |
| {user.description && ( | |
| <Description>{renderTextWithLinks(user.description)}</Description> | |
| )} | |
| </Content> | |
| <Actions> | |
| {me && <OutlineButton to={'/me'}>My profile</OutlineButton>} | |
| </Actions> | |
| </ProfileCard> | |
| </HoverWrapper> | |
| ); | |
| } | |
| } | |
| export default compose( | |
| withCurrentUser, | |
| withRouter, | |
| connect() | |
| )(HoverProfile); | |