Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

refactor(article-page): use common article & style adjust#1116

Merged
mydearxym merged 13 commits intodevfromarticle-page
Jul 21, 2021
Merged
Show file tree
Hide file tree
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
mydearxymJul 19, 2021
d7c619e
refactor(article-digest): re-org layout
mydearxymJul 19, 2021
f0c1ab0
refactor(article-digest): wip
mydearxymJul 19, 2021
a75032c
refactor(avatars-row): new hover effect, awesome
mydearxymJul 19, 2021
cf931d2
refactor(upvote): enhance TS support
mydearxymJul 19, 2021
3b26f02
refactor(article-digest): redesign works digest
mydearxymJul 20, 2021
dc42744
refactor(article): adjust metric system on works
mydearxymJul 20, 2021
1856e4a
refactor(spec): add TMetrice
mydearxymJul 20, 2021
5936866
refactor(article): use common article content
mydearxymJul 21, 2021
eb38ecb
refactor(article): basic fixed header UI/UX
mydearxymJul 21, 2021
01a4f35
refactor(article): wip
mydearxymJul 21, 2021
9060953
refactor(article): header style adjust
mydearxymJul 21, 2021
a80e4d5
chore: clean up
mydearxymJul 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletionssrc/components/ArticleBaseStats/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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;
`
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
// import React from 'react'
// import { shallow } from 'enzyme'

// importPostContent from '../index'
// importArticleBaseStats from '../index'

describe('TODO <PostContent />', () => {
describe('TODO <ArticleBaseStats />', () => {
it('Expect to have unit tests specified', () => {
expect(true).toEqual(true)
})
Expand Down
2 changes: 1 addition & 1 deletionsrc/components/AvatarsRow/RealAvatar.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ const RealAvatar: FC<TProps> = ({ user, size, onUserSelect }) => {
return (
<Tooltip
content={<UserPopContent>{user.nickname}</UserPopContent>}
delay={200}
delay={0}
contentHeight={getAvatarSize(size, 'number') as string}
showArrow={false}
noPadding
Expand Down
11 changes: 3 additions & 8 deletionssrc/components/AvatarsRow/styles/real_avatar.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,6 @@ import ImgFallback from '@/components/ImgFallback'
import { getLiSize, getAvatarSize } from './metric'
import type { TAvatarSize } from '../spec'

import { AvatarsWrapper } from './index'

// height: 49px;
type TWrapper = { size: TAvatarSize }
export const Wrapper = styled.li<TWrapper>`
Expand All@@ -19,16 +17,13 @@ export const Wrapper = styled.li<TWrapper>`
z-index: 2;
filter: grayscale(0.3);

${AvatarsWrapper}:hover & {
margin: 0 5px;
transition-delay: 0.3s;
}

&:hover {
filter: grayscale(0);
z-index: 3;
transform: scale(1.2);
}

transition: all 0.25s;
transition: all 0.2s;
`
type TAvatarsImg = { size: string; onClick: () => void; scrollPosition: any }
export const AvatarsImg = styled(Img)<TAvatarsImg>`
Expand Down
2 changes: 0 additions & 2 deletionssrc/components/Buttons/styles/icon_button.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,6 @@ 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`};
Expand All@@ -19,7 +18,6 @@ export const Wrapper = styled.div<TWrapper>`
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 }) =>
Expand Down
3 changes: 2 additions & 1 deletionsrc/components/Copyright/styles/readonly_panel.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,8 @@ import { css, theme } from '@/utils'
export const Wrapper = styled.div`
${css.flexColumn()};
width: 240px;
padding-left: 5px;
padding: 10px;
padding-left: 15px;
`
export const Header = styled.div`
${css.flex('align-center')};
Expand Down
3 changes: 2 additions & 1 deletionsrc/components/ErrorPage/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import { FC, memo } from 'react'
import { useRouter } from 'next/router'
import Link from 'next/link'

import type { TMetric } from '@/spec'
import { METRIC } from '@/constant'
import { ICON_BASE } from '@/config'
import { buildLog } from '@/utils'
Expand DownExpand Up@@ -37,7 +38,7 @@ export type TProps = {
errorCode?: number // 400 | 500 | 404
target?: string
testid?: string
metric?:string
metric?:TMetric
}

