From bb001148a5ebfb0bffe3566060027289ebb0cedd Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 1 Oct 2021 16:35:14 +0200 Subject: [PATCH] Updated text Signed-off-by: Avior --- src/dzeio/Text/Text.module.styl | 6 +++++- src/dzeio/Text/index.tsx | 22 ++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/dzeio/Text/Text.module.styl b/src/dzeio/Text/Text.module.styl index 179bd69..3e21cba 100644 --- a/src/dzeio/Text/Text.module.styl +++ b/src/dzeio/Text/Text.module.styl @@ -1,3 +1,5 @@ +@import "../config" + .text margin 0 font-size rem(16) @@ -16,9 +18,11 @@ for size in 36 28 24 20 18 16 14 .size-{size} font-size rem(size) -for weight in 'normal' 'bold' 'light' +for weight in 'normal' 'bold' .weight-{weight} font-weight unquote(weight) +.weight-light + font-weight 300 .align-center text-align center diff --git a/src/dzeio/Text/index.tsx b/src/dzeio/Text/index.tsx index d2fb0d5..68e7e65 100644 --- a/src/dzeio/Text/index.tsx +++ b/src/dzeio/Text/index.tsx @@ -27,19 +27,23 @@ const types: Record { public render() { - let data: { weight: Props['weight'], size: Props['size'] } = Object.assign({ + let data: { weight: Props['weight'], size: Props['size'], tag?: Props['tag'] } = Object.assign({ size: 16, weight: 'normal' }, this.props.type ? types[this.props.type] : {}) + if (this.props.size) { + data.size = this.props.size + } + if (this.props.weight) { + data.weight = this.props.weight + } const classes = buildClassName( css.text, [css[`weight-${data.weight}`], data.weight !== 'normal'], @@ -73,6 +83,6 @@ export default class Text extends React.PureComponent { return (

{this.props.children}

) } - return React.createElement(this.props.tag || 'p', {className: classes, children: this.props.children}) + return React.createElement(this.props.tag ?? data.tag ?? 'p', {className: classes, children: this.props.children}) } }