DocSpace-client/packages/components/heading/index.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

import React from "react";
import PropTypes from "prop-types";
import StyledHeading from "./styled-heading";
2019-07-01 14:05:28 +00:00
2021-04-13 11:07:44 +00:00
const Heading = ({ level, color, className, ...rest }) => {
return (
2021-04-13 11:07:44 +00:00
<StyledHeading
className={`${className} not-selectable`}
as={`h${level}`}
colorProp={color}
{...rest}
></StyledHeading>
);
2019-12-06 09:09:56 +00:00
};
2019-07-01 14:05:28 +00:00
2019-12-06 09:09:56 +00:00
Heading.propTypes = {
/** The heading level. It corresponds to the number after the 'H' for the DOM tag. Set the level for semantic accuracy and accessibility. */
level: PropTypes.oneOf([1, 2, 3, 4, 5, 6]),
/** Specifies the headline color */
color: PropTypes.string,
/** Title */
title: PropTypes.string,
/** Disables word wrapping */
truncate: PropTypes.bool,
/** Sets the 'display: inline-block' property */
isInline: PropTypes.bool,
/** Sets the size of headline */
size: PropTypes.oneOf(["xsmall", "small", "medium", "large", "xlarge"]),
/** Accepts css class */
className: PropTypes.string,
2019-12-06 09:09:56 +00:00
};
2019-07-01 14:05:28 +00:00
2019-12-06 09:09:56 +00:00
Heading.defaultProps = {
title: null,
truncate: false,
isInline: false,
size: "large",
level: 1,
className: "",
2019-12-06 09:09:56 +00:00
};
2019-07-01 14:05:28 +00:00
export default React.memo(Heading);