Skip to content

Commit

Permalink
feat(taro-ui): 增加customStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
cos2004 committed Sep 13, 2018
1 parent 329e5b4 commit c38b0a5
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions @types/avatar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface AtAvatarProps {
openData?: object

className?: string | Array<string>

customStyle?: object | string
}

declare const AtAvatar: ComponentClass<AtAvatarProps>
Expand Down
2 changes: 2 additions & 0 deletions @types/badge.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface AtBadgeProps {
maxValue?: number

className?: string | Array<string>

customStyle?: object | string
}

declare const AtBadge: ComponentClass<AtBadgeProps>
Expand Down
2 changes: 2 additions & 0 deletions @types/button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface AtButtonProps {

className?: string | Array<string>

customStyle?: object | string

onClick?: (event: BaseEventFunction) => void

// start Button props
Expand Down
2 changes: 2 additions & 0 deletions @types/noticebar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface AtNoticeBarProps {

className?: string | Array<string>

customStyle?: object | string

onClose?: (event: BaseEventFunction) => void

onGotoMore?: (event: BaseEventFunction) => void
Expand Down
2 changes: 2 additions & 0 deletions @types/pagination.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface AtPaginationProps {

className?: string | Array<string>

customStyle?: object | string

onPageChange?: (data: {type: 'prev' | 'next', current: number}) => void
}

Expand Down
2 changes: 2 additions & 0 deletions @types/tag.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface AtTagProps {

className?: string | Array<string>

customStyle?: object | string

onClick?: (event: BaseEventFunction) => void
}

Expand Down
2 changes: 2 additions & 0 deletions @types/timeline.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export interface AtTimeLineProps {
items: Array<Item>

className?: string | Array<string>

customStyle?: object | string
}

declare const AtTimeLine: ComponentClass<AtTimeLineProps>
Expand Down
4 changes: 4 additions & 0 deletions src/components/avatar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class AtAvatar extends AtComponent {
image,
text,
openData,
customStyle,
} = this.props
let rootClassName = ['at-avatar']
const sizeClass = SIZE_CLASS[size] || ''
Expand All @@ -52,6 +53,7 @@ export default class AtAvatar extends AtComponent {
return (
<View
className={this.getClassName(rootClassName, this.props.className)}
style={customStyle}
>{elem}</View>
)
}
Expand All @@ -62,11 +64,13 @@ AtAvatar.defaultProps = {
circle: false,
image: '',
openData: {},
customStyle: {},
}

AtAvatar.propTypes = {
size: PropTypes.oneOf(['large', 'normal', 'small']),
circle: PropTypes.bool,
image: PropTypes.string,
openData: PropTypes.object,
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
}
4 changes: 4 additions & 0 deletions src/components/badge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class AtBadge extends AtComponent {
dot,
value,
maxValue,
customStyle,
} = this.props
const rootClassName = ['at-badge']

Expand All @@ -35,6 +36,7 @@ export default class AtBadge extends AtComponent {
return (
<View
className={this.getClassName(rootClassName, this.props.className)}
style={customStyle}
>
{this.props.children}
{dot ? <View className='at-badge__dot'></View> : val !== '' && <View className='at-badge__num'>{val}</View>}
Expand All @@ -47,6 +49,7 @@ AtBadge.defaultProps = {
dot: false,
value: '',
maxValue: 99,
customStyle: {},
}

AtBadge.propTypes = {
Expand All @@ -56,4 +59,5 @@ AtBadge.propTypes = {
PropTypes.number
]),
maxValue: PropTypes.number,
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
}
4 changes: 4 additions & 0 deletions src/components/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class AtButton extends AtComponent {
circle,
loading,
disabled,
customStyle,

formType,
openType,
Expand Down Expand Up @@ -86,6 +87,7 @@ export default class AtButton extends AtComponent {
return (
<View
className={this.getClassName(rootClassName, this.props.className)}
style={customStyle}
onClick={this.onClick.bind(this)}
>
{isWEAPP && !disabled && <Button className='at-button__wxbutton'
Expand Down Expand Up @@ -117,6 +119,7 @@ AtButton.defaultProps = {
circle: false,
loading: false,
disabled: false,
customStyle: {},
onClick: () => {},
// Button props
formType: '',
Expand All @@ -142,6 +145,7 @@ AtButton.propTypes = {
loading: PropTypes.bool,
disabled: PropTypes.bool,
onClick: PropTypes.func,
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),

formType: PropTypes.oneOf(['submit', 'reset']),
openType: PropTypes.oneOf(['contact', 'share', 'getUserInfo', 'getPhoneNumber', 'launchApp', 'openSetting', 'feedback', 'getRealnameAuthInfo']),
Expand Down
4 changes: 4 additions & 0 deletions src/components/noticebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default class AtNoticebar extends AtComponent {
single,
icon,
marquee,
customStyle,
} = this.props
let {
showMore,
Expand Down Expand Up @@ -100,6 +101,7 @@ export default class AtNoticebar extends AtComponent {
this.state.show &&
<View
className={this.getClassName(rootClassName, this.props.className)}
style={customStyle}
>
{close && <View className='at-noticebar__close' onClick={this.onClose.bind(this)}><AtIcon value='close' size='16' color='#ccc'></AtIcon></View>}
<View className='at-noticebar__content'>
Expand All @@ -122,6 +124,7 @@ AtNoticebar.defaultProps = {
moreText: '查看详情',
showMore: false,
icon: '',
customStyle: {},
onClose: () => {},
onGotoMore: () => {},
}
Expand All @@ -134,6 +137,7 @@ AtNoticebar.propTypes = {
moreText: PropTypes.string,
showMore: PropTypes.bool,
icon: PropTypes.string,
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
onClose: PropTypes.func,
onGotoMore: PropTypes.func,
}
4 changes: 4 additions & 0 deletions src/components/pagination/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default class AtPagination extends AtComponent {
const {
icon,
pickerSelect,
customStyle,
} = this.props
const { current, maxPage } = this.state

Expand All @@ -90,6 +91,7 @@ export default class AtPagination extends AtComponent {
return (
<View
className={this.getClassName(rootClassName, this.props.className)}
style={customStyle}
>
<View className='at-pagination__operate'>
<View className='at-pagination__btns'>
Expand Down Expand Up @@ -122,6 +124,7 @@ AtPagination.defaultProps = {
pageSize: 20,
icon: false,
pickerSelect: false,
customStyle: {},
onPageChange: () => {},
}

Expand All @@ -131,5 +134,6 @@ AtPagination.propTypes = {
pageSize: PropTypes.number,
icon: PropTypes.bool,
pickerSelect: PropTypes.bool,
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
onPageChange: PropTypes.func,
}
4 changes: 4 additions & 0 deletions src/components/tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class AtTag extends AtComponent {
circle = false,
disabled = false,
active = false,
customStyle,
} = this.props
let rootClassName = ['at-tag']
const sizeClass = SIZE_CLASS[size] || ''
Expand All @@ -48,6 +49,7 @@ export default class AtTag extends AtComponent {
return (
<View
className={this.getClassName(rootClassName, this.props.className)}
style={customStyle}
onClick={this.onClick.bind(this)}
>
{this.props.children}
Expand All @@ -63,6 +65,7 @@ AtTag.defaultProps = {
circle: false,
active: false,
disabled: false,
customStyle: {},
onClick: () => {},
}

Expand All @@ -73,5 +76,6 @@ AtTag.propTypes = {
circle: PropTypes.bool,
active: PropTypes.bool,
disabled: PropTypes.bool,
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
onClick: PropTypes.func,
}
4 changes: 4 additions & 0 deletions src/components/timeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default class AtTimeline extends AtComponent {
const {
pending,
items,
customStyle,
} = this.props

const rootClassName = ['at-timeline']
Expand Down Expand Up @@ -54,6 +55,7 @@ export default class AtTimeline extends AtComponent {
return (
<View
className={this.getClassName(rootClassName, this.props.className)}
style={customStyle}
>
{itemElems}
</View>
Expand All @@ -64,9 +66,11 @@ export default class AtTimeline extends AtComponent {
AtTimeline.defaultProps = {
pending: false,
items: [],
customStyle: {},
}

AtTimeline.propTypes = {
pending: PropTypes.bool,
items: PropTypes.arrayOf(PropTypes.object),
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
}

0 comments on commit c38b0a5

Please sign in to comment.