Download spectrum/src/views/thread/components/stickyHeader.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/views/thread/components/stickyHeader.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/src/views/thread/components/stickyHeader.js
-
curl -L -o stickyHeader.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/views/thread/components/stickyHeader.js
1.94 kB
| // @flow | |
| import * as React from 'react'; | |
| import { connect } from 'react-redux'; | |
| import compose from 'recompose/compose'; | |
| import { Link } from 'react-router-dom'; | |
| import { truncate } from 'src/helpers/utils'; | |
| import { UserAvatar } from 'src/components/avatar'; | |
| import { convertTimestampToDate } from 'shared/time-formatting'; | |
| import type { GetThreadType } from 'shared/graphql/queries/thread/getThread'; | |
| import getThreadLink from 'src/helpers/get-thread-link'; | |
| import { useAppScroller } from 'src/hooks/useAppScroller'; | |
| import ActionsDropdown from './actionsDropdown'; | |
| import { | |
| StickyHeaderContent, | |
| CommunityHeaderName, | |
| CommunityHeaderMeta, | |
| CommunityHeaderSubtitle, | |
| CommunityHeaderMetaCol, | |
| StickyHeaderContainer, | |
| StickyHeaderActionsContainer, | |
| } from '../style'; | |
| type Props = { | |
| thread: GetThreadType, | |
| }; | |
| const StickyHeader = (props: Props) => { | |
| const { thread } = props; | |
| const { scrollToTop } = useAppScroller(); | |
| const { channel } = thread; | |
| const createdAt = new Date(thread.createdAt).getTime(); | |
| const timestamp = convertTimestampToDate(createdAt); | |
| return ( | |
| <StickyHeaderContainer> | |
| <StickyHeaderContent onClick={scrollToTop}> | |
| <CommunityHeaderMeta> | |
| <UserAvatar showHoverProfile username={thread.author.user.username} /> | |
| <CommunityHeaderMetaCol> | |
| <CommunityHeaderName> | |
| {truncate(thread.content.title, 80)} | |
| </CommunityHeaderName> | |
| <CommunityHeaderSubtitle> | |
| <Link to={getThreadLink(thread)}>{timestamp}</Link> | |
| </CommunityHeaderSubtitle> | |
| </CommunityHeaderMetaCol> | |
| </CommunityHeaderMeta> | |
| </StickyHeaderContent> | |
| {channel.channelPermissions.isMember && ( | |
| <StickyHeaderActionsContainer> | |
| <ActionsDropdown thread={thread} /> | |
| </StickyHeaderActionsContainer> | |
| )} | |
| </StickyHeaderContainer> | |
| ); | |
| }; | |
| export default compose(connect())(StickyHeader); | |