From 8c141a1a62e106b2f3735f844f3ffec3ff4b921b Mon Sep 17 00:00:00 2001
From: Tobias
Date: Thu, 24 Jan 2019 21:38:26 +0100
Subject: [PATCH] feat: larger enhancement of how styles behave and are
structured. Have a look at the CSS structure diagram.
---
.../gatsby-browser.js | 1 +
.../src/pages/uilib/typography.md | 8 +-
.../uilib/typography/TypographyExamples.js | 2 +-
.../pages/uilib/typography/font-weights.md | 25 +-
...e_diagram.svg => css_structure_diagram.js} | 227 +++++++++++---
.../usage/customisation/event-handling.md | 17 +-
.../examples/properties-example.js | 2 +-
.../uilib/usage/customisation/styling.md | 33 +-
.../uilib/usage/customisation/theming.md | 2 +-
.../first-steps/examples/react-examples.js | 18 --
.../pages/uilib/usage/first-steps/react.md | 68 ++---
.../uilib/usage/first-steps/the-basics.md | 14 +-
.../src/shared/inlineTags/CodeBlock.js | 24 +-
.../src/shared/inlineTags/ComponentBox.js | 6 +-
.../src/shared/menu/SidebarMenu.js | 7 +-
.../src/shared/menu/StickyMenuBar.js | 2 +-
.../src/shared/parts/PortalStyle.js | 6 +-
.../__snapshots__/Button.test.js.snap | 3 +-
.../__snapshots__/Dropdown.test.js.snap | 3 +-
.../__tests__/__snapshots__/Icon.test.js.snap | 3 +-
.../src/components/icon/style/_icon.scss | 1 +
.../__snapshots__/InputMasked.test.js.snap | 3 +-
.../__snapshots__/Input.test.js.snap | 3 +-
.../__snapshots__/Modal.test.js.snap | 3 +-
.../src/style/components/imports.scss | 2 +-
.../dnb-ui-lib/src/style/core/dnb-core.scss | 4 +-
.../dnb-ui-lib/src/style/core/dnb-style.scss | 285 ------------------
.../core/{typography.scss => fonts.scss} | 0
.../src/style/{core => themes}/anchor.scss | 4 +-
.../src/style/themes/dnb-style.scss | 190 ++++++++++++
.../style/themes/dnb-theme-open-banking.scss | 7 +-
.../src/style/themes/dnb-theme-ui.scss | 105 ++++++-
.../dnb-ui-lib/src/style/themes/imports.scss | 5 +-
.../dnb-ui-lib/stories/componentExamples.js | 14 +-
34 files changed, 645 insertions(+), 452 deletions(-)
rename packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/{css_structure_diagram.svg => css_structure_diagram.js} (65%)
delete mode 100644 packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/examples/react-examples.js
delete mode 100644 packages/dnb-ui-lib/src/style/core/dnb-style.scss
rename packages/dnb-ui-lib/src/style/core/{typography.scss => fonts.scss} (100%)
rename packages/dnb-ui-lib/src/style/{core => themes}/anchor.scss (98%)
create mode 100644 packages/dnb-ui-lib/src/style/themes/dnb-style.scss
diff --git a/packages/dnb-design-system-portal/gatsby-browser.js b/packages/dnb-design-system-portal/gatsby-browser.js
index eab2fc1b56b..7db7663910f 100644
--- a/packages/dnb-design-system-portal/gatsby-browser.js
+++ b/packages/dnb-design-system-portal/gatsby-browser.js
@@ -7,6 +7,7 @@
if (process.env.NODE_ENV === 'development') {
require('dnb-ui-lib/src/style/patterns') // import ony patterns
require('dnb-ui-lib/src/style/components') // import ony components
+ // require('dnb-ui-lib/src/style/themes/open-banking') // import the "open-banking" theme
require('dnb-ui-lib/src/style/themes/ui') // import the default theme
} else {
// As the gatsby-plugin-postcss plugin dont processes the scss file in the package "dnb-ui-lib" - we have to use the preprocessed version
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/typography.md b/packages/dnb-design-system-portal/src/pages/uilib/typography.md
index 8db321afde8..e046b872c20 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/typography.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/typography.md
@@ -9,10 +9,10 @@ order: 4
## Font Face
-Our default font is `Fedra Sans Book`. This font, together with its siblings is loaded and imported with `@font-face` in `/css/core/typography.scss`. The font is included in the library package.
-To make sure we don't load all of the font faces at once, we apply the font weights and font styles by using its predefined font faces.
+The DNB default Font Family is `Fedra Sans Std`. This font, together with its weights is loaded and imported with `@font-face` in `/css/core/fonts.scss`. The font is included in the library package.
+To make sure You don't load all of the font faces at once, You apply a font `weights` to load the predefined font faces.
-Read more about [fonts at DNB](/quickguide-designer/fonts/)
+Read more how to use the [different weights](/uilib/typography/font-weights/).
### Headings
@@ -37,3 +37,5 @@ Read more about [fonts at DNB](/quickguide-designer/fonts/)
written in 45 BC.
+
+Or read more [about fonts in the Designer Guides](/quickguide-designer/fonts/).
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/typography/TypographyExamples.js b/packages/dnb-design-system-portal/src/pages/uilib/typography/TypographyExamples.js
index f6f2ee3d6ad..a3dfbd5b06f 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/typography/TypographyExamples.js
+++ b/packages/dnb-design-system-portal/src/pages/uilib/typography/TypographyExamples.js
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types'
import styled from '@emotion/styled'
const Wrapper = styled.div`
- padding: 3rem 0 0;
+ margin-bottom: 3rem;
`
const FontUsageExample = ({ typo_class, font_family }) => (
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/typography/font-weights.md b/packages/dnb-design-system-portal/src/pages/uilib/typography/font-weights.md
index 9f1173d1941..e2991311e24 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/typography/font-weights.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/typography/font-weights.md
@@ -10,9 +10,28 @@ import TypographyExamples from 'Pages/uilib/typography/TypographyExamples'
### For now we have 3 Font Weights:
-- Book
-- Demi
-- Medium
+- Book (normal)
+- Demi (500)
+- Medium (600)
+
+### How to use the Weights
+
+```css
+/* I am Book */
+p {
+ font-weight: normal;
+}
+
+/* I am Demi */
+p {
+ font-weight: var(--font-weight-demi); /* 500 */
+}
+
+/* I am Medium */
+p {
+ font-weight: var(--font-weight-medium); /* 600 */
+}
+```
## Examples
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/css_structure_diagram.svg b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/css_structure_diagram.js
similarity index 65%
rename from packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/css_structure_diagram.svg
rename to packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/css_structure_diagram.js
index e26678f4f92..f4bcd852483 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/css_structure_diagram.svg
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/css_structure_diagram.js
@@ -1,45 +1,182 @@
-
+import React from 'react'
+
+export default props => (
+
+)
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/event-handling.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/event-handling.md
index 3ca7586035c..d2177f21628 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/event-handling.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/event-handling.md
@@ -4,6 +4,8 @@ draft: false
order: 4
---
+import ComponentBox from 'Tags/ComponentBox'
+
# Event Handling
The [dnb-ui-lib](/uilib/) offers a couple of different ways to handling events:
@@ -13,7 +15,7 @@ The [dnb-ui-lib](/uilib/) offers a couple of different ways to handling events:
Have a look at the following basic examples:
-The `dnb-ui-lib` uses _snake case_ (**snake_case**) to define the event name property (e.g. `on_click` or `on_change`).
+The `dnb-ui-lib` uses _snake case_ (**snake_case**) to define the event name property (e.g. `on_click` or `on_change`). Read more about the [naming conventions](uilib/development/naming).
## React
@@ -21,13 +23,12 @@ Some of the most basic event handling in React.
### Stateless Component
-```jsx
-import { Button } from 'dnb-ui-lib'
-const myHandler = event => {}
-const MyComponent = () => (
-
-)
-```
+
+{`
+const myHandler = () => alert('Hello')
+render()
+`}
+
### Lifecycle Component
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/examples/properties-example.js b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/examples/properties-example.js
index 342af2db15b..34503526171 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/examples/properties-example.js
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/examples/properties-example.js
@@ -36,7 +36,7 @@ export default class MyClass extends PureComponent {
{children}
- Web Component Property updating
+ Web Component property updates
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/styling.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/styling.md
index 4b134bc8215..dc41dfa67db 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/styling.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/styling.md
@@ -1,36 +1,51 @@
---
title: 'Styling'
-status: 'imp'
draft: false
order: 1
---
import Img from 'Tags/Img'
-import CSSDiagram from 'Pages/uilib/usage/customisation/assets/css_structure_diagram.svg'
+import { Icon } from 'dnb-ui-lib/src'
+import CSSDiagram from 'Pages/uilib/usage/customisation/assets/css_structure_diagram.js'
# Styling
The CSS is a compiled and minified version. You will find it here: `dnb-ui-lib/style/dnb-ui-lib.min.css`
-{CSSDiagram}
+The following Diagram gives an overall overview how the styles are structured.
+
+
## Apply the DNB Style
To use the default DNB style, you have to define a CSS class called: `dnb-style`
You can set this class on the document body or on any content container.
-
```html
-
+
+
e.g. I have now a margin and a size
+
☝🏻 Me as well
```
-
+
+The styles for the `dnb-style` are included in the default UI Theme.
+
+`dnb-ui-lib/style/themes/dnb-ui-theme.min.css`
+
+### What does `.dnb-style` apply?
+
+Once You have to style HTML Elements like:
+
+- Headings
+- Paragraphs
+- Basic Tables
+- Lists (ordered and unordered)
### The Reason
-The benefits of explicitly defining the style class `dnb-style`, is that we then can use the components on their own, without effecting all the existing styled browser elements and tags. This gives use a kind of backwards compatibility.
-But it makes it also more flexible, like if we only want to apply our DNB style to a certain area of our web application.
+The benefits of explicitly defining the style class `.dnb-style`, is that we then can use our [components](/uilib/components) on their own, without effecting all the existing styled HTML Elements and tags. This gives use a kind of backwards compatibility.
+But it makes it also more flexible, like if we only want to apply our DNB HTML Elements Styles to a certain area of our web application.
## For Node based environments
@@ -67,4 +82,4 @@ You also can import a single style of a single component:
import 'dnb-ui-lib/components/button/style'
```
-You may have a look at the guides about [colors](/quickguide-designer/colors/) and [fonts](/quickguide-designer/fonts/#fonts-to-show-code).
+You may have a look at the guides about [Typography](/uilib/typography).
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/theming.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/theming.md
index 41a239e5c3b..3257ac57acc 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/theming.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/theming.md
@@ -22,7 +22,7 @@ We have the **Main Theming File**, which is located here: `dnb-ui-lib/src/style/
From here, we "can" reuse some default theming mechanism, just to have a fallback:
```scss
-@import '../core/dnb-style.scss';
+@import '../themes/dnb-style.scss';
```
All the additional sub theming files (for every component) are automatically added to the **Main Theming File** by running `$ yarn build`. More on that further down.
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/examples/react-examples.js b/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/examples/react-examples.js
deleted file mode 100644
index 18d4666e3a4..00000000000
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/examples/react-examples.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import React from 'react'
-import { Button, Icon } from 'dnb-ui-lib/src'
-import { hamburger_medium as hamburgerIcon } from 'dnb-ui-lib/src/icons/secondary_icons_medium'
-
-const onClickHandler = event => {
- console.log('onClickHandler', event)
-}
-
-// only to satisfy the build process
-export default () => <>>
-
-export const ButtonEventExample = () => {
- return (
-
- )
-}
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/react.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/react.md
index 89d9e671623..6042c7281c9 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/react.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/react.md
@@ -6,7 +6,7 @@ order: 5
import ComponentBox from 'Tags/ComponentBox'
import { Button, IconPrimary } from 'dnb-ui-lib/src'
-import { ButtonEventExample } from 'Pages/uilib/usage/first-steps/examples/react-examples'
+import { hamburger as hamburgerIcon } from 'dnb-ui-lib/src/icons/secondary_icons'
# React JS for the web
@@ -40,41 +40,39 @@ The most basic way to use the `dnb-ui-lib` is like this:
`}
-
-
-
-
-
## Extended example
-```js
-import { Button } from 'dnb-ui-lib'
-
-const MyComponent = props => (
-
-)
-```
-
-## Event example
-
-```js
-import React from 'react'
-import { Button, Icon } from 'dnb-ui-lib'
-import { hamburger_medium as hamburgerIcon } from 'dnb-ui-lib/icons/secondary_icons_medium'
-
-const onClickHandler = event => {
- console.log('onClickHandler', event)
-}
-
-export const MyComponent = () => {
- return (
-