Skip to content

Commit

Permalink
feat: enhance themes usage and the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Feb 5, 2019
1 parent 526b5cd commit 1e07ec2
Show file tree
Hide file tree
Showing 23 changed files with 450 additions and 200 deletions.
18 changes: 11 additions & 7 deletions packages/dnb-design-system-portal/src/pages/design-system/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,36 @@ status: null
order: 1
---

<!--
ATTENTION: This file is auto generated by using "makeDemosFactory".
Do not change the content!
-->
import Tabs from 'Tags/Tabs'
import ComponentBox from 'Tags/ComponentBox'
import Description from 'Pages/uilib/components/button/description'
import Details from 'Pages/uilib/components/button/details'
import Demos from 'Pages/uilib/components/button/Examples'

import ButtonPage from 'Src/uilib/components/demos/Button'
# Button

<ButtonPage />
<Tabs>
<Tabs.Content>
<Description />
<h2>Demos</h2>
<Demos />
</Tabs.Content>
<Tabs.Content>
<Details />
<ComponentBox caption="Test">
{`
<Button
text="Secondary button with text only 2"
variant="secondary"
title="This is a button title"
/>
`}
</ComponentBox>
</Tabs.Content>
<Tabs.Content title="Markup">
<h2>H2</h2>
</Tabs.Content>
</Tabs>

<!-- import ButtonPage from 'Src/uilib/components/demos/Button' -->
<!-- <ButtonPage /> -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/**
* UI lib Component Example
*
*/

import React, { PureComponent, Fragment } from 'react'
import styled from '@emotion/styled'
import Button from 'dnb-ui-lib/src/components/button'
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 (
<Fragment>
<div className="example-box">
<Button
text="Primary button with text only"
title="This is a button title"
on_click={this.clickHandler}
attributes={{
'data-fake:on_click': 'clickme()'
}}
/>
</div>
<div className="example-box">
<Button
text="Secondary button with text only"
variant="secondary"
title="This is a button title"
/>
</div>
<div className="example-box">
<Button
text="Disabled primary button"
title="This is a button title"
disabled
/>
</div>
<div className="example-box">
<Button
text="Disabled secondary button"
variant="secondary"
title="This is a button title"
disabled
/>
</div>
<div className="example-box">
<Button
text="Primary button with icon"
title="This is a button title"
icon="chevron_right"
/>
</div>
<div className="example-box">
<Button
text="Primary button with icon on left"
title="This is a button title"
icon_position="left"
icon="chevron_left"
/>
</div>
<div className="example-box">
<Button
variant="tertiary"
text="Tertiary button with icon on left"
title="This is a button title"
icon_position="left"
icon="chevron_left"
/>
</div>
<div className="example-box">
<Button
variant="tertiary"
text="Tertiary button with icon on left"
title="This is a button title"
icon_position="left"
icon="chevron_left"
disabled
/>
</div>
<div className="example-box">
<Button
text="Primary button with href"
href="?no-cache=1"
title="This is a link"
icon_position="right"
icon="chevron_right"
/>
</div>
<div className="example-box">
<Button
title="Disabled Icon only Button"
icon="calendar"
disabled
/>
<Button title="Button with Icon only" icon="calendar" />
<Button
title="Default sized Button with medium Icon"
icon="calendar"
icon_size="medium"
size="default"
/>
<Button
title="Button with custom, Secondary Icon only"
icon={question}
/>
<p className="example-caption">Button with Icon only</p>
</div>
<div className="example-box">
<Button
variant="signal"
text="Signal Button (large size)"
size="large"
icon={Bell}
icon_size="medium" // medium is equalent to 24, but responsive
/>
</div>
<div className="example-box">
<Button
variant="signal"
text="Disabled Signal Button"
icon={<Bell />}
icon_size="medium"
disabled
/>
</div>
</Fragment>
)
}
}

const Wrapper = styled.div`
display: block;
width: 100%;
`

// export { Example }
export default () => (
<Wrapper>
<Example />
</Wrapper>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
draft: true
---

import Examples from 'Pages/uilib/components/button/Examples'

# Demos

<Examples />
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
draft: true
---

## 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
draft: true
---

| Properties | Description |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `type` | _(optional)_ `button`, `reset` or `submit` for the `type` HTML attribute (default to `button`) . |
| `text` | _(optional)_ the content of the button. |
| `title` | _(optional)_ title of the button. Optional, but should always be included because of accessibility. |
| `variant` | _(optional)_ defines the kind of button. Possible values are `primary`, `secondary`, `tertiary` and `signal`. |
| `size` | _(optional)_ the size of the button. For now there is **medium**, **default** and **large**. |
| `icon` | _(optional)_ name of icon to be included in the button. |
| `icon_position` | _(optional)_ position of icon inside the button. Set to `left` or `right`. Defaults to `right` if not set. |
| `icon_size` | _(optional)_ define icon width and height. Defaults to 16px |
| `disabled` | _(optional)_ to disable/enable the button without using the `attribute` property. |
| `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. |
Empty file.
Original file line number Diff line number Diff line change
@@ -1,17 +1,97 @@
---
title: 'Component Properties'
draft: false
order: 3
order: 6
---

import 'dnb-ui-lib/src/web-components'
import ComponentBox from 'Tags/ComponentBox'
import PropertiesExample from 'Pages/uilib/usage/customisation/examples/properties-example'

# 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

<ComponentBox>
{`
<>
<Button
variant="secondary"
text="Secondary Button"
icon="chevron_right_medium"
size="large"
/>
<Button
icon="chevron_right"
icon_size="medium"
size="large"
/>
</>
`}
</ComponentBox>

## Extended example

<ComponentBox scope={{hamburgerIcon}} noInline={true}>
{`
const Wrapper = styled.div\`
.dnb-button {
--button-width: 4rem;
--button-height: 4rem;
--button-border-radius: 2rem;
svg {
color: fuchsia;
}
}
\`
const myHandler = () => alert('Hello')
render(
<Wrapper>
<Button
variant="secondary"
icon={hamburgerIcon}
size="default"
on_click={myHandler}
/>
<Button
variant="secondary"
size="default"
on_click={myHandler}
>
<Icon icon={hamburgerIcon} />
</Button>
</Wrapper>
)
`}
</ComponentBox>

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

<PropertiesExample />
<ComponentBox noInline={true}>
{`
const Component = () => {
const time = new Date().toLocaleTimeString()
render(
<>
<dnb-form-label for_id="form-input">
Web Component property updates
</dnb-form-label>
<dnb-input id="form-input" value={time} disabled />
</>
)
}
Component()
clearInterval(window.intervalId)
window.intervalId = setInterval(Component, 1e3)
`}
</ComponentBox>
Loading

0 comments on commit 1e07ec2

Please sign in to comment.