This repository was archived by the owner on Nov 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 37 files changed +462
-277
lines changed Expand file tree Collapse file tree 37 files changed +462
-277
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /*
2+ *
3+ * DotDivider
4+ *
5+ */
6+
7+ import React from 'react'
8+
9+ import { buildLog } from '@/utils'
10+ import { Wrapper } from './styles'
11+
12+ /* eslint-disable-next-line */
13+ const log = buildLog ( 'c:DotDivider:index' )
14+
15+ export type TProps = {
16+ className ?: string
17+ radius ?: number
18+ space ?: number
19+ }
20+ const DotDivider : React . FC < TProps > = ( {
21+ radius = 3 ,
22+ space = 3 ,
23+ className = 'dot-divider-class' ,
24+ } ) => {
25+ return < Wrapper radius = { radius } space = { space } className = { className } />
26+ }
27+
28+ export default React . memo ( DotDivider )
Original file line number Diff line number Diff line change 11import styled from 'styled-components'
22import { theme } from '@/utils'
33
4- type TDot = { radius : string ; space : string }
5- export const Wrapper = styled . div < TDot > `
4+ import type { TProps } from '../index'
5+
6+ export const Wrapper = styled . div < TProps > `
67 width: ${ ( { radius } ) => `${ radius } px` } ;
78 height: ${ ( { radius } ) => `${ radius } px` } ;
89 border-radius: 100%;
Original file line number Diff line number Diff line change 55 */
66
77import React from 'react'
8- import T from 'prop-types'
98
109import { buildLog } from '@/utils'
1110
11+ import type { TAvatarProps as TProps } from './index'
1212import { Wrapper , Name } from './styles/avatar'
1313
1414/* eslint-disable-next-line */
1515const log = buildLog ( 'c:ImgFallback:Avatar' )
1616
17- const Avatar = ( {
18- testid,
19- className,
20- size,
21- user,
22- left,
23- right,
24- top,
25- bottom,
26- quote,
17+ const Avatar : React . FC < TProps > = ( {
18+ testid = 'avatar-fallback' ,
19+ className = '' ,
20+ size = 15 ,
21+ user = {
22+ nickname : '?' ,
23+ } ,
24+ left = 0 ,
25+ right = 0 ,
26+ top = 0 ,
27+ bottom = 0 ,
28+ quote = false ,
2729} ) => {
2830 const name = user ?. nickname
2931 const sliceCount = size > 32 ? 2 : 1
@@ -44,32 +46,4 @@ const Avatar = ({
4446 )
4547}
4648
47- Avatar . propTypes = {
48- testid : T . string ,
49- className : T . string ,
50- user : T . shape ( {
51- nickname : T . string ,
52- } ) ,
53- size : T . number ,
54- left : T . number ,
55- right : T . number ,
56- top : T . number ,
57- bottom : T . number ,
58- quote : T . bool ,
59- }
60-
61- Avatar . defaultProps = {
62- testid : 'avatar-fallback' ,
63- className : '' ,
64- size : 15 ,
65- user : {
66- nickname : '?' ,
67- } ,
68- left : 0 ,
69- right : 0 ,
70- top : 0 ,
71- bottom : 0 ,
72- quote : false ,
73- }
74-
7549export default React . memo ( Avatar )
Original file line number Diff line number Diff line change @@ -127,8 +127,12 @@ const rollTheDice = () => {
127127 }
128128}
129129
130- const Work = ( ) => {
131- return < Wrapper > { rollTheDice ( ) } </ Wrapper >
130+ type TProps = {
131+ testid ?: string
132+ }
133+
134+ const Work : React . FC < TProps > = ( { testid = 'image-fallbak-work' } ) => {
135+ return < Wrapper testid = { testid } > { rollTheDice ( ) } </ Wrapper >
132136}
133137
134138export default React . memo ( Work )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /*
2+ *
3+ * ImgFallback
4+ *
5+ */
6+
7+ import React from 'react'
8+
9+ import type { TUser } from '@/spec'
10+ import { buildLog } from '@/utils'
11+
12+ import Work from './Work'
13+ import Avatar from './Avatar'
14+
15+ /* eslint-disable-next-line */
16+ const log = buildLog ( 'c:ImgFallback:index' )
17+
18+ export type TAvatarProps = {
19+ testid ?: string
20+ className ?: string
21+ user ?: TUser
22+ size ?: number
23+ left ?: number
24+ right ?: number
25+ top ?: number
26+ bottom ?: number
27+ quote ?: boolean
28+ }
29+
30+ type TProps = {
31+ type ?: 'avatar' | 'work'
32+ } & TAvatarProps
33+
34+ const ImgFallback : React . FC < TProps > = ( { type = 'avatar' , ...restProps } ) => {
35+ switch ( type ) {
36+ case 'work' : {
37+ return < Work />
38+ }
39+
40+ default :
41+ return < Avatar { ...restProps } />
42+ }
43+ }
44+
45+ export default React . memo ( ImgFallback )
Original file line number Diff line number Diff line change 11import styled from 'styled-components'
22
3- import type { TTestable , TSpace } from '@/spec'
3+ import type { TTestable } from '@/spec'
44import { css , theme } from '@/utils'
5+
6+ import type { TAvatarProps } from '../index'
57import { getFontSize } from './metric/avatar'
68
7- type IWrapper = TSpace & {
8- size : string
9- quote : string
10- }
9+ type TWrapper = TTestable & TAvatarProps
1110
12- export const Wrapper = styled . div . attrs ( ( { testid } : TTestable ) => ( {
11+ export const Wrapper = styled . div . attrs ( ( { testid } : TWrapper ) => ( {
1312 'data-test-id' : testid ,
14- } ) ) < TTestable & IWrapper > `
13+ } ) ) < TWrapper > `
1514 ${ css . flex ( 'align-both' ) } ;
1615 color: ${ theme ( 'thread.articleTitle' ) } ;
1716 width: ${ ( { size } ) => `${ size } px` } ;
Original file line number Diff line number Diff line change 11import React from 'react'
22
3+ import type { TAccount , TComment } from '@/spec'
4+
35import { Wrapper , ReplyAction } from '../styles/comment/actions'
46import { openUpdateEditor , openReplyEditor , onDelete } from '../logic'
57
6- const Actions = ( { data, accountInfo } ) => {
8+ type TProps = {
9+ data : TComment
10+ accountInfo : TAccount
11+ }
12+
13+ const Actions : React . FC < TProps > = ( { data, accountInfo } ) => {
714 if ( String ( data . author . id ) === accountInfo . id ) {
815 return (
916 < Wrapper >
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments