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(articles-thread): extract articles thread#1108

Merged
mydearxym merged 22 commits intodevfromextract-articles-thread
Jul 10, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
22 commits
Select commitHold shift + click to select a range
aa30936
refactor(articlesFilter): adjust props
mydearxymJul 7, 2021
2158cc2
feat: add useMST hooks, awesome
mydearxymJul 7, 2021
851e73c
chore: missing inline doc
mydearxymJul 7, 2021
836c17d
chore(articles-thread): basic setup
mydearxymJul 7, 2021
552a23d
chore(articles-thread): drop PostsThread
mydearxymJul 7, 2021
e2b63b6
refactor(articlesFilter): wip
mydearxymJul 7, 2021
4f0a490
fix(preview): edge case
mydearxymJul 7, 2021
e54cf3e
chore(types): add common used useMST store type
mydearxymJul 7, 2021
6528a81
refactor(useMST): split it into useAccount
mydearxymJul 8, 2021
5e0d676
refactor(useAccount): improve type
mydearxymJul 8, 2021
baf1b6f
refactor(useAccount): imporve substore hooks
mydearxymJul 8, 2021
9a2586a
chore(articles-thread): filter naming
mydearxymJul 8, 2021
dff5841
refactor: wip
mydearxymJul 9, 2021
3c6cfab
refactor(loadingEffect): rename to loading & ts
mydearxymJul 9, 2021
20c1f1d
refactor: wip
mydearxymJul 9, 2021
c8575e3
refactor: wip
mydearxymJul 9, 2021
5d0830b
refactor(articlesThread): adjust props
mydearxymJul 9, 2021
e7af260
refactor(articlesThread): make onPreview eventify
mydearxymJul 9, 2021
2f2cd30
chore(articlesThread): fmt
mydearxymJul 9, 2021
0d554f5
chore(articlesThread): mv holygrail tabs to common layout
mydearxymJul 10, 2021
3eb439c
refactor(community-content): re-org
mydearxymJul 10, 2021
9b33d35
refactor(articlesThread): tab change wip
mydearxymJul 10, 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
5 changes: 0 additions & 5 deletionsserver/routes.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,11 +124,6 @@ router.route('/:community/help-center').get((req, res) => {
return renderAndCache({ req, res, path: '/help-center' })
})

// NOTE: TMP: 博客
router.route('/:community/blogs').get((req, res) => {
return renderAndCache({ req, res, path: '/home/blogs' })
})

