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 #53

Closed
9 tasks done
arcticicestudio opened this issue Dec 1, 2018 · 0 comments
Closed
9 tasks done

Base Style & Theme Setup #53

arcticicestudio opened this issue Dec 1, 2018 · 0 comments

Comments

@arcticicestudio
Copy link
Contributor

arcticicestudio commented Dec 1, 2018

Associated epic: #51
Depends on #54

To start implementing components the basic styles must be set up. As documented in #51, Nord Docs will uses the CSS-in-JS library styled-components. To use uniform global theme definitions and to simplify CSS styling, the styled-theming and polished libraries will be integrated next to some useful and required specific Babel & Gatsby plugins.

Default Browser Style Normalization

The modern-normalize is a great project that normalizes the browsers default styles for a consistent appearance across different modern browsers. For the best usage with styled-components the npm-styled-modern-normalize project will be used. It exports the styles via the css API and will be added to the created global styles component mentioned above.

CSS Tools

To simplify the CSS styling, the polished package will be used that provides a lightweight toolset for writing styles in JavaScript (CSS-in-JS).

CSS Base Styles

Global and normalization CSS styles will be implemented using styled-components css API. They extend modern-normalize and define, next to the browser normalization, styles of the available global themes like documented in the sections below.

In order to use fonts in Nord Docs style & themes (implemented in #54) the basic properties and values must be added and integrated into this CSS base styles.

Global Styles

To inject global styles, styled-components v4 createglobalstyle API will be used to create a <GlobalStyle> component that can then be used to inject various styles globally.

Global Themes

To provide the global theme, the ThemeProvider component will be added to the Nord Docs Root core container component. The global theme, placed in src/styles/themes will then be passed to the provider.

Simplified Theme Usage

To simplify the usage of styled-theming's theme() and theme.variants() API functions, two utility functions will be 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).

Available Themes

Initially Nord Docs will be build with the “bright snow flurry” and “dark night frost” theme modes. The names will be implemented as constants with values BRIGHT_SNOW_FLURRY and DARK_NIGHT_FROST to be used with the utility functions mentioned above to define the styles of a component for each available global theme.

Plugins

styled-components great Babel plugin adds support for server-side rendering, minification of styles, and a nicer debugging experience. It will be integrated via the corresponding Gatsby's plugin.

Nord Colors

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

Motion

Some basic configurations for motion related styles like animations will be implemented inspired by Material Designs great documentation and guide about motion speed. 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.

Tasks

  • Install all (dev) dependencies:
  • Setup styled-components Babel plugin via the corresponding Gatsby plugin.
  • Implement CSS global and normalization styles with styled-components css API.
  • Implement the <GlobalStyle> component to inject styled-modern-normalize and CSS base styles.
  • Add ThemeProvider component to Root core container.
  • Implement the themeMode and themeModeVariants theme utility functions.
  • Create constants for the BRIGHT_SNOW_FLURRY and DARK_NIGHT_FROST theme modes.
  • Implement temporary nord and palettes modules.
  • Implement basic configurations for motion related styles like animations.
@arcticicestudio arcticicestudio added this to the 0.2.0 milestone Dec 1, 2018
@arcticicestudio arcticicestudio self-assigned this Dec 1, 2018
This was referenced Dec 1, 2018
arcticicestudio added a commit that referenced this issue Dec 2, 2018
In order to use the fonts is must be added to Nord Docs theme. This
commit implements the `typography` module that defines all used font
families and the basic typography properties and values like the font
size and units based on the used modular scale documented in GH-2.

Associated epic: GH-2
Dependency of GH-53
GH-54
arcticicestudio added a commit that referenced this issue Dec 2, 2018
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
arcticicestudio added a commit that referenced this issue Dec 2, 2018
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
arcticicestudio added a commit that referenced this issue Dec 3, 2018
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
arcticicestudio added a commit that referenced this issue Dec 3, 2018
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
arcticicestudio added a commit that referenced this issue Dec 3, 2018
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
arcticicestudio added a commit that referenced this issue Dec 3, 2018
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
arcticicestudio added a commit that referenced this issue Dec 3, 2018
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
arcticicestudio added a commit that referenced this issue Dec 3, 2018
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
arcticicestudio added a commit that referenced this issue Dec 3, 2018
…and-theme-setup

Base Style & Theme Setup
@arcticicestudio arcticicestudio mentioned this issue Dec 3, 2018
3 tasks
arcticicestudio added a commit that referenced this issue Dec 4, 2018
The `Root` component has been changed from a SFC to a class component to
store the currently active state and handle the theme mode toggle logic
through a function. It also migrated the currently used simple
"styled-component" theme (1) (provided through the `<ThemeProvider`
component) to the styled-theming theme (2) that provides the initially
implemented theme (GH-53).

References:
  (1) https://www.styled-components.com/docs/advanced#theming
  (2) https://github.com/styled-components/styled-theming

Associated epic: GH-51
GH-57
arcticicestudio added a commit that referenced this issue Dec 4, 2018
They will be initially used in the global theme styles implemented
in GH-53.

Associated epic: GH-51
GH-59
@arcticicestudio arcticicestudio removed their assignment Dec 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant