✨ feat(Table|LoadMore组件): 新增Table和LoadMore组件

This commit is contained in:
xuan
2022-10-13 17:42:10 +08:00
parent 7bf3fedf9c
commit 3199628d4f
10 changed files with 399 additions and 10 deletions
@@ -0,0 +1,9 @@
.loadMore{
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
font-size: 28px;
color: $color_font_three;
padding: 24px 0;
}
+42
View File
@@ -0,0 +1,42 @@
import { View, Text } from '@tarojs/components'
import { FC } from 'react'
import Iconfont from '../iconfont/iconfont'
import LoadingCard from '../loadingCard/index'
import styles from './index.module.scss'
export type LoadMoreStatus = 'more' | 'loading' | 'noMore'
interface LoadMoreEvent {
onClick?: () => void
}
interface LoadMorePropsType extends LoadMoreEvent {
status: LoadMoreStatus
moreText?: string
loadingText?: string
noMoreText?: string
}
const LoadMore: FC<LoadMorePropsType> = props => {
const { status, moreText = '查看更多', loadingText = '加载中', noMoreText = '没有更多', onClick } = props
const handleShowMore = () => {
onClick && onClick()
}
let component: JSX.Element | null = null
if (status === 'loading') {
component = <LoadingCard title={loadingText}></LoadingCard>
} else if (status === 'more') {
component = (
<View onClick={handleShowMore}>
<Text style={{ marginRight: '5px' }}>{moreText}</Text>
<Iconfont name='icon-zhankai' size={32}></Iconfont>
</View>
)
} else {
component = <Text>{noMoreText}</Text>
}
return <View className={styles.loadMore}>{component}</View>
}
export default LoadMore