const ErrorPage: FC<TProps> = ({
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
/*
*
* Maybe
*
*/

import React from 'react'
import T from 'prop-types'
import { FC, memo, ReactNode } from 'react'
import { isEmpty } from 'ramda'

import { buildLog } from '@/utils'
Expand All@@ -18,7 +15,13 @@ const MaybeLoading = ({ loading }) => {
return <div>{loading}</div>
}

const Maybe = ({ children, test, loading }) => {
type TProps = {
children: ReactNode
test: boolean
loading?: boolean
}

const Maybe: FC<TProps> = ({ children, test, loading = false }) => {
if (Array.isArray(test) && isEmpty(test)) {
return <MaybeLoading loading={loading} />
}
Expand All@@ -29,16 +32,4 @@ const Maybe = ({ children, test, loading }) => {
return <>{children}</>
}

Maybe.propTypes = {
// https://www.npmjs.com/package/prop-types
children: T.node.isRequired,
test: T.any,
loading: T.node,
}

Maybe.defaultProps = {
test: '',
loading: null,
}

export default Maybe
export default memo(Maybe)
10 changes: 3 additions & 7 deletionssrc/components/Navigator/DigestView.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { FC, memo } from 'react'

import type { TMetric } from '@/spec'
import { METRIC } from '@/constant'

import BlinkCursor from '@/components/BlinkCursor'

import {
Expand DownExpand Up@@ -30,7 +30,7 @@ const renderMainEntries = (metric) => {
}

type TProps = {
metric:string
metric:TMetric
layout: TC11NLayout
showLogoText: boolean
isOnline: boolean
Expand All@@ -44,11 +44,7 @@ const DigestView: FC<TProps> = ({ metric, showLogoText, isOnline, layout }) => {
{showLogoText && <LogoText>oderPlanets</LogoText>}
</LogoLink>

{showLogoText ? (
<LogoMargin layout={layout} />
) : (
<BlinkCursor duration={1.2} height={14} left={5} right={2} />
)}
<BlinkCursor duration={1.6} height={14} left={5} right={2} />

{isOnline ? (
renderMainEntries(metric)
Expand Down
10 changes: 5 additions & 5 deletionssrc/components/Navigator/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,10 @@
* Navigator
*/

import { FC, memo, Fragment } from 'react'
import { contains, values } from 'ramda'
import { FC, memo } from 'react'
import { contains } from 'ramda'

import type { TCommunity, TC11NLayout } from '@/spec'
import type { TCommunity, TC11NLayout, TMetric } from '@/spec'
import { C11N, METRIC, HCN } from '@/constant'
import { buildLog } from '@/utils'

Expand All@@ -17,7 +17,7 @@ const log = buildLog('c:Navigator:index')

const shouldShowLogoText = (
communityRaw: string,
metric:string,
metric:TMetric,
layout: TC11NLayout,
): boolean => {
if (contains(metric, [METRIC.ARTICLE, METRIC.ARTICLE_EDITOR])) return false
Expand All@@ -30,7 +30,7 @@ type TProps = {
community: TCommunity
isOnline?: boolean
layout: TC11NLayout
metric?:string
metric?:TMetric
}

const Navigator: FC<TProps> = ({
Expand Down
2 changes: 1 addition & 1 deletionsrc/components/Tooltip/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58,7 +58,7 @@ const Tooltip: FC<TProps> = ({
duration = 0,
content,
hideOnClick = true,
showArrow =true,
showArrow =false,
footerBehavior = 'default',
trigger = 'mouseenter focus',
onConfirm,
Expand Down
2 changes: 1 addition & 1 deletionsrc/components/Tooltip/styles/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ export const NoPaddingStyledTippy = styled(StyledTippy)`
export const ContentWrapper = styled.div<{ contentHeight: string }>`
position: relative;
height: ${({ contentHeight }) => contentHeight};
z-index: 1;
/*z-index: 1; */
`
const Arrow = styled.div`
position: absolute;
Expand Down
48 changes: 48 additions & 0 deletionssrc/components/Upvote/ArticleLayout.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff 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)
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@ import { buildLog } from '@/utils'
import TotalCount from './TotalCount'
import UpvoteBtn from './UpvoteBtn'

import { Wrapper, UpWrapper, CountWrapper } from './styles/comment_view'
import { Wrapper, UpWrapper, CountWrapper } from './styles/comment_layout'

/* eslint-disable-next-line */
const log = buildLog('c:Upvote:index')
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ import AvatarsRow from '@/components/AvatarsRow'
import UpvoteBtn from './UpvoteBtn'
import Desc from './Desc'

import { Wrapper } from './styles/default_view'
import { Wrapper } from './styles/default_layout'

/* eslint-disable-next-line */
const log = buildLog('c:Upvote:index')
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp