-
-
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.
Implemented base HTML components for
<pre>
and <code>
elements
The `Code` component represents a `<code>` base HTML element to render short fragments of computer code. It is related o and commonly used with the `Pre` component that represents the `<pre>` element to render preformatted text using a non-proportional "monspace" font. GH-112
- Loading branch information
1 parent
bbb96fe
commit 2c8b0f0
Showing
5 changed files
with
90 additions
and
7 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
46 changes: 46 additions & 0 deletions
46
src/components/atoms/core/HTMLElements/inline-text-semantics/Code.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,46 @@ | ||
/* | ||
* 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, typography, MODE_BRIGHT_SNOW_FLURRY, MODE_DARK_NIGHT_FROST } from "styles/theme"; | ||
|
||
import { Pre } from "../text"; | ||
|
||
const backgroundColor = themedMode({ | ||
[MODE_BRIGHT_SNOW_FLURRY]: colors.nord6, | ||
[MODE_DARK_NIGHT_FROST]: colors.nord1 | ||
}); | ||
|
||
/** | ||
* A base HTML component that represents the `<code>` element to render short fragments of computer code. | ||
* The actual text is rendered as base HTML element `<pre>` that is represented through the `Pre` component. | ||
* | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.6.0 | ||
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre | ||
*/ | ||
const Code = styled.code` | ||
font-family: ${typography.typefaces.monospace}; | ||
font-weight: 500; | ||
font-size: 0.85em; | ||
padding: 0.2em 0.4em; | ||
background-color: ${backgroundColor}; | ||
border-radius: 4px; | ||
transition: background-color ${motion.speed.duration.transition.base.themeModeSwitch}ms ease-in-out; | ||
${Pre} & { | ||
margin-bottom: 1em; | ||
display: block; | ||
padding: 1em; | ||
} | ||
`; | ||
|
||
export default Code; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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.nord6, | ||
[MODE_DARK_NIGHT_FROST]: colors.nord1 | ||
}); | ||
|
||
/** | ||
* A base HTML component that represents the `<pre>` element to render preformatted text using a non-proportional | ||
* "monspace" font. | ||
* It is related to and commonly used with a `<code>` element that is represented by the `Code` component. | ||
* | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.6.0 | ||
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code | ||
*/ | ||
const Pre = styled.pre` | ||
background-color: ${backgroundColor}; | ||
overflow: auto; | ||
white-space: pre; | ||
border-radius: 4px; | ||
transition: background-color ${motion.speed.duration.transition.base.themeModeSwitch}ms ease-in-out; | ||
`; | ||
|
||
export default Pre; |
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