web.components: Text: prop size can be string or number
This commit is contained in:
parent
d3483a2e6b
commit
e9449f6a70
@ -34,7 +34,7 @@ const StyledText = styled(Text)`
|
||||
|
||||
| Props | Type | Required | Values | Default | Description |
|
||||
| ----------------- | :------: | :------: | :----: | :-------: | -------------------------------------------------- |
|
||||
| `fontSize` | `number` | - | - | `13` | Sets the font size |
|
||||
| `fontSize` | `oneOfType(number, string)` | - | - | `13` | Sets the font size |
|
||||
| `as` | `string` | - | - | `p` | Sets the tag through which to render the component |
|
||||
| `title` | `bool` | - | - | - | Title |
|
||||
| `truncate` | `bool` | - | - | `false` | Disables word wrapping |
|
||||
|
@ -4,7 +4,8 @@ import styled, { css } from 'styled-components';
|
||||
import commonTextStyles from './common-text-styles';
|
||||
|
||||
const styleCss = css`
|
||||
font-size: ${props => props.fontSize}px;
|
||||
${props => (typeof (props.fontSize) === 'string' && css`font-size: ${props.fontSize};`) ||
|
||||
(typeof (props.fontSize) === 'number' && css`font-size: ${props.fontSize}px;`)};
|
||||
font-weight: ${props => props.fontWeight
|
||||
? props.fontWeight
|
||||
: props.isBold == true ? 700 : 500};
|
||||
@ -33,7 +34,7 @@ Text.propTypes = {
|
||||
tag: PropTypes.string,
|
||||
title: PropTypes.string,
|
||||
color: PropTypes.string,
|
||||
fontSize: PropTypes.number,
|
||||
fontSize: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
fontWeight: PropTypes.number,
|
||||
backgroundColor: PropTypes.string,
|
||||
truncate: PropTypes.bool,
|
||||
|
Loading…
Reference in New Issue
Block a user