diff --git a/packages/dnb-design-system-portal/src/pages/design-system/about.md b/packages/dnb-design-system-portal/src/pages/design-system/about.md
index b2bbc1054fd..cfa2223919a 100644
--- a/packages/dnb-design-system-portal/src/pages/design-system/about.md
+++ b/packages/dnb-design-system-portal/src/pages/design-system/about.md
@@ -29,12 +29,16 @@ The goal is to have a single source of truth for design through color, typograph
Thank You for all who as contributed to build Eufemia. People who has contributed heavily to Eufemia are:
-- Jens Thuland
-- Sindre Marken
-- Casper Brekke
-- Tobias Høegh
-- Kevin Murphy
+- [Jens Thuland](https://dnb.enterprise.slack.com/user/@WE4QCR6PQ)
+- [Sindre Marken](https://dnb.enterprise.slack.com/user/@WDUUEJNVC)
+- [Casper Brekke](https://dnb.enterprise.slack.com/user/@WDU4VCEP5)
+- [Tobias Høegh](https://dnb.enterprise.slack.com/user/@WE2M4E65N)
+- [Kevin Murphy](https://dnb.enterprise.slack.com/user/@WE38HLQQ4)
- Hans Kristian Smedsrød
-- Nicolai Rygh
-The DNB ASA Design System is build together with [EGGS Design](https://eggsdesign.com/).
+The DNB ASA Design System (Eufemia) is build together with [EGGS Design](https://eggsdesign.com/).
+
+## More People to thank
+
+- [Nicolai Rygh](https://dnb.enterprise.slack.com/user/@WDY36GXKM)
+-
diff --git a/packages/dnb-design-system-portal/src/pages/icons/secondary.md b/packages/dnb-design-system-portal/src/pages/icons/secondary.md
index a6b02dafd11..72e15a6e40d 100644
--- a/packages/dnb-design-system-portal/src/pages/icons/secondary.md
+++ b/packages/dnb-design-system-portal/src/pages/icons/secondary.md
@@ -13,7 +13,7 @@ The Secondary Icons are an addition to the [Primary Icons](/icons/primary). They
The Secondary Icons can be extended infinitely.
-**Technically:** The consequence is that they have to be [imported](/uilib/components/icon#info) where ever they have to be used.
+**Technically:** The consequence is that they have to be [imported](/uilib/components/icon) where ever they have to be used.
#### A list of all Secondary Icons
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/components/accordion.md b/packages/dnb-design-system-portal/src/pages/uilib/components/accordion.md
index 6c61fad6695..958505e18cd 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/components/accordion.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/components/accordion.md
@@ -2,7 +2,7 @@
title: 'Accordion'
draft: false
status: 'wip'
-# order: 1
+order: 1
---
import Tabs from 'Tags/Tabs'
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/components/button.md b/packages/dnb-design-system-portal/src/pages/uilib/components/button.md
index 72c9ec94c5e..a24298cf625 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/components/button.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/components/button.md
@@ -1,15 +1,25 @@
---
title: 'Button'
draft: false
-status: null
-order: 1
+order: 2
---
-
+import Tabs from 'Tags/Tabs'
-import ButtonPage from 'Src/uilib/components/demos/Button'
+import FirstTabContent from 'Pages/uilib/components/button/button-info'
+import SecondTabContent from 'Pages/uilib/components/button/button-properties'
+import ThirdTabContent from 'Pages/uilib/components/button/button-events'
-
+# Button
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/components/button/Examples.js b/packages/dnb-design-system-portal/src/pages/uilib/components/button/Examples.js
new file mode 100644
index 00000000000..54043590878
--- /dev/null
+++ b/packages/dnb-design-system-portal/src/pages/uilib/components/button/Examples.js
@@ -0,0 +1,155 @@
+/**
+ * UI lib Component Example
+ *
+ */
+
+import React, { PureComponent, Fragment } from 'react'
+import ComponentBox from '../../../../shared/inlineTags/ComponentBox'
+import { bell_medium as Bell, question } from 'dnb-ui-lib/src/icons'
+
+class Example extends PureComponent {
+ clickHandler = () => {
+ alert('You clicked a button with a click function attached to it')
+ }
+ render() {
+ return (
+
+
+ {/* @jsx */ `
+
+ `}
+
+
+ {/* @jsx */ `
+
+ `}
+
+
+ {/* @jsx */ `
+
+ `}
+
+
+ {/* @jsx */ `
+
+ `}
+
+
+ {/* @jsx */ `
+
+ `}
+
+
+ {/* @jsx */ `
+
+ `}
+
+
+ {/* @jsx */ `
+
+ `}
+
+
+ {/* @jsx */ `
+
+ `}
+
+
+ {/* @jsx */ `
+
+
+ `}
+
+
+ {/* @jsx */ `
+
+
+
+
+
Button with Icon only
+ `}
+
+
+ {/* @jsx */ `
+// Medium is equalent to 24, but responsive
+
+ `}
+
+
+ {/* @jsx */ `
+}
+ icon_size="medium"
+ disabled
+/>
+ `}
+
+
+ )
+ }
+}
+
+export default Example
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/components/button/button-events.md b/packages/dnb-design-system-portal/src/pages/uilib/components/button/button-events.md
new file mode 100644
index 00000000000..a8412cc4bbc
--- /dev/null
+++ b/packages/dnb-design-system-portal/src/pages/uilib/components/button/button-events.md
@@ -0,0 +1,9 @@
+---
+draft: true
+---
+
+## Events
+
+| Events | Description |
+| ---------- | --------------------------------------------- |
+| `on_click` | _(optional)_ will be called on a click event. |
diff --git a/packages/dnb-ui-lib/src/components/button/description.md b/packages/dnb-design-system-portal/src/pages/uilib/components/button/button-info.md
similarity index 73%
rename from packages/dnb-ui-lib/src/components/button/description.md
rename to packages/dnb-design-system-portal/src/pages/uilib/components/button/button-info.md
index ff626f987ae..aa2f867c11c 100644
--- a/packages/dnb-ui-lib/src/components/button/description.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/components/button/button-info.md
@@ -1,3 +1,13 @@
+---
+draft: true
+---
+
+import Examples from 'Pages/uilib/components/button/Examples'
+
## Description
The button component should be used as the call-to-action in a form, or as a user interaction mechanism. Generally speaking, a button should not be used when a link would do the trick. Exceptions are made at times when it is used as a navigation element in the `action-nav` element.
+
+## Demos
+
+
diff --git a/packages/dnb-ui-lib/src/components/button/details.md b/packages/dnb-design-system-portal/src/pages/uilib/components/button/button-properties.md
similarity index 92%
rename from packages/dnb-ui-lib/src/components/button/details.md
rename to packages/dnb-design-system-portal/src/pages/uilib/components/button/button-properties.md
index 1e60c97e43d..161ab64c9e5 100644
--- a/packages/dnb-ui-lib/src/components/button/details.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/components/button/button-properties.md
@@ -1,3 +1,9 @@
+---
+draft: true
+---
+
+## Properties
+
| Properties | Description |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `type` | _(optional)_ `button`, `reset` or `submit` for the `type` HTML attribute (default to `button`) . |
@@ -12,7 +18,3 @@
| `class` | _(optional)_ any extra modifying class. |
| `attributes` | _(optional)_ insert any other attributes. For example `disabled` or any other custom attributes. |
| `href` | _(optional)_ if you want the button to behave as a link. Use with caution! A link should normally visually be a link and not a button. |
-
-| Events | Description |
-| ---------- | --------------------------------------------- |
-| `on_click` | _(optional)_ will be called on a click event. |
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/development.md b/packages/dnb-design-system-portal/src/pages/uilib/development.md
index 7fcbefc9f70..adb6babb472 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/development.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/development.md
@@ -9,7 +9,7 @@ import { Icon } from 'dnb-ui-lib/src'
# Development
-The `dnb-ui-lib` uses a [Node](https://nodejs.org) based setup with a lot of auto generated code to make the [React](https://reactjs.org) based components and patterns.
+The `dnb-ui-lib` uses a [Node.js](https://nodejs.org) based setup with a lot of auto generated code to make the [React](https://reactjs.org) based components and patterns.
## Repository
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/development/commit.md b/packages/dnb-design-system-portal/src/pages/uilib/development/commit.md
index f2cd7827709..46798ce899f 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/development/commit.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/development/commit.md
@@ -14,9 +14,17 @@ Version numbers are handled automatically by using [semantic-release](https://gi
Make sure to decorate Your **commit messages** with either [commit message format](https://github.com/semantic-release/semantic-release#commit-message-format) or simply use the following three methods:
-- `major: breaking change in API`
-- `minor: this is a new feature`
- `fix: an example fix message`
+- `feat: this is a new feature`
+- `break: breaking change in API`
+
+You can use these synonyms as well:
+
+- `patch: an example fix message`
+- `minor: this is a new feature`
+- `major: breaking change in API`
+
+Read more about [simple-commit-message](https://github.com/bahmutov/simple-commit-message).
## Committing changes
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/getting-started/requirements.md b/packages/dnb-design-system-portal/src/pages/uilib/getting-started/requirements.md
index 5d4e1a3f30d..42cf3e7c78f 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/getting-started/requirements.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/getting-started/requirements.md
@@ -18,5 +18,5 @@ This library can be used on top of a modern frontend framework.
**To run the portal (docs) locally - or to make changes to the `dnb-ui-lib`**
- [Git](https://git-scm.com)
-- [Node 64-bit](https://nodejs.org) (=> v10)
+- [Node.js 64-bit](https://nodejs.org) (=> v10)
- [Yarn](https://yarnpkg.com) (=> v1.12)
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/patterns/article.md b/packages/dnb-design-system-portal/src/pages/uilib/patterns/article.md
deleted file mode 100644
index 8a67d532dd0..00000000000
--- a/packages/dnb-design-system-portal/src/pages/uilib/patterns/article.md
+++ /dev/null
@@ -1,15 +0,0 @@
----
-title: 'Article'
-draft: false
-status: dep
-order: 2
----
-
-
-
-import ArticlePage from 'Src/uilib/patterns/demos/Article'
-
-
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 e046b872c20..519804fe0f9 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/typography.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/typography.md
@@ -16,6 +16,18 @@ Read more how to use the [different weights](/uilib/typography/font-weights/).
### Headings
+DNB UX Team has currently only defined tree levels of heading styles (h1, h2 and h3). But level 4, 5 and 6 is also supported by the `dnb-ui-lib`.
+
+In case You want to have a header look like a heading, You can use these classes:
+
+- `.dnb-h1`
+- `.dnb-h2`
+- `.dnb-lead`
+
+Read more about [best practices for typography](/uilib/usage/best-practices/for-typography).
+
+#### Heading examples
+
H1
H2
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/typography/anchor.md b/packages/dnb-design-system-portal/src/pages/uilib/typography/anchor.md
index 2bd7ed585a2..2dea5dfb2ae 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/typography/anchor.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/typography/anchor.md
@@ -4,7 +4,7 @@ draft: false
order: 2
---
-import { IconPrimary as Icon } from 'dnb-ui-lib/src'
+import { IconPrimary } from 'dnb-ui-lib/src'
# Anchor
@@ -20,13 +20,13 @@ Beside that the Anchor Tag gets assigned by default - or let's say, by only impo
## With Icon
-- Anchor with Icon
+- Anchor with Icon
-
Eros semper blandit tellus mollis primis quisque platea sollicitudin
- ipsum Inside a Paragraph auctor cursus mauris porta consectetur natoque vehicula vestibulum feugiat ultrices vitae fermentum eros euismod imperdiet eleifend justo vivamus posuere
+ ipsum Inside a Paragraph auctor cursus mauris porta consectetur natoque vehicula vestibulum feugiat ultrices vitae fermentum eros euismod imperdiet eleifend justo vivamus posuere
## Manipulation
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility.md
index 6b705a3da3d..1270b86064a 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility.md
@@ -2,7 +2,7 @@
title: 'Accessibility'
status: 'wip'
draft: false
-order: 3
+order: 4
---
# Accessibility
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility/focus.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility/focus.md
index 6282021f579..d4ffdef648d 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility/focus.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility/focus.md
@@ -7,15 +7,77 @@ draft: false
# Focus Management
Page Focus is an important part of keyboard-only navigation.
-After a navigation content gets loaded, make sure to assign it an _invisible_ focus, so the user can continue the navigation inside this new content.
-Read more about the term Page Focus in the [Body Component](/uilib/components/body#info).
+From the technical side, we have to assign an _invisible_ focus, so the user can continue the navigation inside this new content.
+
+**Example setup:**
```html
+
Main Title
+ I'm now focusable on next tab
```
+
+## Helper tool
+
+The `dnb-ui-lib` has an build in helper, to manage basic focus handling.
+This helper also handles both the `tabindex="-1"` and the `class="dnb-no-focus"` situation.
+
+### Focus helper
+
+```js
+import {
+ setPageFocusElement,
+ applyPageFocus
+} from 'dnb-ui-lib/shared/tools'
+
+// 1. Somewhere in Your app, set either an element, or a CSS Selector
+setPageFocusElement('.css-selector', 'MyCustomName')
+
+// 2. Later You can call this action, once it's time to activate the new focus state
+applyPageFocus('MyCustomName')
+```
+
+**So, make sure You:**
+
+- set the focus on the content (e.g. `
`) after a navigation action, initiated by the user.
+- set the focus into a _menu or navigation_ area, if it has an opening mechanism.
+- also set the focus back to the content, once the menu or navigation area gets closed.
+
+A more complex focus management is build in already to the [Modal Component](/uilib/components/modal). There we actually also disable focus possibility on the content behind, so the user only can navigate inside the modal.
+
+### Skip Link
+
+The `dnb-ui-lib` also has a small setup for a [skip link](https://www.w3.org/TR/WCAG20-TECHS/G1.html)
+
+Our solution is CSS only and should work for all kinds of App setups.
+Place an Anchor like this one blow, on the very top of Your App content:
+
+
+```html
+Skip to content
+```
+
+
+Also, place a `id="dnb-app-content"` on Your content wrapper:
+
+
+```html
+
+ Skip to content
+
+
+
+
+
+
+
+```
+
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility/icons.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility/icons.md
index 5baac620338..b0ac299a815 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility/icons.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/accessibility/icons.md
@@ -8,6 +8,10 @@ import Beach from 'Pages/uilib/usage/accessibility/assets/beach'
# Accessibility of Icons
+By using Inline SVG, we have today the possibility to make graphical assets both **responsive** and **interactive**. In order to do so, use the [Icon](/uilib/components/icon) or [IconPrimary](/uilib/components/icon-primary) component. These components provides the needed runtime processing, witch is needed to get there.
+
+## Decorative Icons
+
If your icons are purely **decorative**, you’ll need to manually add an **aria-hidden** (results in `aria-hidden="true"`) attribute to each of your icons so Your app is "accessible".
@@ -15,3 +19,14 @@ If your icons are purely **decorative**, you’ll need to manually add an **aria
`}
+
+## Responsive Icons
+
+Use `size="auto"` to force the icon to inherit the size of its parent element.
+
+
+{`
+
My H1 with an Icon
+
My H4 with the same Icon
+`}
+
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices.md
index 8742e4d2cd3..a7e6555b88f 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices.md
@@ -3,6 +3,7 @@ title: 'Best Practices'
menuTitle: 'Best Practices ...'
status: 'wip'
draft: false
+order: 5
---
# Best Practices
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices/for-styling.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices/for-styling.md
index 268c9005741..46e451eb82d 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices/for-styling.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices/for-styling.md
@@ -55,6 +55,7 @@ This helps coworkers quickly find and understand the sentence and meaning of the
Here is a list of what we should use as layout and styling units to embrace the best possible accessibility experience and visual correctness.
-- `rem` Use _rem_ as a default sizing unit - when ever other units don't are favorited.
-- `em` Use _em_ only on complex layouts, when ever You need the sizes to respond to constrains. But use _em_ for CSS `@media` queries for the best browser compatibility.
-- `px` Use _pixels_ on visual helper lines and borders. Borders don't need necessarily to be responsive.
+- **`rem`**: Use _rem_ as a default sizing unit - when ever other units don't are favorited.
+- **`em`**: Use _em_ only on complex layouts, when ever You need the sizes to respond to constrains. But use _em_ for CSS `@media` queries for the best browser compatibility.
+- **`px`**: Use _pixels_ on visual helper lines and borders. Borders don't need necessarily to be responsive.
+- **`viewport units and percentage`**: Use these units to make layout and component withs responsive. Also placing and positioning layout wrappers, with these units, may give the user a good experience.
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices/for-typography.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices/for-typography.md
index e01a4507105..690ce4dc2a6 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices/for-typography.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/best-practices/for-typography.md
@@ -9,7 +9,9 @@ order: 2
### Headings and styling
-Never use Headings (like `
`) for only styling purposes. Headings exist in first place to practice correct semantics, witch again will gain all kind of users.
+Never use Headings (like `
`) for only styling purposes. Headings exist in first place to practice correct semantics, witch again will gain all kind of users.
+
+For styling purposes only, use `.dnb-h1` , `.dnb-h2` or `.dnb-lead`. Or style Your Typography regarding to the Prototypes.
Use headings where You think that someone with a Screen Reader would have benefits of finding and reading a title.
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation.md
index eac2b5c4ead..3e6b84ecc7f 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation.md
@@ -2,6 +2,7 @@
title: 'Customisation'
status: 'wip'
draft: false
+order: 3
---
# Customisation
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/css_structure_diagram.js b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/css_structure_diagram.js
index f4bcd852483..931b65110a5 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/css_structure_diagram.js
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/assets/css_structure_diagram.js
@@ -2,181 +2,176 @@ import React from 'react'
export default props => (
)
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/component-properties.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/component-properties.md
index 6a25e462147..ff517a02c5a 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/component-properties.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/component-properties.md
@@ -1,17 +1,95 @@
---
title: 'Component Properties'
draft: false
-order: 3
+order: 6
---
-import PropertiesExample from 'Pages/uilib/usage/customisation/examples/properties-example'
+import 'dnb-ui-lib/src/web-components'
+import ComponentBox from 'Tags/ComponentBox'
+import { hamburger as hamburgerIcon } from 'dnb-ui-lib/src/icons/secondary_icons'
# Component Properties
-## What if a property has to change at runtime?
+Every [Component](/uilib/components) has its own `properties` to make them work for a variety of cases. You may have a look at the Table describing all the possibilities. Check out f.eks. the [Button Properties](/uilib/components/button#info).
+
+But here You have some examples. You can even modify them right away in the Browser.
+
+## Large Buttons & Icons
+
+
+{`
+
+
+`}
+
+
+## Extended example
+
+
+{`
+const Wrapper = styled.div\`
+ .dnb-button {
+ --button-width: 4rem;
+ --button-height: 4rem;
+ --button-border-radius: 2rem;
+ svg {
+ color: fuchsia;
+ }
+ }
+\`
+const myHandler = () => alert('Hello')
+render(
+
+
+
+
+)
+`}
+
+
+## Web Components and properties
+
+> What if a property has to change at runtime?
Changing a property (`props`) at runtime is a common thing in React. But also `dnb-ui-lib` Web Components support `prop` changes.
Keep in mind that not all components are tested to the last detail.
So, if you come over some special use cases, please contribute back and make a pull request.
-
+
+{`
+const Component = () => {
+ const time = new Date().toLocaleTimeString()
+ render(
+ <>
+
+ Web Component property updates
+
+
+ >
+ )
+}
+Component()
+clearInterval(window.intervalId)
+window.intervalId = setInterval(Component, 1e3)
+`}
+
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/consume-styles.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/consume-styles.md
new file mode 100644
index 00000000000..55ab98d1b16
--- /dev/null
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/consume-styles.md
@@ -0,0 +1,57 @@
+---
+title: 'Importing CSS'
+draft: false
+order: 2
+---
+
+import Img from 'Tags/Img'
+import { Icon } from 'dnb-ui-lib/src'
+import CSSDiagram from 'Pages/uilib/usage/customisation/assets/css_structure_diagram.js'
+
+# Importing the CSS
+
+To include the packages `dnb-ui-core`, `dnb-ui-components` and `dnb-theme-ui` in a [Node.js](https://nodejs.org) based environment (given You have a CSS loader in place), do this:
+
+```js
+// This includes the "dnb-ui-core", "dnb-ui-components" and "dnb-theme-ui"
+import 'dnb-ui-lib/style'
+```
+
+### No Theme
+
+If You want to import the styles of all components only - without **dnb-theme-ui**:
+
+```js
+// No Theme is included
+import 'dnb-ui-lib/style/components'
+```
+
+### Custom Theme
+
+You may want to import a theme as well:
+
+```js
+// No Theme is included
+import 'dnb-ui-lib/style/components'
+
+// Default DNB UI Theme
+import 'dnb-ui-lib/style/theme'
+```
+
+```js
+// ... is equivalent to the default theme
+import 'dnb-ui-lib/style/themes/ui'
+
+// ... or some other theme
+import 'dnb-ui-lib/style/themes/[NAME].css'
+```
+
+### Single Component only
+
+You also can import a single style of a single component:
+
+```js
+// Imports only the Button CSS and Main DNB Theme
+import 'dnb-ui-lib/components/button/style'
+import 'dnb-ui-lib/components/button/style/themes/ui'
+```
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 d2177f21628..41b924e9401 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
@@ -1,7 +1,7 @@
---
title: 'Event Handling'
draft: false
-order: 4
+order: 7
---
import ComponentBox from 'Tags/ComponentBox'
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
deleted file mode 100644
index 34503526171..00000000000
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/customisation/examples/properties-example.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Example
- *
- */
-
-import React, { PureComponent, Fragment } from 'react'
-import PropTypes from 'prop-types'
-
-export default class MyClass extends PureComponent {
- static propTypes = {
- children: PropTypes.node
- }
- static defaultProps = {
- children: null
- }
- constructor(props) {
- super(props)
- this.state = { time: this.getTime() }
- }
- getTime() {
- return new Date().toLocaleTimeString()
- }
- setTime() {
- this.setState({ time: this.getTime() })
- }
- componentDidMount() {
- this.setTime()
- this.myInterval = setInterval(() => this.setTime(), 1e3)
- }
- componentWillUnmount() {
- clearInterval(this.myInterval)
- }
- render() {
- const { children } = this.props
- return (
-
- {children}
-
- 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 dc41dfa67db..5a4a5c1ea42 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,5 +1,5 @@
---
-title: 'Styling'
+title: 'CSS Styles'
draft: false
order: 1
---
@@ -8,78 +8,41 @@ import Img from 'Tags/Img'
import { Icon } from 'dnb-ui-lib/src'
import CSSDiagram from 'Pages/uilib/usage/customisation/assets/css_structure_diagram.js'
-# Styling
+# CSS Styles
-The CSS is a compiled and minified version. You will find it here: `dnb-ui-lib/style/dnb-ui-lib.min.css`
+To ensure flexibility and the possibility of [theming](/uilib/usage/customisation/theming), the DNB CSS Styles area build in a bottom up manner.
-The following Diagram gives an overall overview how the styles are structured.
+The styles are decoupled from the functional [components](/uilib/components).
+There are several Packages You can use.
-
-
-## 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)
+- **dnb-ui-core** - Includes the `DNB Main Style`.
+- **dnb-ui-components** - Includes all the styles for the [components](/uilib/components).
+- **dnb-ui-patterns** - Includes all the styles for the [patterns](/uilib/patterns).
+- **dnb-theme-ui** - Includes both the `DNB Main Theme` (_inkl. HTML elements_) and themes for every `component`.
-### The Reason
+All the CSS packages are ready to use, minified CSS files. You will find the main style here, like: `dnb-ui-lib/style/dnb-ui-core.min.css`
-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.
+Additionally, it is also possible to import a style and theme for every single component separately. You find the styles here, like: `dnb-ui-lib/components/[button]/style/dnb-button.min.css`
-## For Node based environments
+The following Diagram gives an overall overview how the packages are structured.
-To include the `dnb-ui-lib` styles (except patterns), do this:
-
-```js
-// This also includes the default DNB UI Theme
-import 'dnb-ui-lib/style'
-```
-
-If You want to import the styles of all components - **without** the default DNB UI Theme:
-
-```js
-// No Theme is included
-import 'dnb-ui-lib/style/components'
-```
-
-You may want to import a theme as well:
+
-```js
-// Default DNB UI Theme
-import 'dnb-ui-lib/style/theme'
+You may have a look at the guides about [Typography](/uilib/typography).
-// ... is equivalent to the default theme
-import 'dnb-ui-lib/style/themes/ui'
+## Spacing
-// ... or some other theme
-import 'dnb-ui-lib/style/themes/[NAME].css'
-```
+To ensure more flexibility, all the margins / spacings are reset to zero. But more often we have to have a by default defined e.g. `margins` on HTML Elements like headings or paragraphs.
-You also can import a single style of a single component:
+To use the default DNB spacings, You can define a CSS class called: `.dnb-spacing`
+Everything inside this container will then have a default spacing. This will be specially helpful for article alike pages.
-```js
-import 'dnb-ui-lib/components/button/style'
+```html
+
+
+
e.g. I have now a margin
+
☝🏻 Me as well
+
```
-You may have a look at the guides about [Typography](/uilib/typography).
+The styles for the `.dnb-spacing` are included in the package: **dnb-theme-ui**
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 3257ac57acc..325e5a0d20d 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
@@ -1,12 +1,12 @@
---
title: 'Theming'
draft: false
-order: 2
+order: 5
---
# Theming
-Read the [Styling examples](/uilib/usage/styling) on how to include styles and a theme.
+Read the [Styling examples](/uilib/usage/customisation/styling) on how to include styles and a theme.
This section is about how theming works and how to actually create a custom theme.
## How Themes are built
@@ -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 '../themes/dnb-style.scss';
+@import '../themes/dnb-spacing.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/react.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/react.md
index 6042c7281c9..0847fc3dea9 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
@@ -12,7 +12,7 @@ import { hamburger as hamburgerIcon } from 'dnb-ui-lib/src/icons/secondary_icons
The most basic way to use the `dnb-ui-lib` is like this:
-### Basic Buttons
+## Basic Buttons
{`
@@ -20,59 +20,19 @@ The most basic way to use the `dnb-ui-lib` is like this:
`}
-### Large Buttons & Icons
+### Importing the Components
-
-{`
-<>
-
-
->
-`}
-
+To make the [Button](/uilib/components/button) Component work, we have to import it as well:
-## Extended example
+```js
+import { Button } from 'dnb-ui-lib'
+```
-
-{`
-// import { Button, Icon } from 'dnb-ui-lib'
-// import { hamburger as hamburgerIcon } from 'dnb-ui-lib/icons/secondary_icons'
-const Wrapper = styled.div\`
- .dnb-button {
- --button-width: 4rem;
- --button-height: 4rem;
- --button-border-radius: 2rem;
- svg {
- color: fuchsia;
- }
- }
-\`
-const myHandler = () => alert('Hello')
-render(
-
-
-
-
-)
-`}
-
+And here an example with several imports:
+
+```js
+import { Button, Icon } from 'dnb-ui-lib'
+import { hamburger as hamburgerIcon } from 'dnb-ui-lib/icons/secondary_icons'
+```
+
+You may have a look at a [Example for React on GitHub](https://github.com/dnbexperience/eufemia/tree/develop/packages/examples/example-react).
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/the-basics.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/the-basics.md
index e4f8a9cfee4..ee353ba55de 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/the-basics.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/the-basics.md
@@ -34,26 +34,43 @@ All the HTML elements have individual interaction states. The look and feel is d
- focus
- disabled
-## Global Scope
+## CSS Styles
-Once You import the `dnb-ui-lib` style, You will not only get the HTML Element styles, but also for lower lever tags like [Headings and Paragraphs](/uilib/typography) and support for [Focus Management](/uilib/usage/accessibility/focus).
+Have a read on [how the styles are setup](/uilib/usage/customisation/styling) and [how to import the CSS](/uilib/usage/customisation/consume-styles).
## Compiler
With [Node.js](https://nodejs.org/) as our JavaScript runtime in place, we may use ES6 (ECMAScript 2015) to write our application. There are many frameworks and libraries to build user interfaces. If we take [React JSX](https://reactjs.org/docs/add-react-to-a-website.html#optional-try-react-with-jsx) as an starting point, we basically [do this](/uilib/usage/first-steps/react):
-
+
{`
`}
+```jsx
+// Define the imports
+import { Button } from 'dnb-ui-lib'
+
+// And consume the Component in Your markup render method
+render()
+```
+
You also may [import the styles](/uilib/usage/customisation/styling) on a higher lever in Your application:
```js
+// e.g. in the App root
import 'dnb-ui-lib/style'
```
+You can also import a single style of one component at a time:
+
+```js
+// Imports only the Button CSS and Main DNB Theme
+import 'dnb-ui-lib/components/button/style'
+import 'dnb-ui-lib/components/button/style/themes/ui'
+```
+
And finally bind an [event listener](/uilib/usage/customisation/event-handling):
```jsx
@@ -70,7 +87,15 @@ In case you don't have a compiling/build process, You can use the UMD packed ver
...
+
+
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/vue.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/vue.md
index 3166c894bcc..2e9990f45b2 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/vue.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/vue.md
@@ -30,7 +30,7 @@ And the syntax would look like:
```html
-
+
diff --git a/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/web-components.md b/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/web-components.md
index 56701ea1da3..2f19dbb16b3 100644
--- a/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/web-components.md
+++ b/packages/dnb-design-system-portal/src/pages/uilib/usage/first-steps/web-components.md
@@ -4,15 +4,14 @@ draft: false
order: 7
---
-import dnb from 'dnb-ui-lib/src/web-components'
+import 'dnb-ui-lib/src/web-components'
+import ComponentBox from 'Tags/ComponentBox'
# Web Components
So called [Custom Elements](https://www.w3.org/TR/custom-elements/), running as a [Web Component](https://github.com/w3c/webcomponents/) can be used to run the `dnb-ui-lib` components in all other frameworks like Dojo, Vue and Angular.
----
-
-##### Example
+## Example usage
```jsx
// Method #1
@@ -30,26 +29,19 @@ Now we can use our web components right away in our markup.
### Button
-
-
-```html
-
-```
-
-
+
+{`
-
+`}
+
### Input
-```html
-Label for this Input
-My Value
-```
-
-
- The following header pattern consists of an H1 with the first part
- wrapped in a 'small' tag. The small tag is displaying as a block.
- Following the h1 is a paragarph tag with class 'dnb-lead' which is
- used here as an ingress or intro paragraph.
-
-
- The default bottom margin is removed from elements (H1, H2, p etc.)
- placed inside a 'header'.
-
-
-
-
- Ha finansieringsbeviset klart
- Det tar bare noen minutter å søke og få svar på hvor mye du kan
- låne
-
- Spare er appen som samler alt om sparing på ett sted. Opprett
- sparemål og spar til de gode opplevelsene som du kan dele med de
- du er glad i. Last ned appen på mobilen din nå!
-
-
-
- In these examples pattern, note the custom margin between the
- header and the last paragraph
-
-
-
-
- Ha finansieringsbeviset klart
-
- Det tar bare noen minutter å søke og få svar på hvor mye du
- kan låne
-
-
- Spare er appen som samler alt om sparing på ett sted. Opprett
- sparemål og spar til de gode opplevelsene som du kan dele med de
- du er glad i. Last ned appen på mobilen din nå!
-
-
-
An example subheader
-
-
A sub header (h2 with default margin bottom.)
-
- Spare er appen som samler alt om sparing på ett sted. Opprett
- sparemål og spar til de gode opplevelsene som du kan dele med de
- du er glad i. Last ned appen på mobilen din nå!
-
- h4 Five or six big jet planes zoomed quickly by the new tower.
-
-
- h5 Expect skilled signwriters to use many jazzy, quaint old
- alphabets effectively.
-
-
h6 Pack my box with five dozen liquor jugs.
-
-
-
-
-
-
-
-
-
- This paragraph is nested inside an article. It contains many
- different, sometimes useful,{" "}
- HTML5 tags. Of
- course there are classics like emphasis,{" "}
- strong, and small but there are
- many others as well. Hover the following text for abbreviation
- tag: abbr. Similarly, you can
- use acronym tag like this:{" "}
- ftw. You can define{" "}
- deleted text which often gets replaced with{" "}
- inserted text.
-
-
- You can also use keyboard text, which sometimes is
- styled similarly to the <code> or{" "}
- samp tags. Even more specifically, there is a tag
- just for variables. Not to be mistaken with
- blockquotes below, the quote tag lets you denote something as{" "}
- quoted text. Lastly don't forget the sub (H
- 2O) and sup (E = MC2) tags.{" "}
-
-
-
-
-
-
-
-
-
- Blockquote: I quickly explained that many big jobs involve few
- hazards
-
-
-
-
- This is a mult-line blockquote with a cite reference. People
- think focus means saying yes to the thing you’ve got to focus
- on. But that’s not what it means at all. It means saying no to
- the hundred other good ideas that there are. You have to pick
- carefully. I’m actually as proud of the things we haven’tdone
- as the things I have done. Innovation is saying no to 1,000
- things.
-
- Steve Jobs – Apple Worldwide Developers’ Conference, 1997
-
-
-
-
-
-
-
-
Tables can have captions now.
-
-
-
Person
-
Number
-
Third Column
-
-
-
Someone Lastname
-
900
-
- Nullam quis risus eget urna mollis ornare vel eu leo.
-
-
-
-
Person Name
-
1200
-
- Vestibulum id ligula porta felis euismod semper. Donec
- ullamcorper nulla non metus auctor fringilla.
-
-
-
-
Another Person
-
1500
-
- Vivamus sagittis lacus vel augue laoreet rutrum faucibus
- dolor auctor. Nullam id dolor id nibh ultricies vehicula ut
- id elit.
-
-
-
-
Last One
-
2800
-
- Morbi leo risus, porta ac consectetur ac, vestibulum at
- eros. Cras mattis consectetur purus sit amet fermentum.
-
-
-
-
-
-
-
-
-
Definition List Title
-
Definition list division.
-
Kitchen Sink
-
- Used in expressions to describe work in which all conceivable
- (and some inconceivable) sources have been mined. In this case,
- a bunch of markup.
-
-
aside
-
Defines content aside from the page content
-
blockquote
-
Defines a section that is quoted from another source
-
-
-
-
-
-
- Unordered List item one
-
-
- Nested list item
-
-
Level 3, item one
-
Level 3, item two
-
Level 3, item three
-
Level 3, item four
-
-
-
List item two
-
List item three
-
List item four
-
-
-
List item two
-
List item three
-
List item four
-
-
-
-
- List item one
-
-
- List item one
-
-
List item one
-
List item two
-
List item three
-
List item four
-
-
-
List item two
-
List item three
-
List item four
-
-
-
List item two
-
List item three
-
List item four
-
-
-
-
-
- 1 Infinite Loop
-
- Cupertino, CA 95014
-
- United States
-
-
-
-
-
-
diff --git a/packages/dnb-ui-lib/.babelrc b/packages/dnb-ui-lib/.babelrc
index 41279dab2d0..2a61edfd353 100644
--- a/packages/dnb-ui-lib/.babelrc
+++ b/packages/dnb-ui-lib/.babelrc
@@ -1,7 +1,17 @@
{
"env": {
"test": {
- "presets": ["@babel/preset-env", "@babel/preset-react"],
+ "presets": [
+ [
+ "@babel/preset-env",
+ {
+ "targets": {
+ "node": "10.6"
+ }
+ }
+ ],
+ "@babel/preset-react"
+ ],
"ignore": ["node_modules/**"],
"plugins": [
"transform-dynamic-import",
@@ -10,7 +20,17 @@
]
},
"development": {
- "presets": ["@babel/preset-env", "@babel/preset-react"],
+ "presets": [
+ [
+ "@babel/preset-env",
+ {
+ "targets": {
+ "browsers": "last 1 versions"
+ }
+ }
+ ],
+ "@babel/preset-react"
+ ],
"ignore": ["node_modules/**", "**/*.test.js"],
"plugins": [
"@babel/plugin-proposal-export-default-from",
@@ -29,7 +49,7 @@
"firefox": 45,
"chrome": 49,
"safari": 10,
- "node": "6.11"
+ "node": "10.6"
},
"useBuiltIns": false
}
@@ -66,8 +86,7 @@
"edge": 14,
"firefox": 45,
"chrome": 49,
- "safari": 10,
- "node": "6.11"
+ "safari": 10
},
"modules": false
}
diff --git a/packages/dnb-ui-lib/.storybook/.babelrc b/packages/dnb-ui-lib/.storybook/.babelrc
index 485f79d1c0d..054c4a29c59 100644
--- a/packages/dnb-ui-lib/.storybook/.babelrc
+++ b/packages/dnb-ui-lib/.storybook/.babelrc
@@ -3,6 +3,7 @@
"ignore": ["node_modules/**"],
"plugins": [
"emotion",
+ "@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties"
]
diff --git a/packages/dnb-ui-lib/.stylelintignore b/packages/dnb-ui-lib/.stylelintignore
index 34aa8d6b088..001d4e0af68 100644
--- a/packages/dnb-ui-lib/.stylelintignore
+++ b/packages/dnb-ui-lib/.stylelintignore
@@ -2,3 +2,4 @@
*not_in_use*
src/components/slider/Slider.js
scripts
+stories
diff --git a/packages/dnb-ui-lib/assets/icons/file.svg b/packages/dnb-ui-lib/assets/icons/file.svg
new file mode 100644
index 00000000000..02f987f3f47
--- /dev/null
+++ b/packages/dnb-ui-lib/assets/icons/file.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/packages/dnb-ui-lib/assets/icons/file_medium.svg b/packages/dnb-ui-lib/assets/icons/file_medium.svg
new file mode 100644
index 00000000000..77fb9c4d3aa
--- /dev/null
+++ b/packages/dnb-ui-lib/assets/icons/file_medium.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/packages/dnb-ui-lib/assets/icons/search.svg b/packages/dnb-ui-lib/assets/icons/search.svg
index 04160f3a120..e54ebdf19ca 100644
--- a/packages/dnb-ui-lib/assets/icons/search.svg
+++ b/packages/dnb-ui-lib/assets/icons/search.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/packages/dnb-ui-lib/assets/icons/search_medium.svg b/packages/dnb-ui-lib/assets/icons/search_medium.svg
index 54763c6f2f7..324e411c1d8 100644
--- a/packages/dnb-ui-lib/assets/icons/search_medium.svg
+++ b/packages/dnb-ui-lib/assets/icons/search_medium.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/packages/dnb-ui-lib/jest-screenshot.json b/packages/dnb-ui-lib/jest-screenshot.json
new file mode 100644
index 00000000000..6c67afa50e7
--- /dev/null
+++ b/packages/dnb-ui-lib/jest-screenshot.json
@@ -0,0 +1,3 @@
+{
+ "pixelThresholdRelative": 0.15
+}
diff --git a/packages/dnb-ui-lib/jest.config.js b/packages/dnb-ui-lib/jest.config.js
index 7070d3531f0..5039a372a88 100644
--- a/packages/dnb-ui-lib/jest.config.js
+++ b/packages/dnb-ui-lib/jest.config.js
@@ -3,8 +3,9 @@ const config = {
testURL: 'http://localhost',
moduleFileExtensions: ['js', 'json', 'scss', 'css'],
testRegex: '(/__tests__/\\.js|(\\.|/)(test|spec))\\.js?$',
- modulePathIgnorePatterns: ['not_in_use', '/dist/'],
+ modulePathIgnorePatterns: ['not_in_use', '/dist/', 'screenshot'],
transformIgnorePatterns: ['node_modules'],
+ // globalTeardown: './src/core/jest/jestGlobalTeardown.js',
transform: {
'^.+\\.(js|jsx)$': 'babel-jest',
'^.+\\.(md|txt)$': 'jest-raw-loader'
diff --git a/packages/dnb-ui-lib/jest.config.screenshots.js b/packages/dnb-ui-lib/jest.config.screenshots.js
new file mode 100644
index 00000000000..1616a0b7b71
--- /dev/null
+++ b/packages/dnb-ui-lib/jest.config.screenshots.js
@@ -0,0 +1,15 @@
+// because --testPathIgnorePatterns=[array] has a bug, we do handle the ignore screenshots with this config
+const config = require('./jest.config.js')
+module.exports = {
+ ...config,
+ ...{
+ testRegex: 'screenshot.test.js$',
+ globalSetup: './src/core/jest/jestPuppeteerSetup.js',
+ globalTeardown: './src/core/jest/jestPuppeteerTeardown.js',
+ testEnvironment: './src/core/jest/jestPuppeteerEnvironment.js',
+ setupFilesAfterEnv: ['./src/core/jest/setupJestScreenshot.js'],
+ modulePathIgnorePatterns: config.modulePathIgnorePatterns.filter(i => {
+ return i !== 'screenshot'
+ })
+ }
+}
diff --git a/packages/dnb-ui-lib/package.json b/packages/dnb-ui-lib/package.json
index 12fc982725f..abf44b48def 100644
--- a/packages/dnb-ui-lib/package.json
+++ b/packages/dnb-ui-lib/package.json
@@ -15,6 +15,7 @@
"main": "index.js",
"scripts": {
"post-build": "yarn prettier:other",
+ "audit-ci": "babel-node ./scripts/prepub/audit/toOpt && audit-ci --moderate --package-manager=yarn; babel-node ./scripts/prepub/audit/toDev",
"build": "yarn prepublish:local && yarn post-build",
"cdn": "live-server --no-browser --cors --port=8081",
"precommit": "yarn lint-staged",
@@ -33,7 +34,7 @@
"lint-ci": "yarn lint:js && yarn lint:styles",
"lint-staged": "lint-staged -d",
"lint:js": "yarn lint --fix",
- "lint:js:staged": "yarn lint:js",
+ "lint:js:staged": "eslint --quiet --fix",
"lint:styles": "stylelint './src/{components,patterns,style}/**/*.{js,scss}'",
"lint:styles:staged": "stylelint",
"publish": "yarn publish-ci --dry-run",
@@ -51,9 +52,13 @@
"t": "jest --watch --testPathPattern ",
"test": "jest --watch",
"test-ci": "jest --ci",
- "test:screenshots": "cross-env NODE_ENV=test TAKE_SCREENSHOTS=true jest --watch --forceExit",
- "test:staged": "jest --bail --findRelatedTests :#keep this whitespace",
+ "test-ci-screenshots": "jest --config=./jest.config.screenshots.js --ci --detectOpenHandles",
+ "test:screenshots": "jest --config=./jest.config.screenshots.js --watch --forceExit",
+ "test:screenshots:update": "jest --config=./jest.config.screenshots.js --updateSnapshot --detectOpenHandles",
+ "test:screenshots:update:build": "yarn build && yarn workspace dnb-design-system-portal build-portal && yarn test:screenshots:update",
+ "test:staged": "jest --bail --findRelatedTests ",
"test:update": "jest --updateSnapshot",
+ "ts": "jest --config=./jest.config.screenshots.js --watch --testPathPattern ",
"prettier:diff": "prettier --list-different '{scripts,stories,src}/**/*.{md,js}'",
"prettier:js": "prettier --loglevel warn --write '{scripts,stories,src}/**/*.js'",
"prettier:js:staged": "prettier --loglevel warn",
@@ -68,8 +73,8 @@
"classnames": "^2.2.6",
"keycode": "^2.2.0",
"prop-types": "^15.6.2",
- "react": "^16.7.0",
- "react-dom": "^16.7.0",
+ "react": "^16.8.0",
+ "react-dom": "^16.8.0",
"react-text-mask": "^5.4.3",
"vuera": "^0.2.3",
"what-input": "^5.1.3"
@@ -83,7 +88,8 @@
"@babel/node": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.3.0",
"@babel/plugin-proposal-export-default-from": "^7.2.0",
- "@babel/plugin-proposal-object-rest-spread": "^7.3.1",
+ "@babel/plugin-proposal-object-rest-spread": "^7.3.2",
+ "@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.3.1",
@@ -92,31 +98,32 @@
"@storybook/addon-options": "^4.1.11",
"@storybook/react": "^4.1.11",
"@svgr/core": "^4.1.0",
+ "audit-ci": "^1.3.0",
"babel-core": "7.0.0-bridge.0",
- "babel-jest": "^23.6.0",
+ "babel-jest": "^24.1.0",
"babel-loader": "^8.0.5",
- "babel-plugin-emotion": "^10.0.6",
+ "babel-plugin-emotion": "^10.0.7",
"babel-plugin-react-remove-properties": "^0.2.5",
"babel-plugin-transform-dev-warning": "^0.1.1",
"babel-plugin-transform-dynamic-import": "^2.1.0",
"babel-plugin-transform-react-constant-elements": "^6.23.0",
- "babel-plugin-transform-react-remove-prop-types": "^0.4.23",
+ "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"camelcase": "^5.0.0",
"chalk": "^2.4.2",
"ci-info": "^2.0.0",
"color": "^3.1.0",
- "cross-env": "^5.2.0",
"css-loader": "^2.1.0",
- "css-vars-ponyfill": "^1.16.3",
+ "css-vars-ponyfill": "^1.16.4",
"del": "^3.0.0",
+ "detect-port": "^1.3.0",
"dotenv": "^6.2.0",
- "emotion": "^10.0.6",
+ "emotion": "^10.0.7",
"enzyme": "^3.8.0",
- "enzyme-adapter-react-16": "^1.8.0",
+ "enzyme-adapter-react-16": "^1.9.1",
"enzyme-to-json": "^3.3.5",
- "eslint": "^5.12.1",
+ "eslint": "^5.13.0",
"eslint-plugin-import": "^2.16.0",
- "eslint-plugin-jsx-a11y": "^6.2.0",
+ "eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-security": "^1.4.0",
"figma-js": "^1.5.1",
@@ -135,13 +142,13 @@
"gulp-transform": "^3.0.5",
"gulp-uglify": "^3.0.1",
"history": "^4.7.2",
- "jest": "^23.6.0",
- "jest-axe": "^3.1.0",
+ "jest": "^24.1.0",
+ "jest-axe": "^3.1.1",
"jest-css-modules": "^1.1.0",
"jest-raw-loader": "^1.0.1",
"jest-screenshot": "^0.2.1",
"jest-tobetype": "^1.2.0",
- "lint-staged": "^8.1.1",
+ "lint-staged": "^8.1.3",
"live-server": "^1.2.1",
"lodash.isequal": "^4.5.0",
"lodash.isequalwith": "^4.4.0",
@@ -152,9 +159,9 @@
"packpath": "^0.1.0",
"postcss-calc": "^7.0.1",
"postcss-preset-env": "^6.5.0",
- "prettier": "^1.16.1",
+ "prettier": "^1.16.4",
"prettier-package-json": "^2.0.1",
- "puppeteer": "^1.11.0",
+ "puppeteer": "^1.12.2",
"raw-loader": "^1.0.0",
"react-fake-props": "^0.3.1",
"rollup": "^1.1.2",
@@ -162,7 +169,7 @@
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^4.0.0",
- "rollup-plugin-scss": "^0.4.0",
+ "rollup-plugin-scss": "^1.0.0",
"sass-loader": "^7.1.0",
"sass-variable-parser": "^1.2.2",
"scss-to-json": "^2.0.0",
@@ -174,7 +181,7 @@
"stylelint": "^9.10.1",
"stylelint-config-prettier": "^4.0.0",
"stylelint-config-standard": "^18.2.0",
- "stylelint-scss": "^3.5.1",
+ "stylelint-scss": "^3.5.2",
"svgo": "^1.1.1",
"text-mask-addons": "^3.8.0",
"traverse": "^0.6.6",
diff --git a/packages/dnb-ui-lib/scripts/commands/commands.js b/packages/dnb-ui-lib/scripts/commands/commands.js
deleted file mode 100644
index 9c3be91f955..00000000000
--- a/packages/dnb-ui-lib/scripts/commands/commands.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * CLI Commands
- *
- */
-
-import chalk from 'chalk'
-import fs from 'fs'
-
-const ignoredExtensions = [
- 'css',
- 'scss',
- 'styl',
- 'less',
- 'png',
- 'gif',
- 'jpg',
- 'jpeg',
- 'svg',
- 'woff',
- 'ttf',
- 'eot',
- 'otf',
- 'mp4',
- 'webm',
- 'ogg',
- 'mp3',
- 'wav',
- 'md',
- 'yaml'
-]
-ignoredExtensions.forEach(ext => {
- require.extensions[`.${ext}`] = () => {}
-})
-
-const cmd = process.argv[2]
-
-const run = () => {
- if (['-v', '--version'].indexOf(cmd) !== -1) {
- const packageJson = JSON.parse(
- fs.readFileSync(`${__dirname}/../../package.json`, 'utf8')
- )
- return console.log(packageJson.version)
- }
-
- if (cmd === 'prepublish') {
- return require('./prepublish')
- }
-
- if (cmd === 'generate-icons') {
- return require('./generate-icons')
- }
-
- console.log(
- `
- Usage: dnb-ui-lib
-
- - ${chalk.green('build')} - build site for production
-
- Options:
-
- -v, --version output the version number
- `
- )
-}
-run()
diff --git a/packages/dnb-ui-lib/scripts/commands/generate-icons.js b/packages/dnb-ui-lib/scripts/commands/generate-icons.js
deleted file mode 100644
index 4d893367146..00000000000
--- a/packages/dnb-ui-lib/scripts/commands/generate-icons.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * CLI Commands
- *
- */
-
-process.on('unhandledRejection', err => {
- throw err
-})
-
-import { convertSvgToJsx } from '../prepub/index'
-
-const run = async () => {
- await convertSvgToJsx()
- return true
-}
-run()
diff --git a/packages/dnb-ui-lib/scripts/commands/index.js b/packages/dnb-ui-lib/scripts/commands/index.js
deleted file mode 100644
index 11f29cdc250..00000000000
--- a/packages/dnb-ui-lib/scripts/commands/index.js
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * CLI Commands
- *
- */
-
-require('babel-core/register')
-require('babel-polyfill')
-require('./commands.js')
diff --git a/packages/dnb-ui-lib/scripts/commands/prepublish.js b/packages/dnb-ui-lib/scripts/commands/prepublish.js
deleted file mode 100644
index 78875999105..00000000000
--- a/packages/dnb-ui-lib/scripts/commands/prepublish.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * CLI Commands
- *
- */
-
-// Do this as the first thing so that any code reading it knows the right env.
-// process.env.BABEL_ENV = 'production'
-// process.env.NODE_ENV = 'production'
-
-// Makes the script crash on unhandled rejections instead of silently
-// ignoring them. In the future, promise rejections that are not handled will
-// terminate the Node.js process with a non-zero exit code.
-process.on('unhandledRejection', err => {
- throw err
-})
-
-// const argv = process.argv.slice(3)
-
-import { runPrepublishTasks } from '../prepub/index'
-runPrepublishTasks({ preventDelete: false })
diff --git a/packages/dnb-ui-lib/scripts/figma/FigmaAPI.js b/packages/dnb-ui-lib/scripts/figma/FigmaAPI.js
index e0d4b807086..5b81fce4c6e 100644
--- a/packages/dnb-ui-lib/scripts/figma/FigmaAPI.js
+++ b/packages/dnb-ui-lib/scripts/figma/FigmaAPI.js
@@ -6,7 +6,7 @@
import { ConvertAndSaveComponentsStyle } from './tasks/componentsStyleConverter'
// import { FetchImages } from './tasks/imageStore'
import { IconsConverter } from './tasks/iconsConverter'
-import { getBranchName } from './../tools/commitToBranch'
+import { getBranchName } from './../prepub/commitToBranch'
import { log, ErrorHandler } from '../lib'
import { getFigmaDoc } from './helpers/docHelpers'
diff --git a/packages/dnb-ui-lib/scripts/figma/helpers/docHelpers.js b/packages/dnb-ui-lib/scripts/figma/helpers/docHelpers.js
index d480fe87637..0288a0bd052 100644
--- a/packages/dnb-ui-lib/scripts/figma/helpers/docHelpers.js
+++ b/packages/dnb-ui-lib/scripts/figma/helpers/docHelpers.js
@@ -207,7 +207,7 @@ export const getFigmaDoc = async ({
forceRefetch = null,
preventUpdate = null
} = {}) => {
- if (!figmaFile) {
+ if (!(figmaFile && String(figmaFile).length > 0)) {
figmaFile = defaultFigmaFile
}
diff --git a/packages/dnb-ui-lib/scripts/figma/tasks/commitChanges.js b/packages/dnb-ui-lib/scripts/figma/tasks/commitChanges.js
index fc0134d6b00..84f0e9fcad2 100644
--- a/packages/dnb-ui-lib/scripts/figma/tasks/commitChanges.js
+++ b/packages/dnb-ui-lib/scripts/figma/tasks/commitChanges.js
@@ -3,7 +3,7 @@
*
*/
-import { commitToBranch } from '../../tools/commitToBranch'
+import { commitToBranch } from '../../prepub/commitToBranch'
if (require.main === module) {
commitToBranch({
diff --git a/packages/dnb-ui-lib/scripts/figma/tasks/iconsConverter.js b/packages/dnb-ui-lib/scripts/figma/tasks/iconsConverter.js
index 5bb233242fc..2e3d593d6c8 100644
--- a/packages/dnb-ui-lib/scripts/figma/tasks/iconsConverter.js
+++ b/packages/dnb-ui-lib/scripts/figma/tasks/iconsConverter.js
@@ -103,7 +103,11 @@ const runFrameIconsFactory = async ({
// select all icons in the frame
const frameDocChildren = iconSelector
? findAllNodes(frameDoc, { name: new RegExp(iconSelector) })
- : frameDoc.children
+ : // using frameDoc.children only is possible,
+ // but once an icon has a frame inside, we have to make sure that this not happens
+ findAllNodes(frameDoc, { type: 'COMPONENT' }) || frameDoc.children
+
+ console.log('frameDocChildren', frameDocChildren)
// get a list of icons we want to refetch
const iconIdsFromDoc = frameDocChildren.reduce((acc, { id, name }) => {
@@ -114,7 +118,7 @@ const runFrameIconsFactory = async ({
// also skip if there are too many underlines
// because too many underlines will probably indicate that it is not menat to have it inside
- const iconName = prepareIconName(name, iconNameAdditions)
+ const iconName = prerenderIconName(name, iconNameAdditions)
if (iconName.split(/_/g).length > 4) {
log.fail(
`${iconName} was skipped, cause it had more than 4 parts on name split by _`
@@ -178,7 +182,7 @@ const runFrameIconsFactory = async ({
async ([id, url]) => {
try {
const { name } = frameDocChildren.find(({ id: i }) => i === id)
- const iconName = prepareIconName(name, iconNameAdditions)
+ const iconName = prerenderIconName(name, iconNameAdditions)
// deifine the filePath
const file = path.resolve(iconsDest, iconName)
@@ -246,7 +250,7 @@ const runFrameIconsFactory = async ({
return listOfProcessedIcons
}
-const prepareIconName = (name, iconNameAdditions = []) => {
+const prerenderIconName = (name, iconNameAdditions = []) => {
let iconName = name
// in case Icons have "[NAME] ..." somewhere
diff --git a/packages/dnb-ui-lib/scripts/figma/version.lock b/packages/dnb-ui-lib/scripts/figma/version.lock
index 1e2d22018dc..cb984179d13 100644
--- a/packages/dnb-ui-lib/scripts/figma/version.lock
+++ b/packages/dnb-ui-lib/scripts/figma/version.lock
@@ -1 +1 @@
-{"1a3caba565dddc0a936aaddc29a82887":"106241935"}
\ No newline at end of file
+{"1a3caba565dddc0a936aaddc29a82887":"107683503"}
\ No newline at end of file
diff --git a/packages/dnb-ui-lib/scripts/lib/error.js b/packages/dnb-ui-lib/scripts/lib/error.js
index 021a98251d5..f30882da58c 100644
--- a/packages/dnb-ui-lib/scripts/lib/error.js
+++ b/packages/dnb-ui-lib/scripts/lib/error.js
@@ -6,11 +6,11 @@
export const ERROR_HARMLESS = 100
export const ERROR_FATAL = 500
-export const ErrorHandler = (
+function ErrorHandler(
error,
{ message } = { message: null },
code = ERROR_HARMLESS
-) => {
+) {
if (typeof error === 'object') {
message = error.message
}
@@ -21,3 +21,6 @@ export const ErrorHandler = (
console.log(err)
}
}
+ErrorHandler.prototype.constructor = function() {}
+
+export { ErrorHandler }
diff --git a/packages/dnb-ui-lib/scripts/prepub/audit/prepareForAudit.js b/packages/dnb-ui-lib/scripts/prepub/audit/prepareForAudit.js
new file mode 100644
index 00000000000..8ed134e8ee4
--- /dev/null
+++ b/packages/dnb-ui-lib/scripts/prepub/audit/prepareForAudit.js
@@ -0,0 +1,78 @@
+/**
+ * Because of an Yarn bug, where devDependencies do not get checked by audit,
+ * we rename devDependencies to optionalDependencies and visaversa
+ *
+ */
+
+import path from 'path'
+import fs from 'fs-extra'
+import packpath from 'packpath'
+import prettier from 'prettier'
+
+// if (require.main === module) {
+// renameDependencies('auto')
+// }
+
+function renameDependencies(direction = 'auto') {
+ new Promise(async (resolve, reject) => {
+ const filepath = path.resolve(packpath.self(), './package.json')
+ const packageJson = JSON.parse(
+ (await fs.readFile(filepath)).toString()
+ )
+
+ if (direction === 'auto' && packageJson.devDependencies) {
+ direction = 'fromDevToOpt'
+ }
+
+ try {
+ switch (direction) {
+ case 'fromDevToOpt':
+ {
+ if (packageJson.devDependencies) {
+ packageJson.optionalDependencies =
+ packageJson.devDependencies
+ delete packageJson.devDependencies
+ } else
+ throw new Error(
+ 'Could not rename pkg key! There has to exist: devDependencies'
+ )
+ }
+ break
+ default:
+ case 'fromOptToDev':
+ {
+ if (packageJson.optionalDependencies) {
+ packageJson.devDependencies =
+ packageJson.optionalDependencies
+ delete packageJson.optionalDependencies
+ } else
+ throw new Error(
+ 'Could not rename pkg key! There has to exist: optionalDependencies'
+ )
+ }
+ break
+ }
+ } catch (e) {
+ reject(e)
+ }
+
+ const prettierrc = JSON.parse(
+ await fs.readFile(
+ path.resolve(packpath.self(), '.prettierrc'),
+ 'utf-8'
+ )
+ )
+
+ const newPackageJson = JSON.stringify(packageJson, null, 2)
+ const formattedPackageJson = prettier.format(newPackageJson, {
+ ...prettierrc,
+ filepath
+ })
+
+ await fs.writeFile(filepath, formattedPackageJson)
+
+ resolve()
+ })
+}
+
+export default renameDependencies
diff --git a/packages/dnb-ui-lib/scripts/prepub/audit/toDev.js b/packages/dnb-ui-lib/scripts/prepub/audit/toDev.js
new file mode 100644
index 00000000000..93b137c981b
--- /dev/null
+++ b/packages/dnb-ui-lib/scripts/prepub/audit/toDev.js
@@ -0,0 +1,9 @@
+/**
+ * Because of an Yarn bug, where devDependencies do not get checked by audit,
+ * we rename devDependencies to optionalDependencies and visaversa
+ *
+ */
+
+import prepareForAudit from './prepareForAudit'
+
+prepareForAudit('fromOptToDev')
diff --git a/packages/dnb-ui-lib/scripts/prepub/audit/toOpt.js b/packages/dnb-ui-lib/scripts/prepub/audit/toOpt.js
new file mode 100644
index 00000000000..fd4080f4476
--- /dev/null
+++ b/packages/dnb-ui-lib/scripts/prepub/audit/toOpt.js
@@ -0,0 +1,9 @@
+/**
+ * Because of an Yarn bug, where devDependencies do not get checked by audit,
+ * we rename devDependencies to optionalDependencies and visaversa
+ *
+ */
+
+import prepareForAudit from './prepareForAudit'
+
+prepareForAudit('fromDevToOpt')
diff --git a/packages/dnb-ui-lib/scripts/tools/commitToBranch.js b/packages/dnb-ui-lib/scripts/prepub/commitToBranch.js
similarity index 100%
rename from packages/dnb-ui-lib/scripts/tools/commitToBranch.js
rename to packages/dnb-ui-lib/scripts/prepub/commitToBranch.js
diff --git a/packages/dnb-ui-lib/scripts/prepub/tasks/__tests__/makeMainStyle.test.js b/packages/dnb-ui-lib/scripts/prepub/tasks/__tests__/makeMainStyle.test.js
index 36351288dd7..84fc7beac5c 100644
--- a/packages/dnb-ui-lib/scripts/prepub/tasks/__tests__/makeMainStyle.test.js
+++ b/packages/dnb-ui-lib/scripts/prepub/tasks/__tests__/makeMainStyle.test.js
@@ -4,9 +4,14 @@
*/
import { runFactory } from '../makeMainStyle'
+import '../../../../src/style/dnb-ui-core.scss' // just to make sure we re-run the test in watch mode due to changes in this file
import '../../../../src/style/dnb-ui-components.scss' // just to make sure we re-run the test in watch mode due to changes in this file
+import '../../../../src/style/themes/dnb-theme-ui.scss' // just to make sure we re-run the test in watch mode due to changes in this file
beforeAll(async () => {
+ global.core = await runFactory('./src/style/dnb-ui-core.scss', {
+ returnResult: true
+ })
global.components = await runFactory(
'./src/style/dnb-ui-components.scss',
{
@@ -18,12 +23,12 @@ beforeAll(async () => {
})
})
-describe('makeMainStyle transform components SASS to CSS', () => {
+describe('makeMainStyle transform core SASS to CSS', () => {
it('has to contain a button selector', () => {
expect(global.components).toContain('.dnb-button {')
})
- it('has to have correct components path to fonts', () => {
- expect(global.components).toContain('"../assets/fonts/')
+ it('has to have correct core path to fonts', () => {
+ expect(global.core).toContain('"../assets/fonts/')
})
})
diff --git a/packages/dnb-ui-lib/scripts/prepub/tasks/makeMainStyle.js b/packages/dnb-ui-lib/scripts/prepub/tasks/makeMainStyle.js
index beead7a4821..29fe4fc21b8 100644
--- a/packages/dnb-ui-lib/scripts/prepub/tasks/makeMainStyle.js
+++ b/packages/dnb-ui-lib/scripts/prepub/tasks/makeMainStyle.js
@@ -23,7 +23,7 @@ export default async () => {
await runFactory('./src/style/**/themes/*.scss', { importOnce: false })
await runFactory('./src/style/**/dnb-ui-components.scss')
await runFactory('./src/style/**/dnb-ui-patterns.scss')
- await runFactory('./src/style/**/dnb-ui-lib.scss')
+ await runFactory('./src/style/**/dnb-ui-core.scss')
log.succeed(
'> PrePublish: "makeMainStyle" transforming style modules done'
)
diff --git a/packages/dnb-ui-lib/scripts/prepub/tasks/styleFactory.js b/packages/dnb-ui-lib/scripts/prepub/tasks/styleFactory.js
index d49a5a3dca8..c0a4d1b61db 100644
--- a/packages/dnb-ui-lib/scripts/prepub/tasks/styleFactory.js
+++ b/packages/dnb-ui-lib/scripts/prepub/tasks/styleFactory.js
@@ -31,7 +31,7 @@ const runStyleFactory = async () => {
'../../../src/style/dnb-ui-components.scss'
),
customContent: `
-@import './core/dnb-core.scss';
+@import './core/utilities.scss';
`,
scssTemplateToFill: `@import '../components/{name}/style/_{name}.scss';`,
processToNamesList: [
@@ -55,7 +55,7 @@ const runStyleFactory = async () => {
'../../../src/style/dnb-ui-patterns.scss'
),
customContent: `
-@import './core/dnb-core.scss';
+@import './core/utilities.scss';
`,
scssTemplateToFill: `@import '../patterns/{name}/style/_{name}.scss';`,
processToNamesList: [
diff --git a/packages/dnb-ui-lib/src/__tests__/assets/images/Logo.test.js b/packages/dnb-ui-lib/src/__tests__/assets/images/Logo.screenshot.test.js
similarity index 100%
rename from packages/dnb-ui-lib/src/__tests__/assets/images/Logo.test.js
rename to packages/dnb-ui-lib/src/__tests__/assets/images/Logo.screenshot.test.js
diff --git a/packages/dnb-ui-lib/src/__tests__/assets/images/__snapshots__/logo-test-js-logo-image-have-to-match-image-snapshot-1-37d94.snap.png b/packages/dnb-ui-lib/src/__tests__/assets/images/__snapshots__/logo-screenshot-test-js-logo-image-have-to-match-image-snapshot-1-49ee6.snap.png
similarity index 100%
rename from packages/dnb-ui-lib/src/__tests__/assets/images/__snapshots__/logo-test-js-logo-image-have-to-match-image-snapshot-1-37d94.snap.png
rename to packages/dnb-ui-lib/src/__tests__/assets/images/__snapshots__/logo-screenshot-test-js-logo-image-have-to-match-image-snapshot-1-49ee6.snap.png
diff --git a/packages/dnb-ui-lib/src/components/button/Button.js b/packages/dnb-ui-lib/src/components/button/Button.js
index 7c0f79df75c..3e5fac22781 100644
--- a/packages/dnb-ui-lib/src/components/button/Button.js
+++ b/packages/dnb-ui-lib/src/components/button/Button.js
@@ -24,6 +24,7 @@ export const propTypes = {
text: PropTypes.string,
type: PropTypes.string,
title: PropTypes.string,
+ /* _(optional)_ defines the kind of button. Possible values are `primary`, `secondary`, `tertiary` and `signal`. */
variant: PropTypes.oneOf(['primary', 'secondary', 'tertiary', 'signal']),
size: PropTypes.oneOf(['default', 'small', 'medium', 'large']),
icon: PropTypes.oneOfType([
@@ -174,7 +175,7 @@ export default class Button extends PureComponent {
const classes = classnames(
'dnb-button',
- `dnb-button--${usedVariant}`,
+ `dnb-button--${usedVariant || 'primary'}`,
usedSize && usedSize !== 'default'
? `dnb-button--size-${usedSize}`
: null,
@@ -186,21 +187,23 @@ export default class Button extends PureComponent {
id,
class_name,
className,
- href ? 'dnb-no-anchor-underline dnb-no-anchor-hover' : null
+ href ? '' : null // dnb-no-anchor-underline dnb-no-anchor-hover
)
const params = {
...this.renderProps,
className: classes,
type,
- title: title || text,
- ['aria-label']: title || text,
+ title,
id,
disabled,
onMouseOut: this.onMouseOutHandler, // for resetting the button to the default state
onClick: this.onClickHandler,
...props
}
+ if (!params['aria-label'] && !text && title) {
+ params['aria-label'] = title
+ }
// also used for code markup simulation
validateDOMAttributes(this.props, params)
@@ -279,7 +282,7 @@ class Content extends PureComponent {
icon={icon}
size={icon_size}
alt={alt}
- aria_hidden={isIconOnly ? false : Boolean(alt)}
+ aria-hidden={isIconOnly ? false : Boolean(alt)}
/>
)
}
diff --git a/packages/dnb-ui-lib/src/components/button/Example.js b/packages/dnb-ui-lib/src/components/button/Example.js
deleted file mode 100644
index 3926ba29197..00000000000
--- a/packages/dnb-ui-lib/src/components/button/Example.js
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * UI lib Component Example
- *
- */
-
-import React, { PureComponent, Fragment } from 'react'
-import Button from './Button'
-import styled from '@emotion/styled'
-import { bell_medium as Bell, question } from '../../../icons'
-
-class Example extends PureComponent {
- clickHandler = () => {
- alert('You clicked a button with a click function attached to it')
- }
- render() {
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Button with Icon only
-
-
-
-
-
- }
- icon_size="medium"
- disabled
- />
-
-
- )
- }
-}
-
-const Wrapper = styled.div`
- display: block;
- width: 100%;
-`
-
-export { Example }
-export default () => (
-
-
-
-)
diff --git a/packages/dnb-ui-lib/src/components/button/__tests__/Button.screenshot.test.js b/packages/dnb-ui-lib/src/components/button/__tests__/Button.screenshot.test.js
new file mode 100644
index 00000000000..1e3b6678d72
--- /dev/null
+++ b/packages/dnb-ui-lib/src/components/button/__tests__/Button.screenshot.test.js
@@ -0,0 +1,29 @@
+/**
+ * Screenshot Test
+ * This file will not run on "test:staged" because we dont require any related files
+ */
+
+import {
+ setupPageScreenshot,
+ testPageScreenshot
+} from '../../../core/jest/jestSetupScreenshots'
+
+setupPageScreenshot()
+
+describe('Button screenshot', () => {
+ it('have to match the "dnb-button--primary" screenshot snapshot', async () => {
+ const screenshot = await testPageScreenshot({
+ url: '/uilib/components/button?fullscreen',
+ selector: '.example-box .dnb-button.dnb-button--primary:nth-child(1)'
+ })
+ expect(screenshot).toMatchImageSnapshot()
+ })
+ it('have to match the "dnb-button--secondary" screenshot snapshot', async () => {
+ const screenshot = await testPageScreenshot({
+ url: '/uilib/components/button?fullscreen',
+ selector:
+ '.example-box .dnb-button.dnb-button--secondary:nth-child(1)'
+ })
+ expect(screenshot).toMatchImageSnapshot()
+ })
+})
diff --git a/packages/dnb-ui-lib/src/components/button/__tests__/Screenshot.test.js b/packages/dnb-ui-lib/src/components/button/__tests__/Screenshot.test.js
deleted file mode 100644
index 65a1bd78e06..00000000000
--- a/packages/dnb-ui-lib/src/components/button/__tests__/Screenshot.test.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Component Test
- *
- */
-
-// import React from 'react'
-import { setupPageScreenshot } from '../../../core/jest/jestSetup'
-
-describe.skip('Button screenshot', () => {
- setupPageScreenshot({ timeout: 10e3 })
-
- it('have to match the primary button screenshot snapshot', async () => {
- // more info: github.com/GoogleChrome/puppeteer/blob/master/docs/api.md
- await global.page.goto(
- 'https://eufemia.dnb.no/uilib/components/button/?fullscreen#demo'
- // 'http://localhost:8000/uilib/components/button/?fullscreen#demo'
- )
- const selector =
- '.dnb-button.dnb-button--primary.dnb-button--has-text.dnb-button--has-icon'
- await global.page.waitForSelector(selector)
- const element = await global.page.$(selector)
- await element.$eval(
- '.dnb-button__text',
- node => (node.innerText = 'MASTER')
- )
-
- // await element.hover()
- // await element.click()
- // await element.press('Tab') // to simulate pressing tab key before focus
- // await element.focus()
-
- expect(await element.screenshot()).toMatchImageSnapshot()
- })
-
- it.skip('have to match the .button-wrapper', async () => {
- // to use this test, put this first in the Button Example
- /*
-
- -> Syntax
-