-
-
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.
Initially implement shared theme mode styles and "mixins"
To simplify the usage of common and uniform theme mode styles some have been extracted into a new global `styles/shared` package that allows all components ti import them. There are also some "mixins" (functions) that can be used to customize some dynamic/variable attributes of these styles. GH-129
- Loading branch information
1 parent
f0e148e
commit f2e213a
Showing
6 changed files
with
173 additions
and
49 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
36 changes: 36 additions & 0 deletions
36
src/components/atoms/core/mdx-elements/shared/FigCaption.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,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, themedMode, MODE_BRIGHT_SNOW_FLURRY, MODE_DARK_NIGHT_FROST } from "styles/theme"; | ||
|
||
const figcaptionFontColor = themedMode({ | ||
[MODE_BRIGHT_SNOW_FLURRY]: colors.font.faded[MODE_BRIGHT_SNOW_FLURRY], | ||
[MODE_DARK_NIGHT_FROST]: colors.font.faded[MODE_DARK_NIGHT_FROST] | ||
}); | ||
|
||
/** | ||
* A base HTML component that represents the `<figcaption>` element for a caption or legend describing the rest of the | ||
* contents of its parent `<figure>` element. | ||
* | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.10.0 | ||
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure | ||
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaption | ||
*/ | ||
const FigCaption = styled.figcaption` | ||
color: ${figcaptionFontColor}; | ||
margin-bottom: 6em; | ||
margin-left: 1em; | ||
font-size: 0.875em; | ||
`; | ||
|
||
export default FigCaption; |
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,51 @@ | ||
/* | ||
* 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 shared theme mode shadow color styles for all components. | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.10.0 | ||
*/ | ||
|
||
import { css } from "styled-components"; | ||
import { rgba } from "polished"; | ||
|
||
import { colors, themedMode, MODE_BRIGHT_SNOW_FLURRY, MODE_DARK_NIGHT_FROST } from "styles/theme"; | ||
|
||
const dropShadowColorAmbientLight = themedMode({ | ||
[MODE_BRIGHT_SNOW_FLURRY]: rgba(colors.shadow.base[MODE_BRIGHT_SNOW_FLURRY], 0.1), | ||
[MODE_DARK_NIGHT_FROST]: rgba(colors.shadow.base[MODE_DARK_NIGHT_FROST], 0.1) | ||
}); | ||
|
||
const dropShadowColorDirectLight = themedMode({ | ||
[MODE_BRIGHT_SNOW_FLURRY]: rgba(colors.shadow.base[MODE_BRIGHT_SNOW_FLURRY], 0.25), | ||
[MODE_DARK_NIGHT_FROST]: rgba(colors.shadow.base[MODE_DARK_NIGHT_FROST], 0.25) | ||
}); | ||
|
||
const mixinDropShadowAmbientLight = (offsetX = 0, offsetY = 5, blurRadius = 7) => | ||
css`${offsetX}px ${offsetY}px ${blurRadius}px ${dropShadowColorAmbientLight}`; | ||
|
||
const mixinDropShadowAmbientLightHover = (offsetX = 0, offsetY = 9, blurRadius = 11) => | ||
css`${offsetX}px ${offsetY}px ${blurRadius}px ${dropShadowColorAmbientLight}`; | ||
|
||
const mixinDropShadowDirectLight = (offsetX = 0, offsetY = 4, blurRadius = 6) => | ||
css`${offsetX}px ${offsetY}px ${blurRadius}px ${dropShadowColorDirectLight}`; | ||
|
||
const mixinDropShadowDirectLightHover = (offsetX = 0, offsetY = 8, blurRadius = 10) => | ||
css`${offsetX}px ${offsetY}px ${blurRadius}px ${dropShadowColorDirectLight}`; | ||
|
||
export { | ||
dropShadowColorAmbientLight, | ||
dropShadowColorDirectLight, | ||
mixinDropShadowAmbientLight, | ||
mixinDropShadowAmbientLightHover, | ||
mixinDropShadowDirectLight, | ||
mixinDropShadowDirectLightHover | ||
}; |
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,35 @@ | ||
/* | ||
* 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 shared theme mode styles for all components. | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.10.0 | ||
*/ | ||
|
||
import { transitionThemedModeSwitch } from "./motion/transition"; | ||
import { | ||
dropShadowColorAmbientLight, | ||
dropShadowColorDirectLight, | ||
mixinDropShadowAmbientLight, | ||
mixinDropShadowAmbientLightHover, | ||
mixinDropShadowDirectLight, | ||
mixinDropShadowDirectLightHover | ||
} from "./colors/shadow"; | ||
|
||
export { | ||
dropShadowColorAmbientLight, | ||
dropShadowColorDirectLight, | ||
mixinDropShadowAmbientLight, | ||
mixinDropShadowAmbientLightHover, | ||
mixinDropShadowDirectLight, | ||
mixinDropShadowDirectLightHover, | ||
transitionThemedModeSwitch | ||
}; |
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,23 @@ | ||
/* | ||
* 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 shared theme mode transition styles for all components. | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.10.0 | ||
*/ | ||
|
||
import { motion } from "styles/theme"; | ||
|
||
const transitionThemedModeSwitch = (propName, duration, timingFunction = "ease-in-out") => | ||
`${propName} ${duration > 0 || motion.speed.duration.transition.base.themeModeSwitch}ms ${timingFunction}`; | ||
|
||
/* eslint-disable-next-line import/prefer-default-export */ | ||
export { transitionThemedModeSwitch }; |