This repository was archived by the owner on Nov 8, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork37
refactor(article-page): use common article & style adjust#1116
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
13 commits Select commitHold shift + click to select a range
ac47171
refactor(post-content): extract common comp wip
mydearxymd7c619e
refactor(article-digest): re-org layout
mydearxymf0c1ab0
refactor(article-digest): wip
mydearxyma75032c
refactor(avatars-row): new hover effect, awesome
mydearxymcf931d2
refactor(upvote): enhance TS support
mydearxym3b26f02
refactor(article-digest): redesign works digest
mydearxymdc42744
refactor(article): adjust metric system on works
mydearxym1856e4a
refactor(spec): add TMetrice
mydearxym5936866
refactor(article): use common article content
mydearxymeb38ecb
refactor(article): basic fixed header UI/UX
mydearxym01a4f35
refactor(article): wip
mydearxym9060953
refactor(article): header style adjust
mydearxyma80e4d5
chore: clean up
mydearxymFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletionssrc/components/ArticleBaseStats/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* | ||
* ArticleBaseStats | ||
* | ||
*/ | ||
import { FC, memo } from 'react' | ||
import type { TArticle, TContainer } from '@/spec' | ||
import { ICON } from '@/config' | ||
import { buildLog, scrollToComments } from '@/utils' | ||
import { Space } from '@/components/Common' | ||
import { | ||
Wrapper, | ||
ViewsIcon, | ||
CommentWrapper, | ||
CommentIcon, | ||
Count, | ||
CommentCount, | ||
} from './styles' | ||
/* eslint-disable-next-line */ | ||
const log = buildLog('c:ArticleBaseStats:index') | ||
type TProps = { | ||
testid?: string | ||
article: TArticle | ||
container?: TContainer | ||
} | ||
const ArticleBaseStats: FC<TProps> = ({ | ||
testid = 'article-base-stats', | ||
container = 'body', | ||
article, | ||
}) => { | ||
return ( | ||
<Wrapper testid={testid}> | ||
<ViewsIcon src={`${ICON}/article/viewed.svg`} /> | ||
<Count>{article.views}</Count> | ||
<Space left={14} /> | ||
<CommentWrapper onClick={() => scrollToComments(container)}> | ||
<CommentIcon src={`${ICON}/article/comment.svg`} /> | ||
<CommentCount>{article.commentsCount}</CommentCount> | ||
</CommentWrapper> | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(ArticleBaseStats) |
42 changes: 42 additions & 0 deletionssrc/components/ArticleBaseStats/styles/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import styled from 'styled-components' | ||
import type { TTestable } from '@/spec' | ||
import Img from '@/Img' | ||
import { css, theme } from '@/utils' | ||
export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({ | ||
'data-test-id': testid, | ||
}))<TTestable>` | ||
${css.flex('align-center')}; | ||
` | ||
const Icon = styled(Img)` | ||
fill: ${theme('thread.articleDigest')}; | ||
${css.size(14)}; | ||
transition: fill 0.25s; | ||
` | ||
export const ViewsIcon = styled(Icon)`` | ||
export const CommentWrapper = styled.div` | ||
${css.flex('align-center')}; | ||
` | ||
export const CommentIcon = styled(Icon)` | ||
${CommentWrapper}:hover & { | ||
cursor: pointer; | ||
fill: ${theme('thread.articleTitle')}; | ||
} | ||
transition: fill 0.2s; | ||
` | ||
export const Count = styled.div` | ||
color: ${theme('thread.articleDigest')}; | ||
font-size: 15px; | ||
margin-left: 5px; | ||
` | ||
export const CommentCount = styled(Count)` | ||
${CommentWrapper}:hover & { | ||
cursor: pointer; | ||
color: ${theme('thread.articleTitle')}; | ||
} | ||
transition: color 0.2s; | ||
` |
4 changes: 2 additions & 2 deletions...s/content/PostContent/tests/index.test.ts → ...ents/ArticleBaseStats/tests/index.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionsrc/components/AvatarsRow/RealAvatar.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
11 changes: 3 additions & 8 deletionssrc/components/AvatarsRow/styles/real_avatar.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletionssrc/components/Buttons/styles/icon_button.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletionsrc/components/Copyright/styles/readonly_panel.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletionsrc/components/ErrorPage/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
27 changes: 9 additions & 18 deletionssrc/components/Maybe/index.js → src/components/Maybe/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 3 additions & 7 deletionssrc/components/Navigator/DigestView.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletionssrc/components/Navigator/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionsrc/components/Tooltip/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionsrc/components/Tooltip/styles/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletionssrc/components/Upvote/ArticleLayout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* | ||
* Upvote | ||
* | ||
*/ | ||
import { FC, memo } from 'react' | ||
import { buildLog } from '@/utils' | ||
import { UPVOTE_LAYOUT } from '@/constant' | ||
import TotalCount from './TotalCount' | ||
import UpvoteBtn from './UpvoteBtn' | ||
import { Wrapper, UpWrapper, CountWrapper } from './styles/article_layout' | ||
/* eslint-disable-next-line */ | ||
const log = buildLog('c:Upvote:index') | ||
type TProps = { | ||
testid?: string | ||
count?: number | ||
viewerHasUpvoted?: boolean | ||
alias?: string // 觉得很赞(default), 觉得很酷(works), 学到了(blog), 感兴趣(meetup), 有意思(Radar) | ||
} | ||
const Upvote: FC<TProps> = ({ | ||
testid = 'upvote', | ||
count = 0, | ||
viewerHasUpvoted = false, | ||
alias = '觉得很赞', | ||
}) => { | ||
return ( | ||
<Wrapper testid={testid}> | ||
<UpWrapper> | ||
<UpvoteBtn | ||
viewerHasUpvoted={viewerHasUpvoted} | ||
type={UPVOTE_LAYOUT.ARTICLE} | ||
/> | ||
</UpWrapper> | ||
<CountWrapper> | ||
<TotalCount count={count} /> | ||
</CountWrapper> | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(Upvote) |
2 changes: 1 addition & 1 deletionsrc/components/Upvote/CommentView.tsx → src/components/Upvote/CommentLayout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionsrc/components/Upvote/DefaultView.tsx → src/components/Upvote/DefaultLayout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.