Skip to content

Commit

Permalink
Implement base HTML components for the <hr> element
Browse files Browse the repository at this point in the history
The `Hr` component represents a `<hr>` (1) base HTML element to render
a visual thematic break between paragraph-level elements.

References:
  (1) https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr

Associated epic: GH-69
GH-115
  • Loading branch information
arcticicestudio committed Jan 26, 2019
1 parent 63c2261 commit 50f81ab
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/atoms/core/HTMLElements/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

import { A, Code } from "./inline-text-semantics";
import { H1, H2, H3, H4, H5, H6 } from "./sectioning";
import { P, Pre } from "./text";
import { Hr, P, Pre } from "./text";

export { A, Code, H1, H2, H3, H4, H5, H6, P, Pre };
export { A, Code, H1, H2, H3, H4, H5, H6, Hr, P, Pre };
36 changes: 36 additions & 0 deletions src/components/atoms/core/HTMLElements/text/Hr.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]>
* Copyright (C) 2018-present Sven Greb <[email protected]>
*
* Project: Nord Docs
* Repository: https://github.com/arcticicestudio/nord-docs
* License: MIT
*/

import styled from "styled-components";

import { colors, motion, themedMode, MODE_BRIGHT_SNOW_FLURRY, MODE_DARK_NIGHT_FROST } from "styles/theme";

const backgroundColor = themedMode({
[MODE_BRIGHT_SNOW_FLURRY]: colors.nord4,
[MODE_DARK_NIGHT_FROST]: colors.nord2
});

/**
* A base HTML component that represents a visual thematic break between paragraph-level elements.
*
* @author Arctic Ice Studio <[email protected]>
* @author Sven Greb <[email protected]>
* @since 0.7.0
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr
*/
const Hr = styled.hr`
background-color: ${backgroundColor};
border: 0;
height: ${({ size }) => size || 1}px;
margin: ${({ spacing }) => spacing || 5}em auto;
width: ${({ spreadPercent }) => spreadPercent || 35}%;
transition: background-color ${motion.speed.duration.transition.base.themeModeSwitch}ms ease-in-out;
`;

export default Hr;
3 changes: 2 additions & 1 deletion src/components/atoms/core/HTMLElements/text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* @since 0.3.0
*/

import Hr from "./Hr";
import P from "./P";
import Pre from "./Pre";

export { P, Pre };
export { Hr, P, Pre };

0 comments on commit 50f81ab

Please sign in to comment.