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

Commit 8601664

Browse files
authored
refactor(thread): add basic blog thread && re-org & clean up (#1102)
* chore: basic setup * chore: clean warnings * chore: tmp solve the postsThread ts convert * chore(blog): basic thread setup * chore(posts): clean up unused thread * chore(clean up): remove cheatsheet thread * chore(clean up): remove wiki thread
1 parent 0016cd4 commit 8601664

File tree

96 files changed

+1275
-3055
lines changed

Some content is hidden

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

96 files changed

+1275
-3055
lines changed

config/config.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161
"GITHUB_CPS_TEAM": "https://github.com/orgs/coderplanets/people",
6262
"ISSUE_ADDR": "https://github.com/coderplanets/coderplanets_web/issues",
6363
"MENTION_USER_ADDR": "https://coderplanets.com/users/",
64-
"COMMUNITY_WIKI": "https://github.com/coderplanets/cps_wiki/blob/master",
65-
"COMMUNITY_CHEATSHEET": "https://github.com/coderplanets/cps_cheatsheets/blob/master",
6664
"//--- contact configs ---//": "",
6765
"EMAIL_CLUB": "club@group.coderplanets.com",
6866
"EMAIL_SUPPORT": "support@group.coderplanets.com",

config/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export const {
3131
GITHUB_CPS_TEAM,
3232
ISSUE_ADDR,
3333
MENTION_USER_ADDR,
34-
COMMUNITY_WIKI,
35-
COMMUNITY_CHEATSHEET,
3634
EMAIL_CLUB,
3735
EMAIL_SUPPORT,
3836
EMAIL_HELLO,

server/routes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ router.route('/:community/help-center').get((req, res) => {
124124
return renderAndCache({ req, res, path: '/help-center' })
125125
})
126126

127+
// NOTE: TMP: 博客
128+
router.route('/:community/blogs').get((req, res) => {
129+
return renderAndCache({ req, res, path: '/home/blogs' })
130+
})
131+
127132
// 社区主页
128133
router.route('/:community/:thread').get((req, res) => {
129134
if (

src/components/Buttons/DropdownButton/OptionPanel.js renamed to src/components/Buttons/DropdownButton/OptionPanel.tsx

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import React from 'react'
1+
import { FC, memo } from 'react'
22
import T from 'prop-types'
33

44
import { ICON } from '@/config'
55
import { cutRest } from '@/utils'
6+
import type { TOption } from './index'
67

78
import {
89
Wrapper,
@@ -37,7 +38,13 @@ const LinkBlock = ({ children, link }) => {
3738
)
3839
}
3940

40-
const OptionPanel = ({ options, onClick, panelMinWidth }) => {
41+
type TProps = {
42+
options: TOption[]
43+
panelMinWidth: string
44+
onClick?: (key?: string) => void
45+
}
46+
47+
const OptionPanel: FC<TProps> = ({ options, onClick, panelMinWidth }) => {
4148
return (
4249
<Wrapper panelMinWidth={panelMinWidth}>
4350
{options.map((item, index) => (
@@ -49,7 +56,7 @@ const OptionPanel = ({ options, onClick, panelMinWidth }) => {
4956
{/* common_check icon is special, smaller than normal icons,
5057
and check icon is always the first icon */}
5158
<IconWrapper>
52-
<Icon src={item.icon} index={index} bigger={index === 0} />
59+
<Icon src={item.icon} index={index} />
5360
</IconWrapper>
5461
<Intro>
5562
<Header>
@@ -64,22 +71,4 @@ const OptionPanel = ({ options, onClick, panelMinWidth }) => {
6471
)
6572
}
6673

67-
OptionPanel.propTypes = {
68-
onClick: T.func,
69-
options: T.arrayOf(
70-
T.shape({
71-
title: T.stirng,
72-
desc: T.string,
73-
icon: T.string,
74-
link: T.string,
75-
}),
76-
),
77-
panelMinWidth: T.string.isRequired,
78-
}
79-
80-
OptionPanel.defaultProps = {
81-
options: [],
82-
onClick: console.log,
83-
}
84-
85-
export default React.memo(OptionPanel)
74+
export default memo(OptionPanel)

src/components/Buttons/DropdownButton/index.js

Lines changed: 0 additions & 96 deletions
This file was deleted.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { FC, ReactNode, memo } from 'react'
2+
3+
import { ICON_CMD } from '@/config'
4+
import { buildLog } from '@/utils'
5+
6+
import type { TTooltipPlacement } from '@/spec'
7+
8+
import Tooltip from '@/components/Tooltip'
9+
import OptionPanel from './OptionPanel'
10+
11+
import {
12+
Wrapper,
13+
ButtonWrapper,
14+
DropdownButtonWrapper,
15+
Divider,
16+
MoreIcon,
17+
} from '../styles/dropdown_button'
18+
19+
const log = buildLog('C:PostsThread')
20+
21+
export type TOption = {
22+
title: string
23+
key: string
24+
desc?: string
25+
icon?: string
26+
link?: string
27+
}
28+
29+
type TProps = {
30+
children: ReactNode
31+
options: TOption[]
32+
placement?: TTooltipPlacement
33+
panelMinWidth?: string
34+
onClick: (key?: string) => void
35+
}
36+
37+
// <UpIcon src={`${ICON_CMD}/works/vote_up.svg`} />
38+
const DropdownButton: FC<TProps> = ({
39+
children,
40+
options,
41+
onClick = log,
42+
placement = 'bottom',
43+
panelMinWidth = '100%',
44+
}) => {
45+
return (
46+
<Wrapper>
47+
<ButtonWrapper onClick={onClick}>{children}</ButtonWrapper>
48+
<Tooltip
49+
placement={placement}
50+
trigger="click"
51+
hideOnClick={false}
52+
content={
53+
<OptionPanel
54+
options={options}
55+
onClick={onClick}
56+
panelMinWidth={panelMinWidth}
57+
/>
58+
}
59+
noPadding
60+
>
61+
<DropdownButtonWrapper>
62+
<MoreIcon src={`${ICON_CMD}/works/vote_up.svg`} onClick={onClick} />
63+
</DropdownButtonWrapper>
64+
</Tooltip>
65+
<Divider />
66+
</Wrapper>
67+
)
68+
}
69+
70+
export default memo(DropdownButton)

src/components/PromotionList/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ const log = buildLog('c:PromotionList:index')
2626
type TProps = {
2727
show?: boolean
2828
onAbout?: () => void
29-
items: TItem[]
29+
items?: TItem[]
3030
intervalSec?: number
31+
onClose?: () => void
3132
}
3233

3334
const PromotionList: FC<TProps> = ({

src/components/Switcher/Tabs/LocalIcon.tsx

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import { FC, memo } from 'react'
22
import {
33
TabPostIcon,
4-
TabTechIcon,
54
TabRadarIcon,
6-
TabShareIcon,
75
TabUserIcon,
8-
TabCityIcon,
96
TabJobIcon,
10-
TabWikiIcon,
117
TabRepoIcon,
12-
TabCheatsheetIcon,
138
// user
149
TabLikesIcon,
1510
TabPublishIcon,
@@ -27,21 +22,11 @@ type TProps = {
2722

2823
const TabIcon: FC<TProps> = ({ raw, active, small }) => {
2924
switch (raw) {
30-
case 'tech': {
31-
/* @ts-ignore */
32-
return <TabTechIcon $active={active} $small={small} />
33-
}
34-
3525
case 'radar': {
3626
/* @ts-ignore */
3727
return <TabRadarIcon $active={active} $small={small} />
3828
}
3929

40-
case 'share': {
41-
/* @ts-ignore */
42-
return <TabShareIcon $active={active} $small={small} />
43-
}
44-
4530
case 'user': {
4631
/* @ts-ignore */
4732
return <TabUserIcon $active={active} $small={small} />
@@ -52,26 +37,11 @@ const TabIcon: FC<TProps> = ({ raw, active, small }) => {
5237
return <TabJobIcon $active={active} $small={small} />
5338
}
5439

55-
case 'city': {
56-
/* @ts-ignore */
57-
return <TabCityIcon $active={active} $small={small} />
58-
}
59-
60-
case 'wiki': {
61-
/* @ts-ignore */
62-
return <TabWikiIcon $active={active} $small={small} />
63-
}
64-
6540
case 'repo': {
6641
/* @ts-ignore */
6742
return <TabRepoIcon $active={active} $small={small} />
6843
}
6944

70-
case 'cheatsheet': {
71-
/* @ts-ignore */
72-
return <TabCheatsheetIcon $active={active} $small={small} />
73-
}
74-
7545
case 'favorites': {
7646
/* @ts-ignore */
7747
return <TabFavoritesIcon $active={active} $small={small} />

src/components/Switcher/styles/tabs/local_icon.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ import styled from 'styled-components'
33
// import Img from '@/Img'
44
import { theme, css } from '@/utils'
55
import TabPostSVG from '@/SvgIcons/TabPostSVG'
6-
import TabTechSVG from '@/SvgIcons/TabTechSVG'
76
import TabRadarSVG from '@/SvgIcons/TabRadarSVG'
8-
import TabShareSVG from '@/SvgIcons/TabShareSVG'
97
import TabUserSVG from '@/SvgIcons/TabUserSVG'
10-
import TabCitySVG from '@/SvgIcons/TabCitySVG'
118
import TabJobSVG from '@/SvgIcons/TabJobSVG'
129
//
13-
import TabWikiSVG from '@/SvgIcons/TabWikiSVG'
1410
import TabRepoSVG from '@/SvgIcons/TabRepoSVG'
1511
import TabCheatsheetSVG from '@/SvgIcons/TabCheatsheetSVG'
1612

@@ -40,13 +36,9 @@ const commonIcon = (comp) => {
4036
}
4137

4238
export const TabPostIcon = commonIcon(TabPostSVG)
43-
export const TabTechIcon = commonIcon(TabTechSVG)
4439
export const TabRadarIcon = commonIcon(TabRadarSVG)
45-
export const TabShareIcon = commonIcon(TabShareSVG)
4640
export const TabUserIcon = commonIcon(TabUserSVG)
47-
export const TabCityIcon = commonIcon(TabCitySVG)
4841
export const TabJobIcon = commonIcon(TabJobSVG)
49-
export const TabWikiIcon = commonIcon(TabWikiSVG)
5042
export const TabRepoIcon = commonIcon(TabRepoSVG)
5143
export const TabCheatsheetIcon = commonIcon(TabCheatsheetSVG)
5244

src/components/TabBar/spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { ReactNode } from 'react'
22

33
export type TTabItem = {
4-
title: string
5-
raw: string
4+
title?: string
5+
raw?: string
66
alias?: string
77
icon?: string | ReactNode
88
localIcon?: string

0 commit comments

Comments
 (0)