// 社区主页
router.route('/:community/:thread').get((req, res) => {
if (
Expand Down
11 changes: 5 additions & 6 deletionssrc/components/ArticleItemPrefixLabel/ReadLabel.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
import { FC, memo } from 'react'
import { useAccount } from '@/hooks'

import { ReadedLabel } from './styles'

import type { TProps } from './index'

const ReadLabel: FC<TProps> = ({ entry, accountInfo, topOffset = '20px' }) => {
const ReadLabel: FC<TProps> = ({ entry, topOffset = '20px' }) => {
const { c11n } = useAccount()
const { isLogin, markViewed } = c11n

const { viewerHasViewed } = entry
const {
isLogin,
customization: { markViewed },
} = accountInfo

if (!isLogin) return null
if (markViewed && viewerHasViewed) {
Expand Down
12 changes: 2 additions & 10 deletionssrc/components/ArticleItemPrefixLabel/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@

import { FC, memo } from 'react'

import type { TAccount } from '@/spec'
import { buildLog } from '@/utils'
import { PinIcon } from './styles'
import ReadLabel from './ReadLabel'
Expand All@@ -15,23 +14,16 @@ import ReadLabel from './ReadLabel'
const log = buildLog('c:ArticleItemPrefixLabel:index')

export type TProps = {
accountInfo: TAccount
topOffset?: string
entry: {
viewerHasViewed?: boolean
pin?: boolean
}
}
const ArticleItemPrefixLabel: FC<TProps> = ({
entry,
accountInfo,
topOffset = '22px',
}) => {
const ArticleItemPrefixLabel: FC<TProps> = ({ entry, topOffset = '22px' }) => {
if (entry.pin) return <PinIcon top={topOffset} />

return (
<ReadLabel entry={entry} accountInfo={accountInfo} topOffset={topOffset} />
)
return <ReadLabel entry={entry} topOffset={topOffset} />
}

export default memo(ArticleItemPrefixLabel)
62 changes: 40 additions & 22 deletionssrc/components/ArticlesFilter/DesktopView.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,48 +5,66 @@
*/

import { FC, memo } from 'react'
import dynamic from 'next/dynamic'

import type { TThread, TAccount, TArticleFilter } from '@/spec'
import { THREAD } from '@/constant'
import type { TArticleFilter, TResState } from '@/spec'

import { TYPE } from '@/constant'
import { buildLog } from '@/utils'
import { useViewing } from '@/hooks'

import FilterButton from './FilterButton'
importSelectedTags from './SelectedTags'
importSelectedFilters from './SelectedFilters'
import FilterResult from './FilterResult'

import { Wrapper, MainFilterWrapper } from './styles'

/* eslint-disable-next-line */
const log = buildLog('c:ArticlesFilter:index')

const LavaLampLoading = dynamic(
() => import('@/components/Loading/LavaLampLoading'),
{
/* eslint-disable react/display-name */
loading: () => <div />,
ssr: false,
},
)

type TProps = {
activeFilter: TArticleFilter
onSelect: (filter: TArticleFilter) => void
thread: TThread
accountInfo: TAccount
pageNumber?: number
totalCount?: number
resState?: TResState
}

const ArticlesFilter: FC<TProps> = ({
thread = THREAD.POST,
activeFilter = {},
onSelect,
accountInfo: { isLogin },
pageNumber = 1,
totalCount = 0,
}) => (
<Wrapper>
<MainFilterWrapper>
<FilterButton
thread={thread}
onSelect={onSelect}
isLogin={isLogin}
activeFilter={activeFilter}
/>

<SelectedTags onSelect={onSelect} activeFilter={activeFilter} />
</MainFilterWrapper>
<FilterResult totalCount={totalCount} />
</Wrapper>
)
resState = TYPE.RES_STATE.DONE,
}) => {
const { activeThread } = useViewing()

return (
<Wrapper>
<MainFilterWrapper>
<FilterButton
thread={activeThread}
onSelect={onSelect}
activeFilter={activeFilter}
/>
<SelectedFilters onSelect={onSelect} activeFilter={activeFilter} />
</MainFilterWrapper>

{resState === TYPE.RES_STATE.LOADING && (
<LavaLampLoading top={2} right={28} />
)}
<FilterResult pageNumber={pageNumber} totalCount={totalCount} />
</Wrapper>
)
}

export default memo(ArticlesFilter)
11 changes: 4 additions & 7 deletionssrc/components/ArticlesFilter/FilterButton.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ import dynamic from 'next/dynamic'

import type { TThread, TArticleFilter } from '@/spec'
import { ICON_CMD } from '@/config'
import { useAccount } from '@/hooks'

import Tooltip from '@/components/Tooltip'

Expand All@@ -21,17 +22,13 @@ const FilterPanel = dynamic(() => import('./FilterPanel/index'), {

type TProps = {
thread: TThread
isLogin: boolean
activeFilter: TArticleFilter
onSelect: (filter: TArticleFilter) => void
}

const FilterButton: FC<TProps> = ({
thread,
onSelect,
isLogin,
activeFilter,
}) => {
const FilterButton: FC<TProps> = ({ thread, onSelect, activeFilter }) => {
const { isLogin } = useAccount()

return (
<Wrapper>
<Tooltip
Expand Down
7 changes: 6 additions & 1 deletionsrc/components/ArticlesFilter/FilterResult.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
import { FC, memo } from 'react'

import DotDivider from '@/components/DotDivider'

import { Wrapper, ResultText } from './styles/filter_result'

type TProps = {
totalCount: number
pageNumber: number
}

const FilterResult: FC<TProps> = ({ totalCount }) => {
const FilterResult: FC<TProps> = ({pageNumber,totalCount }) => {
return (
<Wrapper>
<ResultText>第 {pageNumber} 页</ResultText>
<DotDivider space={8} />
<ResultText>共 {totalCount} 条</ResultText>
</Wrapper>
)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ import type { TArticleFilter } from '@/spec'
import { isEmptyValue } from '@/utils'

import Tag from '@/components/Tag'
import { Wrapper, TagWrapper } from './styles/selected_tags'
import { Wrapper, TagWrapper } from './styles/selected_filters'

const filterDict = {
TODAY: '今天',
Expand DownExpand Up@@ -51,7 +51,7 @@ type TProps = {
activeFilter: TArticleFilter
}

constSelectedTags: FC<TProps> = ({ activeFilter, onSelect }) => (
constSelectedFilters: FC<TProps> = ({ activeFilter, onSelect }) => (
<Wrapper>
{keys(activeFilter).map((filterKey) => (
<FilterTag
Expand All@@ -64,4 +64,4 @@ const SelectedTags: FC<TProps> = ({ activeFilter, onSelect }) => (
</Wrapper>
)

export default memo(SelectedTags)
export default memo(SelectedFilters)
8 changes: 3 additions & 5 deletionssrc/components/ArticlesFilter/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@
*
*/

importReact from 'react'
import{ Fragment, memo } from 'react'

import { useDevice } from '@/hooks'
import { buildLog } from '@/utils'
Expand All@@ -17,9 +17,7 @@ const log = buildLog('c:ArticlesFilter:index')
const ArticlesFilter = (props) => {
const { isMobile } = useDevice()

return (
<React.Fragment>{!isMobile && <DesktopView {...props} />}</React.Fragment>
)
return <Fragment>{!isMobile && <DesktopView {...props} />}</Fragment>
}

export defaultReact.memo(ArticlesFilter)
export default memo(ArticlesFilter)
1 change: 0 additions & 1 deletionsrc/components/ArticlesFilter/styles/filter_result.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,5 +7,4 @@ export const Wrapper = styled.div`
`
export const ResultText = styled.div`
color: ${theme('thread.filterResultHint')};
margin-right: 3px;
`
2 changes: 1 addition & 1 deletionsrc/components/Buttons/DropdownButton/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,7 @@ import {
MoreIcon,
} from '../styles/dropdown_button'

const log = buildLog('C:PostsThread')
const log = buildLog('C:DropdownButton')

export type TOption = {
title: string
Expand Down
6 changes: 1 addition & 5 deletionssrc/components/JobItem/index.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,11 +36,7 @@ const JobItem = ({
opacity={getOpacity(entry, active, accountInfo)}
divider={contentDivider}
>
<ArticleItemPrefixLabel
entry={entry}
accountInfo={accountInfo}
topOffset="9px"
/>
<ArticleItemPrefixLabel entry={entry} topOffset="9px" />
<DigestView
entry={entry}
onPreview={onPreview}
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
import React from 'react'
import T from 'prop-types'
import { Fragment, FC, memo } from 'react'
import { range } from 'ramda'
import styled, { useTheme } from 'styled-components'
import ContentLoader from 'react-content-loader'
Expand DownExpand Up@@ -27,22 +26,22 @@ const LoadingItem = ({ theme }) => (
</ContentLoader>
)

const ArticleContentLoading = ({ num }) => {
const theme = useTheme()

return range(0, num).map((item) => (
<LoadingWrapper key={item}>
<LoadingItem theme={theme} />
</LoadingWrapper>
))
type TProps = {
num?: number
}

ArticleContentLoading.propTypes = {
num: T.number,
}
const ArticleContentLoading: FC<TProps> = ({ num = 1 }) => {
const theme = useTheme()

ArticleContentLoading.defaultProps = {
num: 1,
return (
<Fragment>
{range(0, num).map((item) => (
<LoadingWrapper key={item}>
<LoadingItem theme={theme} />
</LoadingWrapper>
))}
</Fragment>
)
}

export default ArticleContentLoading
export defaultmemo(ArticleContentLoading)
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
import React from 'react'
import T from 'prop-types'
import { FC, memo } from 'react'
import { range } from 'ramda'
import ContentLoader from 'react-content-loader'
import { useTheme } from 'styled-components'
Expand All@@ -8,7 +7,7 @@ import { buildLog } from '@/utils'
import { Wrapper, CheatsheetCard } from './styles'

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

const LoadingBlock = ({ theme }) => (
<CheatsheetCard>
Expand All@@ -32,7 +31,11 @@ const LoadingBlock = ({ theme }) => (
</CheatsheetCard>
)

const CheatSheetLoading = ({ column }) => {
type TProps = {
column: number
}

const CheatSheetLoading: FC<TProps> = ({ column = 4 }) => {
const theme = useTheme()

return (
Expand All@@ -44,12 +47,4 @@ const CheatSheetLoading = ({ column }) => {
)
}

CheatSheetLoading.propTypes = {
column: T.number,
}

CheatSheetLoading.defaultProps = {
column: 4,
}

export default CheatSheetLoading
export default memo(CheatSheetLoading)
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
importReact from 'react'
import{ FC, memo } from 'react'
import styled, { useTheme } from 'styled-components'
import ContentLoader from 'react-content-loader'

import type { TThemeMap } from '@/spec'

// Config-page: http://danilowoz.com/create-react-content-loader/
const LoadingWrapper = styled.div`
width: 100%;
overflow: hidden;
`

const CommentLoading = () => {
const theme = useTheme()
const CommentLoading: FC = () => {
const theme = useTheme() as TThemeMap

return (
<LoadingWrapper>
Expand All@@ -31,4 +33,4 @@ const CommentLoading = () => {
)
}

export default CommentLoading
export defaultmemo(CommentLoading)
Loading

[8]ページ先頭

©2009-2025 Movatter.jp