mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-14 19:20:28 +03:00
Localize fonts
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
ed27e6b8e4
commit
3d7e509f9a
43 changed files with 378 additions and 77 deletions
|
|
@ -3,25 +3,37 @@ import PropTypes from 'prop-types';
|
|||
import './Text.scss';
|
||||
|
||||
function Text({
|
||||
id, className, variant, children,
|
||||
className, variant, weight,
|
||||
primary, span, children,
|
||||
}) {
|
||||
const cName = className !== '' ? `${className} ` : '';
|
||||
if (variant === 'h1') return <h1 id={id === '' ? undefined : id} className={`${cName}text text-h1`}>{ children }</h1>;
|
||||
if (variant === 'h2') return <h2 id={id === '' ? undefined : id} className={`${cName}text text-h2`}>{ children }</h2>;
|
||||
if (variant === 's1') return <h4 id={id === '' ? undefined : id} className={`${cName}text text-s1`}>{ children }</h4>;
|
||||
return <p id={id === '' ? undefined : id} className={`${cName}text text-${variant}`}>{ children }</p>;
|
||||
const classes = [];
|
||||
if (className) classes.push(className);
|
||||
|
||||
classes.push(`text text-${variant} text-${weight}`);
|
||||
if (primary) classes.push('text-primary');
|
||||
|
||||
const textClass = classes.join(' ');
|
||||
if (span) return <span className={classes.join(' ')}>{ children }</span>;
|
||||
if (variant === 'h1') return <h1 className={textClass}>{ children }</h1>;
|
||||
if (variant === 'h2') return <h2 className={textClass}>{ children }</h2>;
|
||||
if (variant === 's1') return <h4 className={textClass}>{ children }</h4>;
|
||||
return <p className={textClass}>{ children }</p>;
|
||||
}
|
||||
|
||||
Text.defaultProps = {
|
||||
id: '',
|
||||
className: '',
|
||||
className: null,
|
||||
variant: 'b1',
|
||||
weight: 'normal',
|
||||
primary: false,
|
||||
span: false,
|
||||
};
|
||||
|
||||
Text.propTypes = {
|
||||
id: PropTypes.string,
|
||||
className: PropTypes.string,
|
||||
variant: PropTypes.oneOf(['h1', 'h2', 's1', 'b1', 'b2', 'b3']),
|
||||
weight: PropTypes.oneOf(['light', 'normal', 'medium', 'bold']),
|
||||
primary: PropTypes.bool,
|
||||
span: PropTypes.bool,
|
||||
children: PropTypes.node.isRequired,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue