Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit fcddc29

Browse files
committed
refactor(filters): add thread
1 parent 6dc546e commit fcddc29

File tree

11 files changed

+34
-22
lines changed

11 files changed

+34
-22
lines changed

components/ContentFilter/FilterPanel.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import VideoSourceFilter from './VideoSourceFilter'
1717

1818
import { THREAD } from '../../utils'
1919

20-
const FilterPanel = ({ activeFilter, onSelect }) => {
21-
const thread = THREAD.VIDEO
20+
const FilterPanel = ({ thread, activeFilter, onSelect }) => {
2221
switch (thread) {
2322
case THREAD.POST: {
2423
return (

components/ContentFilter/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
import React from 'react'
88
import PropTypes from 'prop-types'
99
import { Button, Tag } from 'antd'
10+
import R from 'ramda'
1011

1112
import { ICON_CMD } from '../../config'
1213

1314
import Popover from '../Popover'
1415
import { Wrapper, InnerBtnWrapper, FilterIcon } from './styles'
1516
import FilterPanel from './FilterPanel'
1617

17-
import { makeDebugger, isEmptyValue } from '../../utils'
18+
import { makeDebugger, isEmptyValue, THREAD } from '../../utils'
1819
/* eslint-disable no-unused-vars */
1920
const debug = makeDebugger('c:ContentFilter:index')
2021
/* eslint-enable no-unused-vars */
@@ -39,12 +40,18 @@ const FilterTag = ({ onSelect, active, type }) =>
3940
</Tag>
4041
)
4142

42-
const ContentFilter = ({ activeFilter, onSelect }) => (
43+
const ContentFilter = ({ thread, activeFilter, onSelect }) => (
4344
<Wrapper>
4445
<Popover
4546
placement="bottomLeft"
4647
trigger="click"
47-
content={<FilterPanel onSelect={onSelect} activeFilter={activeFilter} />}
48+
content={
49+
<FilterPanel
50+
thread={thread}
51+
onSelect={onSelect}
52+
activeFilter={activeFilter}
53+
/>
54+
}
4855
>
4956
<Button size="small" type="primary" ghost>
5057
<InnerBtnWrapper>
@@ -72,6 +79,7 @@ ContentFilter.propTypes = {
7279
wordLength: PropTypes.string,
7380
}),
7481
onSelect: PropTypes.func.isRequired,
82+
thread: PropTypes.oneOf(R.values(THREAD)),
7583
}
7684

7785
ContentFilter.defaultProps = {
@@ -80,6 +88,7 @@ ContentFilter.defaultProps = {
8088
sort: '',
8189
wordLength: '',
8290
},
91+
thread: THREAD.POST,
8392
}
8493

8594
export default ContentFilter

components/ContentFilter/styles/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const FilterIcon = styled(Img)`
2121
`
2222
export const FiltrPanelWrapper = styled.div`
2323
display: flex;
24-
min-width: 280px;
24+
min-width: 200px;
2525
padding: 12px;
2626
`
2727
export const ColumnWrapper = styled.div`

components/RepoItem/styles/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export const Wrapper = styled.article`
1010
1111
padding-left: 8px;
1212
padding-right: 8px;
13-
padding-top: 22px;
14-
padding-bottom: 22px;
13+
padding-top: 18px;
14+
padding-bottom: 18px;
1515
border-radius: 4px;
1616
border-bottom: 1px solid;
1717
border-bottom-color: ${theme('thread.articleSpliter')};

containers/JobsThread/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class JobsThreadContainer extends React.Component {
104104
<Maybe test={totalCount !== 0}>
105105
<FilterWrapper show={curView === TYPE.RESULT}>
106106
<ContentFilter
107+
thread={THREAD.JOB}
107108
onSelect={logic.onFilterSelect}
108109
activeFilter={filtersData}
109110
/>

containers/PostsThread/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class PostsThreadContainer extends React.Component {
9595
<Maybe test={totalCount !== 0}>
9696
<FilterWrapper show>
9797
<ContentFilter
98+
thread={THREAD.POST}
9899
onSelect={logic.onFilterSelect}
99100
activeFilter={filtersData}
100101
/>

containers/PostsThread/styles/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ export const LeftPart = styled.div`
1919
flex-grow: 1;
2020
width: 100%;
2121
`
22-
2322
export const RightPart = styled.div`
2423
width: 20vw;
2524
margin-left: 30px;
2625
padding-top: 5px;
2726
`
28-
2927
/* fill: ${theme('shell.searchIcon')}; */
3028
// TODO: rename to PublishButn
3129
export const PublishBtn = styled(Button)`
@@ -36,7 +34,8 @@ export const PublishBtn = styled(Button)`
3634
export const FilterWrapper = styled.div`
3735
margin-bottom: 8px;
3836
margin-left: 8px;
39-
display: ${({ show }) => (show ? 'flex' : 'none')};
37+
display: flex;
38+
align-items: center;
4039
`
4140
export const FilterResultHint = styled.div`
4241
margin-top: 4px;

containers/ReposThread/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424

2525
import {
2626
Wrapper,
27+
ViewerWrapper,
2728
LeftPadding,
2829
RightPadding,
2930
LeftPart,
@@ -44,7 +45,7 @@ const View = ({ community, thread, entries, curView, active }) => {
4445
switch (curView) {
4546
case TYPE.RESULT: {
4647
return (
47-
<React.Fragment>
48+
<ViewerWrapper>
4849
{entries.map(entry => (
4950
<RepoItem
5051
key={uid.gen()}
@@ -53,14 +54,14 @@ const View = ({ community, thread, entries, curView, active }) => {
5354
onTitleSelect={logic.onTitleSelect}
5455
/>
5556
))}
56-
</React.Fragment>
57+
</ViewerWrapper>
5758
)
5859
}
5960
case TYPE.RESULT_EMPTY: {
6061
return (
61-
<React.Fragment>
62+
<ViewerWrapper>
6263
<EmptyThread community={community} thread={thread} />
63-
</React.Fragment>
64+
</ViewerWrapper>
6465
)
6566
}
6667
default:
@@ -98,6 +99,7 @@ class ReposThreadContainer extends React.Component {
9899
<Maybe test={totalCount !== 0}>
99100
<FilterWrapper>
100101
<ContentFilter
102+
thread={THREAD.REPO}
101103
onSelect={logic.onFilterSelect}
102104
activeFilter={filtersData}
103105
/>
@@ -106,15 +108,13 @@ class ReposThreadContainer extends React.Component {
106108
</FilterResultHint>
107109
</FilterWrapper>
108110
</Maybe>
109-
110111
<View
111112
community={mainPath}
112113
thread={subPath}
113114
entries={entries}
114115
curView={curView}
115116
active={activeRepo}
116117
/>
117-
118118
<Pagi
119119
left="-10px"
120120
pageNumber={pageNumber}

containers/ReposThread/styles/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export const Wrapper = styled.div`
77
display: flex;
88
max-width: 1400px;
99
`
10-
10+
export const ViewerWrapper = styled.div`
11+
margin-top: -6px;
12+
`
1113
export const LeftPadding = styled.div`
1214
width: 2.5vw;
1315
`
@@ -18,12 +20,10 @@ export const LeftPart = styled.div`
1820
flex-grow: 1;
1921
width: 100%;
2022
`
21-
2223
export const RightPart = styled.div`
2324
width: 20vw;
2425
margin-left: 30px;
2526
`
26-
2727
/* fill: ${theme('shell.searchIcon')}; */
2828
export const PublishBtn = styled(Button)`
2929
margin-top: 8px;
@@ -32,12 +32,13 @@ export const PublishBtn = styled(Button)`
3232
margin-left: 8%;
3333
`
3434
export const FilterWrapper = styled.div`
35+
display: flex;
36+
align-items: center;
3537
margin-bottom: 8px;
3638
margin-left: 8px;
37-
display: ${({ show }) => (show ? 'flex' : 'none')};
3839
`
3940
export const FilterResultHint = styled.div`
40-
margin-top: 4px;
41+
margin-top: 8px;
4142
margin-right: 10px;
4243
color: ${theme('thread.filterResultHint')};
4344
`

containers/VideosThread/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class VideosThreadContainer extends React.Component {
9696
<Maybe test={totalCount !== 0}>
9797
<FilterWrapper>
9898
<ContentFilter
99+
thread={THREAD.VIDEO}
99100
onSelect={logic.onFilterSelect}
100101
activeFilter={filtersData}
101102
/>

0 commit comments

Comments
 (0)