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

Commit 08b471b

Browse files
authored
feat(articles): search ux (#1288)
* feat(search-ux): extract FAQ list * chore: mini adjust * refactor(utils): extract lineClamp helper * refactor(utils): naming * refactor(faq): add search hint mode * refactor(search): basic ux
1 parent fd76f2a commit 08b471b

File tree

42 files changed

+493
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+493
-225
lines changed

src/containers/content/CoolGuideContent/styles/footer/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,11 @@ export const ContributorsWrapper = styled.div`
3737
`
3838

3939
export const Desc = styled.div`
40+
${css.lineClamp(2)}
4041
color: ${theme('thread.articleDigest')};
4142
margin-top: -10px;
4243
opacity: 0.8;
4344
44-
position: relative;
45-
display: -webkit-box;
46-
-webkit-line-clamp: 2;
47-
overflow: hidden;
48-
text-overflow: ellipsis;
49-
-webkit-box-orient: vertical;
50-
5145
${Block}:hover & {
5246
opacity: 1;
5347
}

src/containers/content/ExploreContent/styles/community_card.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ export const Slash = styled.div`
6363
font-weight: bold;
6464
`
6565
export const Raw = styled.div`
66-
position: relative;
67-
display: -webkit-box;
68-
-webkit-line-clamp: 1;
69-
overflow: hidden;
70-
text-overflow: ellipsis;
71-
-webkit-box-orient: vertical;
66+
${css.lineClamp(1)};
7267
`
7368
export const JoinWrapper = styled.div`
7469
${css.flex('align-center')};
@@ -97,16 +92,11 @@ export const Title = styled.a`
9792
}
9893
`
9994
export const Desc = styled.div`
95+
${css.lineClamp(2)}
10096
margin-top: 8px;
10197
color: ${theme('thread.articleDigest')};
10298
word-break: break-all;
10399
font-size: 13px;
104-
position: relative;
105-
display: -webkit-box;
106-
-webkit-line-clamp: 2;
107-
overflow: hidden;
108-
text-overflow: ellipsis;
109-
-webkit-box-orient: vertical;
110100
`
111101
export const ActivitySpark = styled.div`
112102
width: 80px;

src/containers/content/HaveADrinkContent/styles/body/catalog.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,9 @@ export const Title = styled.div`
9898
font-weight: bold;
9999
`
100100
export const Desc = styled.div`
101+
${css.lineClamp(2)}
101102
color: ${theme('thread.articleDigest')};
102103
opacity: 0.8;
103104
font-size: 13px;
104105
margin-top: 5px;
105-
106-
position: relative;
107-
display: -webkit-box;
108-
-webkit-line-clamp: 2;
109-
overflow: hidden;
110-
text-overflow: ellipsis;
111-
-webkit-box-orient: vertical;
112106
`

src/containers/content/UserContent/styles/mobile_banner.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ export const NickName = styled.div`
2424
color: ${theme('thread.articleTitle')};
2525
`
2626
export const Bio = styled.div`
27+
${css.lineClamp(2)}
2728
font-size: 13px;
2829
color: ${theme('thread.articleDigest')};
29-
position: relative;
30-
display: -webkit-box;
31-
-webkit-line-clamp: 2;
32-
overflow: hidden;
33-
text-overflow: ellipsis;
34-
-webkit-box-orient: vertical;
3530
`

src/containers/editor/CommunityEditor/styles/content/more_info.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ export const Title = styled.div`
3131
font-size: 17px;
3232
`
3333
export const Desc = styled.div`
34+
${css.lineClamp(2)}
3435
color: ${theme('thread.articleDigest')};
3536
font-size: 14px;
36-
position: relative;
37-
display: -webkit-box;
38-
-webkit-line-clamp: 2;
39-
overflow: hidden;
40-
text-overflow: ellipsis;
41-
-webkit-box-orient: vertical;
4237
`

src/containers/thread/ArticlesThread/index.tsx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
import { FC } from 'react'
8-
import dynamic from 'next/dynamic'
98
import { includes } from 'ramda'
109
import { isMobile } from 'react-device-detect'
1110

@@ -15,6 +14,7 @@ import { buildLog } from '@/utils/logger'
1514
import { bond } from '@/utils/mobx'
1615

1716
import PagedArticles from '@/widgets/PagedArticles'
17+
import FaqList from '@/widgets/FaqList'
1818
import ViewportTracker from '@/widgets/ViewportTracker'
1919
import ThreadSidebar from '@/containers/thread/ThreadSidebar'
2020
import ArticlesFilter from '@/widgets/ArticlesFilter'
@@ -27,7 +27,14 @@ import {
2727
MobileCardsMainWrapper,
2828
FilterWrapper,
2929
} from './styles'
30-
import { useInit, inAnchor, outAnchor, onFilterSelect } from './logic'
30+
import {
31+
useInit,
32+
inAnchor,
33+
outAnchor,
34+
onFilterSelect,
35+
onSearch,
36+
closeSearch,
37+
} from './logic'
3138

3239
/* eslint-disable-next-line */
3340
const log = buildLog('C:ArticlesThread')
@@ -47,6 +54,7 @@ const ArticlesThreadContainer: FC<TProps> = ({ articlesThread: store }) => {
4754
showFilters,
4855
c11n,
4956
resState,
57+
mode,
5058
} = store
5159
const { bannerLayout } = c11n
5260
const { pageNumber, totalCount } = pagedArticlesData
@@ -72,16 +80,22 @@ const ArticlesThreadContainer: FC<TProps> = ({ articlesThread: store }) => {
7280
activeFilter={filtersData}
7381
pageNumber={pageNumber}
7482
totalCount={totalCount}
83+
mode={mode}
84+
onSearch={onSearch}
85+
closeSearch={closeSearch}
7586
/>
7687
</FilterWrapper>
7788
)}
78-
<PagedArticles
79-
data={pagedArticlesData}
80-
curCommunity={curCommunity}
81-
thread={curThread}
82-
resState={resState as TResState}
83-
c11n={c11n}
84-
/>
89+
{mode === 'default' && (
90+
<PagedArticles
91+
data={pagedArticlesData}
92+
curCommunity={curCommunity}
93+
thread={curThread}
94+
resState={resState as TResState}
95+
c11n={c11n}
96+
/>
97+
)}
98+
{mode === 'search' && <FaqList mode="search-hint" />}
8599
</TheMainWrapper>
86100

87101
{!isMobile && bannerLayout === C11N.CLASSIC && <ThreadSidebar />}

src/containers/thread/ArticlesThread/logic.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ let sub$ = null
3535
export const inAnchor = (): void => store?.showTopModeline(false)
3636
export const outAnchor = (): void => store?.showTopModeline(true)
3737

38+
export const onSearch = (v: string): void => {
39+
store.mark({ mode: 'search', searchValue: v })
40+
}
41+
42+
export const closeSearch = (): void => {
43+
store.mark({ mode: 'default' })
44+
}
45+
3846
export const onFilterSelect = (option: TArticleFilter): void => {
3947
store.selectFilter(option)
4048
// console.log('cur filter: ', store.filtersData)

src/containers/thread/ArticlesThread/store.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import {
3434
} from '@/model'
3535

3636
const ArticlesThread = T.model('ArticlesThread', {
37+
mode: T.optional(T.enumeration(['default', 'search']), 'default'),
38+
searchValue: T.optional(T.string, ''),
3739
pagedPosts: T.optional(PagedPosts, emptyPagi),
3840
pagedJobs: T.optional(PagedJobs, emptyPagi),
3941
pagedBlogs: T.optional(PagedBlogs, emptyPagi),

src/containers/thread/HelpThread/Sidebar.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/containers/thread/HelpThread/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { bond } from '@/utils/mobx'
1010

1111
import type { TStore } from './store'
1212

13-
import Sidebar from './Sidebar'
13+
import FaqList from '@/widgets/FaqList'
1414
import Category from './Category'
1515

1616
import { Wrapper, MainWrapper, CatsWapper } from './styles'
@@ -80,7 +80,7 @@ const HelpThreadContainer: FC<TProps> = ({
8080
/>
8181
</CatsWapper>
8282
</MainWrapper>
83-
<Sidebar />
83+
<FaqList />
8484
</Wrapper>
8585
)
8686
}

0 commit comments

Comments
 (0)