web: Common: Refactoring: Changed component according to accepted requirements

This commit is contained in:
Alexey Safronov 2019-12-20 11:38:37 +03:00
parent 7caff56dbb
commit a771f0d7cc
5 changed files with 50 additions and 46 deletions

View File

@ -0,0 +1,31 @@
import React from "react";
import PropTypes from 'prop-types';
import StyledHeading from "./StyledHeadline";
const Headline = (props) => {
//console.log("Headline render");
return (
<StyledHeading
{...props} />
);
};
Headline.propTypes = {
level: PropTypes.oneOf([1, 2, 3, 4, 5, 6]),
children: PropTypes.any,
color: PropTypes.string,
title: PropTypes.string,
truncate: PropTypes.bool,
isInline: PropTypes.bool,
type: PropTypes.oneOf(['menu', 'content']),
};
Headline.defaultProps = {
color: '#333333',
title: '',
truncate: false,
isInline: false,
level: 1
};
export default Headline;

View File

@ -0,0 +1,18 @@
import styled, { css } from 'styled-components';
import { Heading } from 'asc-web-components';
const fontSize = css`
${props =>
(props.type === 'menu' && 27) ||
(props.type === 'content' && 21)
}
`;
const StyledHeading = styled(Heading)`
margin: 0;
line-height: 56px;
font-size: ${fontSize}px;
font-weight: 700;
`;
export default StyledHeading;

View File

@ -1,46 +1 @@
import React from "react";
import PropTypes from 'prop-types';
import styled, { css } from 'styled-components';
import { Heading } from 'asc-web-components';
const fontSize = css`
${props =>
(props.type === 'menu' && 27) ||
(props.type === 'content' && 21)
}
`;
const StyledHeading = styled(Heading)`
margin: 0;
line-height: 56px;
font-size: ${fontSize}px;
font-weight: 700;
`;
const Headline = (props) => {
//console.log("Headline render");
return (
<StyledHeading
{...props} />
);
};
Headline.propTypes = {
level: PropTypes.oneOf([1, 2, 3, 4, 5, 6]),
children: PropTypes.any,
color: PropTypes.string,
title: PropTypes.string,
truncate: PropTypes.bool,
isInline: PropTypes.bool,
type: PropTypes.oneOf(['menu', 'content']),
};
Headline.defaultProps = {
color: '#333333',
title: '',
truncate: false,
isInline: false,
level: 1
};
export default Headline;
export default from "./Headline";