|
| 1 | +/* |
| 2 | + * Copyright 2020 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/** |
| 18 | + * External dependencies |
| 19 | + */ |
| 20 | +import styled, { css } from 'styled-components'; |
| 21 | +import PropTypes from 'prop-types'; |
| 22 | + |
| 23 | +/** |
| 24 | + * Internal dependencies |
| 25 | + */ |
| 26 | +import { THEME_CONSTANTS } from '../../../theme'; |
| 27 | +import { defaultTypographyStyle } from '../styles'; |
| 28 | + |
| 29 | +export const Display = styled.h1` |
| 30 | + ${defaultTypographyStyle} |
| 31 | + ${({ size, theme }) => |
| 32 | + css` |
| 33 | + font-size: ${theme.typography.presets.display[size].size}px; |
| 34 | + font-weight: ${theme.typography.presets.display[size].weight}; |
| 35 | + line-height: ${theme.typography.presets.display[size].lineHeight}px; |
| 36 | + letter-spacing: ${theme.typography.presets.display[size].letterSpacing}px; |
| 37 | + `} |
| 38 | +`; |
| 39 | + |
| 40 | +Display.propTypes = { |
| 41 | + as: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']).isRequired, |
| 42 | + size: PropTypes.oneOf(THEME_CONSTANTS.DISPLAY_SIZES), |
| 43 | +}; |
| 44 | +Display.defaultProps = { |
| 45 | + size: THEME_CONSTANTS.TYPOGRAPHY_PRESET_SIZES.MEDIUM, |
| 46 | +}; |
0 commit comments