✨ feat(组件): 新增 iconCard 组件

This commit is contained in:
xuan
2022-09-08 12:05:33 +08:00
parent b7c6c0668f
commit 7b9226b017
7 changed files with 210 additions and 55 deletions
@@ -0,0 +1,6 @@
.iconCard {
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
}
+26
View File
@@ -0,0 +1,26 @@
import { View } from "@tarojs/components"
import { FC, ReactNode } from "react"
import IconFont from "../iconfont"
import styles from './index.module.scss'
type IconfontName = Parameters<typeof IconFont>['0']['name']
interface PropsType {
iconName: IconfontName
title: string
children?: ReactNode
onClick?: Function
}
const IconCard: FC<PropsType> = (props) => {
const { iconName, title, onClick } = props
const handleClick = (event) => {
onClick && onClick(event)
}
return (
<View className={styles.iconCard} onClick={handleClick}>
<IconFont name={iconName} size={72}></IconFont>
<View>{title}</View>
</View>
)
}
export default IconCard
@@ -0,0 +1,16 @@
.layoutBlock {
display: flex;
flex-flow: row nowrap;
background-color: #fff;
padding: 32px;
margin-bottom: 20px;
&--row {
flex-flow: row nowrap;
}
&--col {
flex-flow: column nowrap;
}
&--circle {
border-radius: 20px;
}
}
+29
View File
@@ -0,0 +1,29 @@
import { View } from '@tarojs/components'
import { FC, ReactNode } from 'react'
import classnames from 'classname'
import styles from './index.module.scss'
type FlexDirection = 'row' | 'col'
interface PropsType {
flexDirection?: FlexDirection
circle?: boolean
children?: ReactNode
customStyle?: React.CSSProperties
}
const LayoutBlock: FC<PropsType> = (props) => {
const { flexDirection = 'col', circle = false, children } = props
const getClassName = () => {
const classObject = {
[styles['layoutBlock--circle']]: circle,
[styles[`layoutBlock--${flexDirection}`]]: flexDirection,
}
return classObject
}
return <View className={classnames(styles.layoutBlock, getClassName())}>{children}</View>
}
export default LayoutBlock