diff --git a/src/components/containers/core/Root/Root.jsx b/src/components/containers/core/Root/Root.jsx index b4411f05..40b519aa 100644 --- a/src/components/containers/core/Root/Root.jsx +++ b/src/components/containers/core/Root/Root.jsx @@ -9,15 +9,42 @@ import React, { Fragment } from "react"; import PropTypes from "prop-types"; +import { createGlobalStyle } from "styled-components"; +import modernNormalize from "styled-modern-normalize"; + +import { global, normalize } from "styles/theme"; + +/* eslint-disable import/extensions */ +import "inter-ui"; +import "typeface-rubik"; +import "typeface-source-code-pro"; +/* eslint-enable import/extensions */ + +/** + * A React component that injects global CSS inline styles in page headers. + * + * @see https://www.styled-components.com/docs/api#createglobalstyle + * @since 0.2.0 + */ +const GlobalStyle = createGlobalStyle` + ${modernNormalize}; + ${global}; + ${normalize}; +`; /** - * The root container. + * The root container with injected global CSS styles. * * @author Arctic Ice Studio * @author Sven Greb * @since 0.1.0 */ -const Root = ({ children }) => {children}; +const Root = ({ children }) => ( + + + {children} + +); Root.propTypes = { children: PropTypes.node.isRequired diff --git a/src/styles/theme/global.js b/src/styles/theme/global.js new file mode 100644 index 00000000..4c753dfd --- /dev/null +++ b/src/styles/theme/global.js @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2018-present Arctic Ice Studio + * Copyright (C) 2018-present Sven Greb + * + * Project: Nord Docs + * Repository: https://github.com/arcticicestudio/nord-docs + * License: MIT + */ + +/** + * @file Global CSS styles. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.2.0 + */ + +import { css } from "styled-components"; + +import typography from "./typography"; + +const global = css` + html { + font-size: ${typography.sizes.root}px; + } + + body { + font-family: ${typography.typefaces.main}; + font-size: ${typography.sizes.msBase}rem; + font-weight: ${typography.sizes.weight}; + line-height: ${typography.sizes.lineHeight}; + scroll-behavior: smooth; + } +`; + +export default global; diff --git a/src/styles/theme/index.js b/src/styles/theme/index.js index 66a80dba..5fd24c97 100644 --- a/src/styles/theme/index.js +++ b/src/styles/theme/index.js @@ -14,10 +14,12 @@ * @since 0.2.0 */ +import global from "./global"; +import normalize from "./normalize"; import typography from "./typography"; const theme = { typography }; -export { typography }; +export { global, normalize, typography }; export default theme; diff --git a/src/styles/theme/normalize.js b/src/styles/theme/normalize.js new file mode 100644 index 00000000..1f660568 --- /dev/null +++ b/src/styles/theme/normalize.js @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2018-present Arctic Ice Studio + * Copyright (C) 2018-present Sven Greb + * + * Project: Nord Docs + * Repository: https://github.com/arcticicestudio/nord-docs + * License: MIT + */ + +/** + * @file Custom normalizations for browser default CSS styles. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.2.0 + */ + +import { css } from "styled-components"; + +const normalize = css` + nav ol, + nav ul { + /* Don't decorate list items. */ + list-style: none; + } + + textarea { + /* Only allow veritcal resizing to prevent layout shifting. */ + resize: vertical; + } +`; + +export default normalize; diff --git a/src/styles/theme/typography.js b/src/styles/theme/typography.js index fdeb1ae4..48af894f 100644 --- a/src/styles/theme/typography.js +++ b/src/styles/theme/typography.js @@ -11,6 +11,7 @@ * @file Typefaces and font styles. * @author Arctic Ice Studio * @author Sven Greb + * @see https://material.io/design/typography/understanding-typography.html * @since 0.2.0 */ @@ -28,9 +29,9 @@ */ const typefaces = { main: "Rubik", + monospace: "Source Code Pro", straight: "Inter UI", - straightVariable: "Inter UI var", - monospace: "Source Code Pro" + straightVariable: "Inter UI var" }; /** @@ -43,8 +44,10 @@ const typefaces = { * @type {object} */ const sizes = { + lineHeight: 1.5, msBase: 1, - msBaseUnit: "em", + msBaseUnit: "rem", + msName: "majorSecond", msRatio: 1.125, root: 16, rootUnit: "px",