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

Commit fc3d971

Browse files
authored
refactor(jobs-thread): rethink on tags (#1034)
* refactor(meetups): convert to ts && fix warnings * refactor(meetups): convert more js to ts * refactor(filtersMenu): covert to ts && fix warnings * refactor(jobs): use MenuFilters instead of tags
1 parent dde0e02 commit fc3d971

File tree

49 files changed

+551
-269
lines changed

Some content is hidden

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

49 files changed

+551
-269
lines changed

src/components/FiltersMenu/Filter/index.js renamed to src/components/FiltersMenu/Filter/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const Filter = ({ id, expandMenuId, activeMap, options, onSelect, revert }) => {
6060
))}
6161
</RadioWrapper>
6262
) : (
63-
<RadioWrapper value="">
63+
<RadioWrapper revert={revert}>
6464
<RadioItem>
6565
{!revert ? (
6666
<>

src/components/FiltersMenu/Header.js renamed to src/components/FiltersMenu/Header.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,24 @@ import {
1212
HelpHint,
1313
} from './styles/header'
1414

15-
const Header = ({ title, showReset, reset }) => {
15+
type TProps = {
16+
title: string
17+
showReset: boolean
18+
onReset: () => void
19+
}
20+
21+
const Header: React.FC<TProps> = ({ title, showReset, onReset }) => {
1622
return (
1723
<Wrapper>
1824
<Title active={showReset}>{title}</Title>
1925
<OperatorsWrapper>
26+
{/* @ts-ignore */}
2027
<Tooltip
2128
content={<HelpHint>重置筛选条件</HelpHint>}
2229
placement="bottom"
2330
delay={1000}
2431
>
25-
<Operator show={showReset} onClick={reset}>
32+
<Operator show={showReset} onClick={onReset}>
2633
<ResetIcon src={`${ICON}/shape/reset.svg`} />
2734
</Operator>
2835
</Tooltip>

src/components/FiltersMenu/index.js renamed to src/components/FiltersMenu/index.tsx

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

77
import React, { useState, useCallback } from 'react'
8-
import T from 'prop-types'
98
import { merge, equals } from 'ramda'
109

10+
import type { TFiltersMenuItems } from '@/spec'
1111
import { buildLog } from '@/utils'
1212

1313
import { SpaceGrow } from '@/components/Common'
@@ -31,15 +31,26 @@ const initActiveMap = (items) => {
3131
return menuMap
3232
}
3333

34-
const FiltersMenu = ({
35-
title,
34+
type TProps = {
35+
title?: string
36+
items?: TFiltersMenuItems
37+
activeid?: string | null
38+
noFilter?: boolean
39+
onItemClick?: () => void
40+
itemBgHighlight?: boolean
41+
revert?: boolean
42+
withDivider?: boolean
43+
}
44+
45+
const FiltersMenu: React.FC<TProps> = ({
46+
title = '',
3647
items,
37-
activeid,
38-
noFilter,
39-
onItemClick,
40-
itemBgHighlight,
41-
revert,
42-
withDivider,
48+
activeid = null,
49+
noFilter = false,
50+
onItemClick = log,
51+
itemBgHighlight = true,
52+
revert = false,
53+
withDivider = true,
4354
}) => {
4455
// const [expandMenuId, setExpandMenuId] = useState(null)
4556
const [expandMenuId, setExpandMenuId] = useState(activeid)
@@ -54,7 +65,7 @@ const FiltersMenu = ({
5465
<Header
5566
title={title}
5667
showReset={!equals(initActiveMap(items), activeMap)}
57-
reset={handleReset}
68+
onReset={handleReset}
5869
/>
5970
{items.map((item, index) => (
6071
<ItemWrapper
@@ -108,37 +119,4 @@ const FiltersMenu = ({
108119
)
109120
}
110121

111-
FiltersMenu.propTypes = {
112-
title: T.string,
113-
items: T.arrayOf(
114-
T.shape({
115-
id: T.string,
116-
title: T.string,
117-
icon: T.string,
118-
options: T.arrayOf(
119-
T.shape({
120-
id: T.string,
121-
title: T.string,
122-
}),
123-
),
124-
}),
125-
).isRequired,
126-
activeid: T.oneOfType([T.string, T.instanceOf(null)]),
127-
noFilter: T.bool,
128-
onItemClick: T.func,
129-
itemBgHighlight: T.bool,
130-
revert: T.bool,
131-
withDivider: T.bool,
132-
}
133-
134-
FiltersMenu.defaultProps = {
135-
title: '',
136-
activeid: null,
137-
noFilter: false,
138-
onItemClick: log,
139-
itemBgHighlight: true,
140-
revert: false,
141-
withDivider: true,
142-
}
143-
144122
export default React.memo(FiltersMenu)

src/components/FiltersMenu/styles/filter/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export const Wrapper = styled.div<{ revert: boolean }>`
1313
padding: 4px 6px;
1414
padding-top: 0;
1515
`
16-
export const RadioWrapper = styled.div<{ revert: boolean }>`
16+
type RadioWrapper = { revert?: boolean }
17+
export const RadioWrapper = styled.div<RadioWrapper>`
1718
${css.flexColumn()};
1819
align-items: ${({ revert }) => (revert ? 'flex-start' : 'flex-end')};
1920
margin-top: 5px;
@@ -38,7 +39,7 @@ export const ActiveDot = styled.div<TActive>`
3839
opacity: ${({ active }) => (active ? 1 : 0)};
3940
transition: opacity 0.25s;
4041
`
41-
type TRadioTitle = TActive & { revert: boolean }
42+
type TRadioTitle = TActive & { revert?: boolean }
4243
export const RadioTitle = styled.div<TRadioTitle>`
4344
font-size: 13px;
4445
color: ${({ active }) =>

src/components/FiltersMenu/styles/header.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import styled from 'styled-components'
22

3-
import type { TTestable, TActive } from '@/spec'
3+
import type { TActive } from '@/spec'
44
import Img from '@/Img'
55
import { css, theme } from '@/utils'
66

7-
export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({
8-
'data-test-id': testid,
9-
}))<TTestable>`
7+
export const Wrapper = styled.div`
108
${css.flex('align-center', 'justify-between')}
119
width: 100%;
1210
margin-bottom: 8px;

src/containers/content/MeetupsContent/ActivityCard.js renamed to src/containers/content/MeetupsContent/ActivityCard.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@ import {
1919
FinishedHole,
2020
} from './styles/activity_card'
2121

22-
const ActivityCard = ({ item }) => {
22+
type TProps = {
23+
item: {
24+
id?: number
25+
date: string
26+
week: string
27+
title: string
28+
company: string
29+
finished?: boolean
30+
type?: string
31+
}
32+
}
33+
34+
const ActivityCard: React.FC<TProps> = ({ item }) => {
2335
return (
2436
<Wrapper finished={item.finished}>
2537
<DatetimeWrapper>
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
import React from 'react'
2-
import T from 'prop-types'
32

4-
import { GALLERY } from '@/constant'
3+
import type { TProps as TParentProps } from './index'
54
import { Wrapper, Divider, WeekName, DateNum } from '../styles/card/date'
65

7-
const Date = ({ type }) => {
6+
type TProps = Omit<TParentProps, 'item'>
7+
8+
const Date: React.FC<TProps> = ({ type }) => {
89
return (
910
<Wrapper type={type}>
1011
<WeekName>周五</WeekName>
1112
<Divider type={type} />
12-
<DateNum>18&nbsp;/&nbsp;04</DateNum>
13+
<DateNum size="small">18&nbsp;/&nbsp;04</DateNum>
1314
</Wrapper>
1415
)
1516
}
1617

17-
Date.propTypes = {
18-
type: T.oneOf([GALLERY.TEXT_ONLY, GALLERY.TEXT_WITH_IMAGE]).isRequired,
19-
}
20-
21-
Date.defaultProps = {}
22-
2318
export default React.memo(Date)

src/containers/content/MeetupsContent/Card/TextCard.js renamed to src/containers/content/MeetupsContent/Card/TextCard.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ICON_CMD } from '@/config'
66
import DotDivider from '@/components/DotDivider'
77
import { Br } from '@/components/Common'
88

9+
import type { TProps as TParentProps } from './index'
910
import Date from './Date'
1011

1112
import {
@@ -19,7 +20,9 @@ import {
1920
Icon,
2021
} from '../styles/card/text_card'
2122

22-
const Card = ({ item }) => {
23+
type TProps = Omit<TParentProps, 'type'>
24+
25+
const TextCard: React.FC<TProps> = ({ item }) => {
2326
return (
2427
<Wrapper>
2528
<Date type={GALLERY.TEXT_ONLY} />
@@ -46,4 +49,4 @@ const Card = ({ item }) => {
4649
)
4750
}
4851

49-
export default React.memo(Card)
52+
export default React.memo(TextCard)

src/containers/content/MeetupsContent/Card/TextWithImgCard.js renamed to src/containers/content/MeetupsContent/Card/TextWithImgCard.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { GALLERY } from '@/constant'
44
import { ICON_CMD, ASSETS_ENDPOINT } from '@/config'
55
import DotDivider from '@/components/DotDivider'
66

7+
import type { TProps as TParentProps } from './index'
78
import Date from './Date'
89

910
import {
@@ -21,7 +22,9 @@ import {
2122
Icon,
2223
} from '../styles/card/text_with_img_card'
2324

24-
const Card = ({ item }) => {
25+
type TProps = Omit<TParentProps, 'type'>
26+
27+
const TextWithImageCard: React.FC<TProps> = ({ item }) => {
2528
return (
2629
<Wrapper>
2730
<ContentsWrapper>
@@ -54,4 +57,4 @@ const Card = ({ item }) => {
5457
)
5558
}
5659

57-
export default React.memo(Card)
60+
export default React.memo(TextWithImageCard)

src/containers/content/MeetupsContent/Card/index.js

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

0 commit comments

Comments
 (0)