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

Commit 85216e6

Browse files
authored
refactor(have-a-drink): adjust codebase (#1053)
* refactor(have-a-drink): adjust content width && convert to ts * refactor(have-a-drink): extract constant file
1 parent bebefa1 commit 85216e6

File tree

19 files changed

+117
-89
lines changed

19 files changed

+117
-89
lines changed

src/containers/content/HaveADrinkContent/Body/About.js renamed to src/containers/content/HaveADrinkContent/Body/About.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import React from 'react'
88

99
import { Wrapper, Title, Body } from '../styles/body/about'
1010

11-
const About = () => {
11+
const About: React.FC = () => {
1212
return (
1313
<Wrapper>
1414
<Title>关于『来一杯』</Title>

src/containers/content/HaveADrinkContent/Body/Catalog.js renamed to src/containers/content/HaveADrinkContent/Body/Catalog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const items = [
128128
},
129129
]
130130

131-
const Catalog = () => {
131+
const Catalog: React.FC = () => {
132132
return (
133133
<Wrapper>
134134
{items.map((item) => (

src/containers/content/HaveADrinkContent/Body/Setting.js renamed to src/containers/content/HaveADrinkContent/Body/Setting.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react'
22

3+
import type { TSettingOption } from '../spec'
4+
35
import {
46
Wrapper,
57
Divider,
@@ -11,7 +13,13 @@ import {
1113

1214
import { setSetting } from '../logic'
1315

14-
const Setting = ({ settingOptions: { animateType, fontSize } }) => {
16+
type TProps = {
17+
settingOptions: TSettingOption
18+
}
19+
20+
const Setting: React.FC<TProps> = ({
21+
settingOptions: { animateType, fontSize },
22+
}) => {
1523
return (
1624
<Wrapper>
1725
<Block>

src/containers/content/HaveADrinkContent/Body/index.js renamed to src/containers/content/HaveADrinkContent/Body/index.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,24 @@ import { AnimateOnChange } from 'react-animation'
99

1010
import { buildLog } from '@/utils'
1111

12+
import type { TView, TSettingOption } from '../spec'
1213
import Catalog from './Catalog'
1314
import Setting from './Setting'
1415
import About from './About'
1516

1617
import { Wrapper, Sentence, Hint } from '../styles/body'
17-
import { LN } from '../logic'
18+
import { VIEW } from '../constant'
1819

1920
/* eslint-disable-next-line */
2021
const log = buildLog('C:HaveADrinkContent')
2122

22-
const View = ({ view, sentence, settingOptions }) => {
23-
const { VIEW } = LN
23+
type TViewProps = {
24+
view: TView
25+
sentence: string
26+
settingOptions: TSettingOption
27+
}
2428

29+
const View: React.FC<TViewProps> = ({ view, sentence, settingOptions }) => {
2530
const animate = {
2631
fade: {
2732
durationOut: 200,
@@ -59,10 +64,10 @@ const View = ({ view, sentence, settingOptions }) => {
5964
}
6065
}
6166

62-
const Body = ({ ...restProps }) => {
67+
const Body = (props) => {
6368
return (
6469
<Wrapper>
65-
<View {...restProps} />
70+
<View {...props} />
6671
</Wrapper>
6772
)
6873
}

src/containers/content/HaveADrinkContent/Footer/Contributor.js renamed to src/containers/content/HaveADrinkContent/Footer/Contributor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
/* eslint-disable-next-line */
2121
const log = buildLog('C:HaveADrinkContent')
2222

23-
const IndexStatus = () => {
23+
const IndexStatus: React.FC = () => {
2424
return (
2525
<Wrapper>
2626
<Text>共收录</Text>

src/containers/content/HaveADrinkContent/Footer/Feature.js renamed to src/containers/content/HaveADrinkContent/Footer/Feature.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ import { buildLog } from '@/utils'
1111

1212
import DotDivider from '@/components/DotDivider'
1313

14+
import { VIEW } from '../constant'
1415
import { Wrapper, Icon } from '../styles/footer/feature'
15-
import { setView, LN } from '../logic'
16+
import { setView } from '../logic'
1617
// import { useInit } from './logic'
1718

1819
/* eslint-disable-next-line */
1920
const log = buildLog('C:HaveADrinkContent')
2021

21-
const Feature = () => {
22-
const { VIEW } = LN
23-
22+
const Feature: React.FC = () => {
2423
return (
2524
<Wrapper>
2625
<div onClick={() => setView(VIEW.ABOUT)}>

src/containers/content/HaveADrinkContent/Footer/Share.js renamed to src/containers/content/HaveADrinkContent/Footer/Share.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Wrapper, Icon } from '../styles/footer/share'
1515
/* eslint-disable-next-line */
1616
const log = buildLog('C:HaveADrinkContent')
1717

18-
const Reaction = () => {
18+
const Reaction: React.FC = () => {
1919
return (
2020
<Wrapper>
2121
<Icon src={`${ICON_CMD}/drink_share.svg`} />

src/containers/content/HaveADrinkContent/Footer/index.js renamed to src/containers/content/HaveADrinkContent/Footer/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import React from 'react'
88

99
import { buildLog } from '@/utils'
1010

11+
import type { TView } from '../spec'
12+
1113
import Contributor from './Contributor'
1214
import Feature from './Feature'
1315
import Share from './Share'
1416

17+
import { VIEW } from '../constant'
1518
import { Wrapper } from '../styles/header'
16-
import { LN } from '../logic'
1719

1820
/* eslint-disable-next-line */
1921
const log = buildLog('C:HaveADrinkContent')
2022

2123
const View = ({ view }) => {
22-
const { VIEW } = LN
23-
2424
switch (view) {
2525
case VIEW.DEFAULT: {
2626
return (
@@ -37,7 +37,11 @@ const View = ({ view }) => {
3737
}
3838
}
3939

40-
const Footer = ({ view }) => {
40+
type TProps = {
41+
view: TView
42+
}
43+
44+
const Footer: React.FC<TProps> = ({ view }) => {
4145
return (
4246
<Wrapper>
4347
<View view={view} />

src/containers/content/HaveADrinkContent/Header/IndexStatus.js renamed to src/containers/content/HaveADrinkContent/Header/IndexStatus.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { setView } from '../logic'
2121
/* eslint-disable-next-line */
2222
const log = buildLog('C:HaveADrinkContent')
2323

24-
const IndexStatus = () => {
24+
const IndexStatus: React.FC = () => {
2525
return (
2626
<Wrapper>
2727
<Text>共&nbsp;</Text>

src/containers/content/HaveADrinkContent/Header/Reaction.js renamed to src/containers/content/HaveADrinkContent/Header/Reaction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Wrapper } from '../styles/header/reaction'
1414
/* eslint-disable-next-line */
1515
const log = buildLog('C:HaveADrinkContent')
1616

17-
const Reaction = () => {
17+
const Reaction: React.FC = () => {
1818
return (
1919
<Wrapper>
2020
<div>评论 | 喜欢</div>

0 commit comments

Comments
 (0)