Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base Style & Theme Setup #56

Merged
merged 10 commits into from
Dec 3, 2018

Conversation

arcticicestudio
Copy link
Contributor

Associated epic: #51
Resolves #53

This commit implements global and normalization CSS styles using
"styled-components" `css` API. They extend "modern-normalize" and
define, next to the browser normalization, styles for the available
global themes.

In order to use fonts in "Nord Docs" style & themes (implemented in
GH-54) the basic properties and values have been added and integrated
into these base styles.

To inject global styles, styled-components v4 `createglobalstyle` (1)
API has been used to create a `<GlobalStyle>` component that injects
theme styles and "styled-modern-normalize" (2) globally.

References:
  (1) https://www.styled-components.com/docs/api#createglobalstyle
  (2): https://github.com/arcticicestudio/styled-modern-normalize

Associated epics: GH-51, GH-2
GH-53
To provide the global theme (1), the `ThemeProvider` (2) component has
been implemented into the `Root` core container component (3). The
global theme, placed in `src/styles/themes` is passed to the provider to
make the theme globally available.

References:
  (1) https://www.styled-components.com/docs/advanced#theming
  (2) https://www.styled-components.com/docs/api#themeprovider
  (3) #36

Associated epics: GH-51
GH-53
Jest uses a object called `global` that proxies the `window` object.
This conflicts with the `global` object of Nord Docs theme.
This commit renames the object to `globals`.

GH-53
Instead of using the default entry point of the pakages defined in the
`main` field the CSS modules should be imported directly. This fixes the
imports for tests with Jest that are then handled with the implemented
mock for file imports. It improves the DX by showing that these packages
are CSS styles instead of a JS module and removes the need to add
exception/ignore comments for ESLint. The only disadvantage it that it
might be necessary to update the import when the package maintainer
changes the `main` file when updating to a newer version.

GH-53
Initially Nord Docs will be build with the "bright snow flurry" and
"dark night frost" theme modes representing Nord "auras". The names
have been implemented as constants to be used with the theme utility
functions to define the styles of a component for each available global
theme.

GH-53
To simplify the usage of styled-theming's `theme()` (1) and
`theme.variants()` API functions, two utility functions has been
implemented:

- `themeMode(modeStyles : object)` — Shorthand function for the `theme`
  API to define styles based on the global theme mode(s).
- `themedModeVariant(modeStyles : object, variantPropName : string)` —
  Shorthand function for the `theme.variants` API to define variant
  styles based on the global theme mode(s).

References:
  (1) https://github.com/styled-components/styled-theming#themename-values

GH-53
Since the main JavaScript implementation of Nord (1) is currently not
completed and released yet, the colors and palettes will be provided
"manually" via new `nord` and `palettes` modules. As soon as the
implementation has been done they will be replaced through imports from
the official package.

References:
  (1) nordtheme/nord#36

GH-53
This commit implements some basic configurations for motion related
styles like animations inspired by "Material Designs" (1) great
documentations and guidelines about motion speed (2). This includes
values for speed like transition durations. It'll be used to set the
CSS transition for the base background and font color within the
`globals` CSS style module.

References:
  (1) https://material.io
  (2) https://material.io/design/motion/speed.html

GH-53
@codecov
Copy link

codecov bot commented Dec 3, 2018

Codecov Report

Merging #56 into develop will increase coverage by 47.22%.
The diff coverage is 88.88%.

Impacted file tree graph

@@             Coverage Diff              @@
##           develop      #56       +/-   ##
============================================
+ Coverage    44.44%   91.66%   +47.22%     
============================================
  Files            4       14       +10     
  Lines            9       24       +15     
  Branches         0        1        +1     
============================================
+ Hits             4       22       +18     
+ Misses           5        2        -3
Flag Coverage Δ
#unit 91.66% <88.88%> (+47.22%) ⬆️
Impacted Files Coverage Δ
src/styles/theme/typography.js 100% <ø> (+100%) ⬆️
src/styles/theme/utils/themedMode.js 0% <0%> (ø)
src/styles/theme/colors/palettes.js 100% <100%> (ø)
src/styles/theme/motion/speed.js 100% <100%> (ø)
src/styles/theme/motion/index.js 100% <100%> (ø)
src/styles/theme/globals.js 100% <100%> (ø)
src/styles/theme/normalize.js 100% <100%> (ø)
src/components/containers/core/Root/Root.jsx 100% <100%> (ø) ⬆️
src/styles/theme/colors/index.js 100% <100%> (ø)
src/styles/theme/colors/nord.js 100% <100%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81a5b23...c0e5f6f. Read the comment docs.

@arcticicestudio arcticicestudio merged commit 85498ca into develop Dec 3, 2018
@arcticicestudio arcticicestudio deleted the feature/gh-53-base-style-and-theme-setup branch December 3, 2018 13:39
@arcticicestudio arcticicestudio removed their assignment Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants