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-viewer): extract common drawer viewers#1112
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
a9354d2
fix(drawer): close ux & model blur issue
mydearxymb058b19
refactor(Drawer): add on enhance
mydearxymd003dc5
refactor(Drawer): adjust styles
mydearxym84e7642
refactor(drawer): wip
mydearxymf073885
refactor(drawer): add fixedHeader for article
mydearxym2226b5b
refactor(drawer): improve fixedHeader function
mydearxym9a31c3a
refactor(comment): use common IconButton
mydearxymf7402eb
refactor(postItem): use common IconButton
mydearxym028147a
style(avatar): adjust color
mydearxym13cb800
refactor(upvote): PromoteList naming & upvote comment style
mydearxym117026d
refactor(comment): remove old Upvote
mydearxym84be17f
refactor(ArticleViewer): seperate PostViewer
mydearxymb0b8a64
refactor(ArticleViewer): a works demo viewer
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
1 change: 1 addition & 0 deletionspublic/icons/static/article/share-solid.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletionpublic/icons/static/article/share.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/close-circle.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/close.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/link-outside.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/more-l.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/next-article-solid.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/next-article.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/previous-article-solid.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/previous-article.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/social/global.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletionpublic/icons/static/social/twitter.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/social/wechat-solid.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/social/wechat.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletionpublic/icons/static/social/zhihu.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletionpublic/icons/static/social/zhihu.svg.1
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
1 change: 1 addition & 0 deletionssrc/components/AvatarsRow/styles/more_item.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
72 changes: 72 additions & 0 deletionssrc/components/Buttons/IconButton.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,72 @@ | ||
import { FC, memo, ReactNode } from 'react' | ||
import { ICON } from '@/config' | ||
import Tooltip from '@/components/Tooltip' | ||
import { Wrapper, Icon, Hint } from './styles/icon_button' | ||
export type TProps = { | ||
path: string | ||
size?: number | ||
mRight?: number | ||
mLeft?: number | ||
mTop?: number | ||
mBottom?: number | ||
dimWhenIdle?: boolean | ||
active?: boolean | ||
hint?: ReactNode | null | ||
hintDelay?: number | ||
hintPlacement?: 'top' | 'bottom' | ||
onClick?: () => void | ||
} | ||
const IconButton: FC<TProps> = ({ | ||
path, | ||
size = 16, | ||
mLeft = 0, | ||
mRight = 10, | ||
mTop = 0, | ||
mBottom = 0, | ||
active = false, | ||
dimWhenIdle = false, | ||
hint = null, | ||
hintDelay = 1000, | ||
hintPlacement = 'top', | ||
onClick = console.log, | ||
}) => { | ||
return ( | ||
<Wrapper | ||
size={size} | ||
mRight={mRight} | ||
mLeft={mLeft} | ||
mTop={mTop} | ||
mBottom={mBottom} | ||
onClick={onClick} | ||
> | ||
{hint ? ( | ||
<Tooltip | ||
placement={hintPlacement} | ||
content={<Hint>{hint}</Hint>} | ||
noPadding | ||
delay={hintDelay} | ||
> | ||
<Icon | ||
src={`${ICON}/${path}`} | ||
size={size} | ||
$active={active} | ||
dimWhenIdle={dimWhenIdle} | ||
/> | ||
</Tooltip> | ||
) : ( | ||
<Icon | ||
src={`${ICON}/${path}`} | ||
size={size} | ||
$active={active} | ||
dimWhenIdle={dimWhenIdle} | ||
/> | ||
)} | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(IconButton) |
1 change: 1 addition & 0 deletionssrc/components/Buttons/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
47 changes: 47 additions & 0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import styled from 'styled-components' | ||
import type { TActive, TSpace } from '@/spec' | ||
import Img from '@/Img' | ||
import { css, theme } from '@/utils' | ||
import type { TProps as TIconButtonProps } from '../IconButton' | ||
type TWrapper = Omit<TIconButtonProps, 'path'> | ||
export const Wrapper = styled.div<TWrapper>` | ||
position: relative; | ||
${css.flex('align-both')}; | ||
width: ${({ size }) => `${size}px`}; | ||
height: ${({ size }) => `${size}px`}; | ||
margin-left: ${({ mLeft }) => `${mLeft}px`}; | ||
margin-right: ${({ mRight }) => `${mRight}px`}; | ||
margin-top: ${({ mTop }) => `${mTop}px`}; | ||
margin-bottom: ${({ mBottom }) => `${mBottom}px`}; | ||
` | ||
type TIcon = { size: number; dimWhenIdle: boolean } & TSpace & TActive | ||
export const Icon = styled(Img)<TIcon>` | ||
fill: ${({ $active }) => | ||
$active ? '#00a59b' : theme('thread.articleDigest')}; | ||
display: block; | ||
width: ${({ size }) => `${size}px`}; | ||
height: ${({ size }) => `${size}px`}; | ||
opacity: ${({ dimWhenIdle }) => (dimWhenIdle ? 0.7 : 1)}; | ||
&:hover { | ||
fill: #00a59b; | ||
opacity: 1; | ||
cursor: pointer; | ||
} | ||
transition: fill 0.2s; | ||
` | ||
export const Hint = styled.div` | ||
color: ${theme('thread.articleDigest')}; | ||
text-align: center; | ||
min-width: 80px; | ||
padding: 5px; | ||
` |
4 changes: 2 additions & 2 deletionssrc/components/Buttons/styles/metircs/arrow_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
32 changes: 0 additions & 32 deletionssrc/components/GotoTop/index.js
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
31 changes: 31 additions & 0 deletionssrc/components/GotoTop/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,31 @@ | ||
/* | ||
* | ||
* GotoTop | ||
* | ||
*/ | ||
import { FC, memo } from 'react' | ||
import { scrollToHeader } from '@/utils' | ||
import { IconButton } from '@/components/Buttons' | ||
import { Wrapper } from './styles' | ||
type TProps = { | ||
testid?: string | ||
} | ||
const GotoTop: FC<TProps> = ({ testid }) => { | ||
return ( | ||
<Wrapper testid={testid} onClick={scrollToHeader}> | ||
<IconButton | ||
path="shape/air-balloon.svg" | ||
hint="回到顶部" | ||
size={20} | ||
mLeft={5} | ||
/> | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(GotoTop) |
29 changes: 3 additions & 26 deletionssrc/components/GotoTop/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 |
---|---|---|
@@ -1,35 +1,12 @@ | ||
import styled from 'styled-components' | ||
import type { TTestable } from '@/spec' | ||
import { css } from '@/utils' | ||
export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({ | ||
'data-test-id': testid, | ||
}))<TTestable>` | ||
${css.size(30)}; | ||
${css.flex('align-both')}; | ||
` | ||
export const holder = 1 |
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.