-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1679451
commit a318f95
Showing
13 changed files
with
1,117 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
_ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.bigbear-card-wrapper{ | ||
padding:$card-wrapper-padding; | ||
.bigbear-card-img{ | ||
width:100%; | ||
padding:$card-wrapper-padding; | ||
>img{ | ||
width: 100%; | ||
} | ||
} | ||
.bigbear-card-bottom{ | ||
padding:$card-wrapper-padding; | ||
.bigbear-card-btitle{ | ||
font-size: $font-size-lg; | ||
font-weight: $font-weight-bold; | ||
|
||
} | ||
} | ||
.bigbear-card-id{ | ||
display: flex; | ||
justify-content:flex-start; | ||
align-items: center; | ||
.bigbear-card-text{ | ||
flex:1; | ||
margin-left: $card-wrapper-padding *2 ; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { Meta, Story, Props ,Preview } from '@storybook/addon-docs/blocks'; | ||
import Card from './card'; | ||
import Icon from '../Icon'; | ||
import Button from '../Button' | ||
|
||
<Meta title='DISPLAY |Card 卡片' component={ Card }/> | ||
|
||
<br/> | ||
|
||
# Card 卡片 | ||
<br/> | ||
|
||
## 基本使用 | ||
|
||
<Preview> | ||
<Story name='default'> | ||
<Card | ||
img={<img | ||
src='http://n.sinaimg.cn/tech/5_img/upload/598c9e2d/153/w572h381/20200622/af00-ivffpct3576810.jpg'> | ||
</img>} | ||
style={{width:'300px'}} | ||
bottomTitle='日偏食' | ||
bottomDescription='当地时间2020年6月21日,全球多国上演“超级日环食”奇观,这次日环食是本世纪迄今为止最壮观的一次。太阳将有超过99%的面积被月球遮住,只剩下一圈金边,非常罕见,又被称为“金边日食”。' | ||
></Card> | ||
</Story> | ||
</Preview> | ||
|
||
## color&elevate | ||
|
||
<Preview> | ||
<Story name='default2'> | ||
<Card | ||
img={<img | ||
src='http://n.sinaimg.cn/tech/5_img/upload/598c9e2d/153/w572h381/20200622/af00-ivffpct3576810.jpg'> | ||
</img>} | ||
cardType='primary' | ||
elevateCard='wrapper' | ||
|
||
imgType='danger' | ||
bottomType='info' | ||
style={{width:'300px'}} | ||
bottomTitle='日偏食' | ||
bottomDescription='当地时间2020年6月21日,全球多国上演“超级日环食”奇观,这次日环食是本世纪迄今为止最壮观的一次。太阳将有超过99%的面积被月球遮住,只剩下一圈金边,非常罕见,又被称为“金边日食”。' | ||
></Card> | ||
</Story> | ||
</Preview> | ||
|
||
## id | ||
|
||
<Preview> | ||
<Story name='default3'> | ||
<Card | ||
avatarProps={{ | ||
children:<img src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"/>, | ||
round:true | ||
|
||
}} | ||
type='id' | ||
idText={<div > | ||
<div style={{fontWeight:700}}>yehuozhili</div> | ||
<div>bigbear-ui</div> | ||
</div>} | ||
|
||
style={{width:'300px'}} | ||
> | ||
<div style={{display:'flex',alignItem:'center',justifyContent:'space-evenly'}}> | ||
<Button> | ||
<Icon icon='coffee'></Icon> | ||
</Button> | ||
<Button> | ||
<Icon icon='user'></Icon> | ||
</Button> | ||
<Button> | ||
<Icon icon='bookmark'></Icon> | ||
</Button> | ||
</div> | ||
</Card> | ||
</Story> | ||
</Preview> | ||
|
||
|
||
|
||
## 属性详情 | ||
|
||
<Props of={ Card }/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React, { PropsWithChildren, ReactNode, CSSProperties } from "react"; | ||
import classNames from "classnames"; | ||
import Avatar from "../Avatar"; | ||
import { AvatarProps } from "../Avatar/avatar"; | ||
export type normalType = | ||
| "primary" | ||
| "default" | ||
| "danger" | ||
| "secondary" | ||
| "success" | ||
| "info" | ||
| "light" | ||
| "warning" | ||
| "dark"; | ||
|
||
export interface CardProps { | ||
/** 卡片类型结构 */ | ||
type?: "default" | "id"; | ||
/** 是*/ | ||
style?: CSSProperties; | ||
/** 显示的图片 */ | ||
img?: ReactNode; | ||
/** 头像传参,参考avatar组件*/ | ||
avatarProps?: PropsWithChildren<AvatarProps>; | ||
/** 头像旁区域 */ | ||
idText?: ReactNode; | ||
/** 底部标题,也可以通过children自定义 */ | ||
bottomTitle?: ReactNode; | ||
/** 底部描述,也可以通过children自定义 */ | ||
bottomDescription?: ReactNode; | ||
/** 卡片底座颜色 */ | ||
cardType?: normalType; | ||
/** 卡片底座凹凸 */ | ||
elevateCard?: "block" | "wrapper"; | ||
/** 卡片上部颜色 */ | ||
imgType?: normalType; | ||
/** 卡片上部凹凸 */ | ||
elevateImg?: "block" | "wrapper"; | ||
/** 卡片底部颜色 */ | ||
bottomType?: normalType; | ||
/** 卡片底部凹凸 */ | ||
elevateBottom?: "block" | "wrapper"; | ||
/** 外部容器额外类名 */ | ||
className?: string; | ||
} | ||
|
||
function Card(props: PropsWithChildren<CardProps>) { | ||
const { | ||
type, | ||
style, | ||
img, | ||
cardType, | ||
imgType, | ||
className, | ||
bottomType, | ||
elevateCard, | ||
elevateImg, | ||
elevateBottom, | ||
children, | ||
bottomTitle, | ||
bottomDescription, | ||
avatarProps, | ||
idText | ||
} = props; | ||
const wrapperClass = classNames("bigbear-card-wrapper", className, { | ||
[`bigbear-layout-${elevateCard}-${cardType}`]: cardType | ||
}); | ||
const imgClass = classNames("bigbear-card-img", { | ||
[`bigbear-layout-${elevateImg}-${imgType}`]: imgType | ||
}); | ||
const bottomClass = classNames("bigbear-card-bottom", { | ||
[`bigbear-layout-${elevateBottom}-${bottomType}`]: bottomType | ||
}); | ||
return ( | ||
<div className={wrapperClass} style={style}> | ||
<div className={imgClass}> | ||
{type === "default" && img} | ||
|
||
{type === "id" && ( | ||
<div className="bigbear-card-id"> | ||
<Avatar {...avatarProps}></Avatar> | ||
<div className="bigbear-card-text">{idText}</div> | ||
</div> | ||
)} | ||
</div> | ||
<div className={bottomClass}> | ||
<div className="bigbear-card-btitle">{bottomTitle}</div> | ||
<div className="bigbear-card-bsubs">{bottomDescription}</div> | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
Card.defaultProps = { | ||
type: "default", | ||
cardType: "default", | ||
elevateCard: "block", | ||
imgType: "default", | ||
elevateImg: "block", | ||
bottomType: "default", | ||
elevateBottom: "block" | ||
}; | ||
|
||
export default Card; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Card from "./card"; | ||
|
||
export default Card; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.