Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

refactor(have-a-drink): adjust codebase#1053

Merged
mydearxym merged 2 commits intodevfromadjust-have-a-drink
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ import React from 'react'

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

const About = () => {
const About: React.FC = () => {
return (
<Wrapper>
<Title>关于『来一杯』</Title>
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -128,7 +128,7 @@ const items = [
},
]

const Catalog = () => {
const Catalog: React.FC = () => {
return (
<Wrapper>
{items.map((item) => (
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
import React from 'react'

import type { TSettingOption } from '../spec'

import {
Wrapper,
Divider,
Expand All@@ -11,7 +13,13 @@ import {

import { setSetting } from '../logic'

const Setting = ({ settingOptions: { animateType, fontSize } }) => {
type TProps = {
settingOptions: TSettingOption
}

const Setting: React.FC<TProps> = ({
settingOptions: { animateType, fontSize },
}) => {
return (
<Wrapper>
<Block>
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,19 +9,24 @@ import { AnimateOnChange } from 'react-animation'

import { buildLog } from '@/utils'

import type { TView, TSettingOption } from '../spec'
import Catalog from './Catalog'
import Setting from './Setting'
import About from './About'

import { Wrapper, Sentence, Hint } from '../styles/body'
import {LN } from '../logic'
import {VIEW } from '../constant'

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

const View = ({ view, sentence, settingOptions }) => {
const { VIEW } = LN
type TViewProps = {
view: TView
sentence: string
settingOptions: TSettingOption
}

const View: React.FC<TViewProps> = ({ view, sentence, settingOptions }) => {
const animate = {
fade: {
durationOut: 200,
Expand DownExpand Up@@ -59,10 +64,10 @@ const View = ({ view, sentence, settingOptions }) => {
}
}

const Body = ({ ...restProps }) => {
const Body = (props) => {
return (
<Wrapper>
<View {...restProps} />
<View {...props} />
</Wrapper>
)
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ import {
/* eslint-disable-next-line */
const log = buildLog('C:HaveADrinkContent')

const IndexStatus = () => {
const IndexStatus: React.FC = () => {
return (
<Wrapper>
<Text>共收录</Text>
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,16 +11,15 @@ import { buildLog } from '@/utils'

import DotDivider from '@/components/DotDivider'

import { VIEW } from '../constant'
import { Wrapper, Icon } from '../styles/footer/feature'
import { setView, LN } from '../logic'
import { setView } from '../logic'
// import { useInit } from './logic'

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

const Feature = () => {
const { VIEW } = LN

const Feature: React.FC = () => {
return (
<Wrapper>
<div onClick={() => setView(VIEW.ABOUT)}>
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ import { Wrapper, Icon } from '../styles/footer/share'
/* eslint-disable-next-line */
const log = buildLog('C:HaveADrinkContent')

const Reaction = () => {
const Reaction: React.FC = () => {
return (
<Wrapper>
<Icon src={`${ICON_CMD}/drink_share.svg`} />
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,19 +8,19 @@ import React from 'react'

import { buildLog } from '@/utils'

import type { TView } from '../spec'

import Contributor from './Contributor'
import Feature from './Feature'
import Share from './Share'

import { VIEW } from '../constant'
import { Wrapper } from '../styles/header'
import { LN } from '../logic'

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

const View = ({ view }) => {
const { VIEW } = LN

switch (view) {
case VIEW.DEFAULT: {
return (
Expand All@@ -37,7 +37,11 @@ const View = ({ view }) => {
}
}

const Footer = ({ view }) => {
type TProps = {
view: TView
}

const Footer: React.FC<TProps> = ({ view }) => {
return (
<Wrapper>
<View view={view} />
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ import { setView } from '../logic'
/* eslint-disable-next-line */
const log = buildLog('C:HaveADrinkContent')

const IndexStatus = () => {
const IndexStatus: React.FC = () => {
return (
<Wrapper>
<Text>共&nbsp;</Text>
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ import { Wrapper } from '../styles/header/reaction'
/* eslint-disable-next-line */
const log = buildLog('C:HaveADrinkContent')

const Reaction = () => {
const Reaction: React.FC = () => {
return (
<Wrapper>
<div>评论 | 喜欢</div>
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,24 +5,28 @@
*/

import React from 'react'
import T from 'prop-types'

import { buildLog } from '@/utils'

import type { TInterval } from '../spec'

import { ANIMATE_TIMER_CLASS } from '../constant'
import {
Wrapper,
TopHandlerBar,
PieSpinner,
PieFiller,
Mask,
} from '../styles/header/running_timer'
import { LN } from '../logic'

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

const RunningTimer = ({ interval }) => {
const { ANIMATE_TIMER_CLASS } = LN
type TProps = {
interval?: TInterval
}

const RunningTimer: React.FC<TProps> = ({ interval = '3s' }) => {
return (
<Wrapper>
<TopHandlerBar className={ANIMATE_TIMER_CLASS} />
Expand All@@ -33,12 +37,4 @@ const RunningTimer = ({ interval }) => {
)
}

RunningTimer.propTypes = {
interval: T.oneOf(['3s', '5s', '10s']),
}

RunningTimer.defaultProps = {
interval: '3s',
}

export default React.memo(RunningTimer)
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,8 @@ import { ICON_CMD } from '@/config'
import { buildLog } from '@/utils'

import ExpandIcon from '@/components/ExpandIcon'

import type { TInterval } from '../spec'
import RunningTimer from './RunningTimer'
import {
Wrapper,
Expand DownExpand Up@@ -58,7 +60,12 @@ const SettingPanel = ({ timer, timerInterval }) => {
)
}

const Timer = ({ timer, timerInterval }) => {
type TProps = {
timer: number | null
timerInterval?: TInterval
}

const Timer: React.FC<TProps> = ({ timer, timerInterval = '3s' }) => {
return (
<Wrapper>
<ExpandIcon
Expand All@@ -76,14 +83,4 @@ const Timer = ({ timer, timerInterval }) => {
)
}

Timer.propTypes = {
timer: T.oneOfType([T.number, T.instanceOf(null)]),
timerInterval: T.oneOf(['3s', '5s', '10s']),
}

Timer.defaultProps = {
timer: null,
timerInterval: '3s',
}

export default React.memo(Timer)
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,19 +13,20 @@ import IndexStatus from './IndexStatus'
import Timer from './Timer'
import Reaction from './Reaction'

import { VIEW } from '../constant'
import { Wrapper, GoBackWrapper, BackText, BackIcon } from '../styles/header'
import { setView, LN } from '../logic'
import { setView } from '../logic'

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

const View = ({ view, ...restProps }) => {
const { VIEW } = LN
switch (view) {
case VIEW.DEFAULT: {
return (
<>
<IndexStatus />
{/* @ts-ignore */}
<Timer {...restProps} />
<Reaction />
</>
Expand All@@ -43,10 +44,10 @@ const View = ({ view, ...restProps }) => {
}
}

const Header = ({ ...restProps }) => {
const Header = (props) => {
return (
<Wrapper>
<View {...restProps} />
<View {...props} />
</Wrapper>
)
}
Expand Down
11 changes: 11 additions & 0 deletionssrc/containers/content/HaveADrinkContent/constant.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
// class name of the animate timer components
export const ANIMATE_TIMER_CLASS = 'animate-timer'
export const VIEW = {
DEFAULT: 'default',
CATALOG: 'catalog',
SETTING: 'setting',
ABOUT: 'about',
EDIT: 'edit',
SHARE: 'share',
COMMENT: 'comment',
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@ import dynamic from 'next/dynamic'
import { pluggedIn, buildLog, scrollToTop, lockPage, unlockPage } from '@/utils'
import { useShortcut } from '@/hooks'

import type { TStore } from './store'
import Header from './Header'
import Footer from './Footer'

Expand All@@ -30,7 +31,15 @@ export const Body = dynamic(() => import('./Body'), {
/* eslint-disable-next-line */
const log = buildLog('C:HaveADrinkContent')

const HaveADrinkContentContainer = ({ haveADrinkContent: store }) => {
type TProps = {
haveADrinkContent: TStore
metric: string
}

const HaveADrinkContentContainer: React.FC<TProps> = ({
haveADrinkContent: store,
metric,
}) => {
useInit(store)

useShortcut('Space', () => {
Expand All@@ -44,7 +53,7 @@ const HaveADrinkContentContainer = ({ haveADrinkContent: store }) => {

return (
<Wrapper>
<InnerWrapper>
<InnerWrapper metric={metric}>
<Header
view={view}
timer={timer}
Expand All@@ -62,4 +71,4 @@ const HaveADrinkContentContainer = ({ haveADrinkContent: store }) => {
)
}

export default pluggedIn(HaveADrinkContentContainer)
export default pluggedIn(HaveADrinkContentContainer) as React.FC<TProps>
Loading

[8]ページ先頭

©2009-2025 Movatter.jp