-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement core atom HTML element component "P"
This commit implements the core atom `P` that represents the text content (1) HTML element `<p>`. It uses adjusted styles instead of browser defaults to match Nord Docs style. References: (1) https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Text_content Associated epic: GH-69 GH-79
- Loading branch information
1 parent
47010b8
commit f86bab6
Showing
9 changed files
with
93 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
src/components/atoms/core/HTMLElements/text-content/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
test/components/atoms/core/HTMLElements/text-content/P.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
test/components/atoms/core/HTMLElements/text-content/__snapshots__/P.test.jsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
`; |