Skip to content

Commit

Permalink
Merge pull request #80 from arcticicestudio/feature/gh-79-core-atom-h…
Browse files Browse the repository at this point in the history
…tml-element-p

Core Atom HTML Element: P
  • Loading branch information
arcticicestudio authored Dec 16, 2018
2 parents 47010b8 + f86bab6 commit ad995b0
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/components/atoms/core/HTMLElements/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @since 0.3.0
*/

import { A } from "./inlineTextSemantics";
import { A } from "./inline-text-semantics";
import { P } from "./text-content";

/* eslint-disable-next-line import/prefer-default-export */
export { A };
export { A, P };
25 changes: 25 additions & 0 deletions src/components/atoms/core/HTMLElements/text-content/P.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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";

/**
* A base HTML component that represents a paragraph.
*
* @author Arctic Ice Studio <[email protected]>
* @author Sven Greb <[email protected]>
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p
* @since 0.3.0
*/
const P = styled.p`
margin-top: 0;
margin-bottom: 1em;
`;

export default P;
21 changes: 21 additions & 0 deletions src/components/atoms/core/HTMLElements/text-content/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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
*/

/**
* @file Provides components that represent basic HTML elements with text content functionality.
* @author Arctic Ice Studio <[email protected]>
* @author Sven Greb <[email protected]>
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Text_content
* @since 0.3.0
*/

import P from "./P";

/* eslint-disable-next-line import/prefer-default-export */
export { P };
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { A } from "atoms/core/HTMLElements";
import { ROUTE_DOCS } from "config/routes/mappings";
import { metadataNordDocs } from "data/project";

describe("snapshot", () => {
describe("logical behavior", () => {
test("renders inernal URLs with `to` prop", () => {
const { container } = render(<A to={ROUTE_DOCS}>Docs</A>);
expect(container.firstChild).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`snapshot renders external URLs with \`href\` prop 1`] = `
exports[`logical behavior renders external URLs with \`href\` prop 1`] = `
.c0 {
color: inherit;
cursor: pointer;
Expand All @@ -23,7 +23,7 @@ exports[`snapshot renders external URLs with \`href\` prop 1`] = `
</a>
`;

exports[`snapshot renders external URLs with \`to\` prop 1`] = `
exports[`logical behavior renders external URLs with \`to\` prop 1`] = `
.c0 {
color: inherit;
cursor: pointer;
Expand All @@ -46,7 +46,7 @@ exports[`snapshot renders external URLs with \`to\` prop 1`] = `
</a>
`;

exports[`snapshot renders inernal URLs with \`href\` prop 1`] = `
exports[`logical behavior renders inernal URLs with \`href\` prop 1`] = `
.c0 {
color: inherit;
cursor: pointer;
Expand All @@ -69,7 +69,7 @@ exports[`snapshot renders inernal URLs with \`href\` prop 1`] = `
</a>
`;

exports[`snapshot renders inernal URLs with \`to\` prop 1`] = `
exports[`logical behavior renders inernal URLs with \`to\` prop 1`] = `
.c0 {
color: inherit;
cursor: pointer;
Expand Down
25 changes: 25 additions & 0 deletions test/components/atoms/core/HTMLElements/text-content/P.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 React from "react";

import { renderWithTheme } from "nord-docs-test-utils";
import { P } from "atoms/core/HTMLElements";

describe("theme styles", () => {
test("matches the snapshot", () => {
const { container } = renderWithTheme(<P>Nord</P>);
expect(container.firstChild).toMatchSnapshot();
});

test("has no top margin", () => {
const { container } = renderWithTheme(<P>Nord</P>);
expect(container.firstChild).toHaveStyleRule("margin-top", "0");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`theme styles matches the snapshot 1`] = `
.c0 {
margin-top: 0;
margin-bottom: 1em;
}
<p
class="c0"
>
Nord
</p>
`;

0 comments on commit ad995b0

Please sign in to comment.