-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
528f3c9
commit 476e2de
Showing
22 changed files
with
403 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
packages/dnb-design-system-portal/src/pages/uilib/components/progress.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: 'Progress' | ||
draft: false | ||
order: 12 | ||
--- | ||
|
||
import Tabs from 'Tags/Tabs' | ||
|
||
import ProgressInfo from 'Pages/uilib/components/progress/progress-info' | ||
import ProgressProperties from 'Pages/uilib/components/progress/progress-properties' | ||
import ProgressEvents from 'Pages/uilib/components/progress/progress-events' | ||
|
||
# Progress | ||
|
||
<Tabs> | ||
<Tabs.Content> | ||
<ProgressInfo /> | ||
</Tabs.Content> | ||
<Tabs.Content> | ||
<ProgressProperties /> | ||
</Tabs.Content> | ||
<Tabs.Content> | ||
<ProgressEvents /> | ||
</Tabs.Content> | ||
</Tabs> |
29 changes: 29 additions & 0 deletions
29
packages/dnb-design-system-portal/src/pages/uilib/components/progress/Examples.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* UI lib Component Example | ||
* | ||
*/ | ||
|
||
import React, { PureComponent, Fragment } from 'react' | ||
import ComponentBox from '../../../../shared/tags/ComponentBox' | ||
|
||
class Example extends PureComponent { | ||
clickHandler = () => { | ||
alert('You clicked a button with a click function attached to it') | ||
} | ||
render() { | ||
return ( | ||
<Fragment> | ||
<ComponentBox> | ||
{/* @jsx */ ` | ||
<Button | ||
text="Primary button with text only" | ||
data-dnb-test="button-primary" | ||
/> | ||
`} | ||
</ComponentBox> | ||
</Fragment> | ||
) | ||
} | ||
} | ||
|
||
export default Example |
9 changes: 9 additions & 0 deletions
9
...dnb-design-system-portal/src/pages/uilib/components/progress/progress-events.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
draft: true | ||
--- | ||
|
||
## Events | ||
|
||
| Events | Description | | ||
| ------------- | -------------------------------------------------------------- | | ||
| `on_complete` | _(optional)_ will be called once the `min_time` has timed out. | |
17 changes: 17 additions & 0 deletions
17
...s/dnb-design-system-portal/src/pages/uilib/components/progress/progress-info.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
draft: true | ||
--- | ||
|
||
import Examples from 'Pages/uilib/components/progress/Examples' | ||
|
||
## Description | ||
|
||
Use a progress whenever the user has to wait for more than _150ms_. This component is also knows as: | ||
|
||
- Indicator (Activity-Indicator) | ||
- Loader (Pre-loader) | ||
- Spinner | ||
|
||
## Demos | ||
|
||
<Examples /> |
15 changes: 15 additions & 0 deletions
15
...design-system-portal/src/pages/uilib/components/progress/progress-properties.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
draft: true | ||
--- | ||
|
||
## Properties | ||
|
||
| Properties | Description | | ||
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `label` | _(optional)_ if a text label is needed. Defaults to `null`. | | ||
| `visible` | _(optional)_ defines the visibility of the progress. Toggeling the `visible` property to false will force a fade-out animation. Defaults to `true`. | | ||
| `type` | _(optional)_ defines the **type** of progress, like `circular`. Defaults to `circular`. | | ||
| `no_animation` | _(optional)_ disables the fade-in and fade-out animation. Defaults to false. | | ||
| `min_time` | _(optional)_ defines the minimum time the progress should be displayed. Defaults to `null`. | | ||
| `variant` | _(optional)_ defines the color variant, like `primary` or `secondary`. Defaults to `primary`. | | ||
| `size` | _(optional)_ defines the size, like `large` or `medium`. Defaults to `medium`. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* ATTENTION: This file is auto generated by using "prepareTemplates". | ||
* Do not change the content! | ||
* | ||
*/ | ||
|
||
/** | ||
* Library Index progress to autogenerate all the components and patterns | ||
* Used by "prepareProgresss" | ||
*/ | ||
|
||
import Progress from './progress/Progress' | ||
export * from './progress/Progress' | ||
export default Progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
packages/dnb-ui-lib/src/components/progress/Progress.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/** | ||
* Web Progress Component | ||
* | ||
*/ | ||
|
||
import React, { PureComponent } from 'react' | ||
import PropTypes from 'prop-types' | ||
// import classnames from 'classnames' | ||
// import keycode from 'keycode' | ||
import { | ||
registerElement | ||
// validateDOMAttributes, | ||
// dispatchCustomElementEvent | ||
} from '../../shared/component-helper' | ||
import ProgressCircular from './ProgressCircular' | ||
|
||
const renderProps = { | ||
render: null | ||
} | ||
|
||
export const propTypes = { | ||
label: PropTypes.string, | ||
visible: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), | ||
type: PropTypes.oneOf(['circular']), | ||
no_animation: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), | ||
min_time: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
variant: PropTypes.oneOf(['primary', 'secondary']), | ||
size: PropTypes.oneOf(['large', 'medium']), | ||
// id: PropTypes.string, | ||
// class: PropTypes.string, | ||
/** React props */ | ||
className: PropTypes.string, | ||
children: PropTypes.oneOfType([ | ||
PropTypes.object, | ||
PropTypes.node, | ||
PropTypes.func | ||
]), | ||
|
||
// Web Component props | ||
render: PropTypes.func | ||
} | ||
|
||
export const defaultProps = { | ||
label: null, | ||
visible: true, | ||
type: 'circular', | ||
no_animation: false, | ||
min_time: null, | ||
variant: 'primary', | ||
size: 'medium', | ||
// id: null, | ||
// class: null, | ||
|
||
/** React props */ | ||
className: null, | ||
children: null, | ||
|
||
// Web Component props | ||
...renderProps | ||
} | ||
|
||
export default class Progress extends PureComponent { | ||
static tagName = 'dnb-progress' | ||
static propTypes = propTypes | ||
static defaultProps = defaultProps | ||
|
||
static enableWebComponent() { | ||
registerElement(Progress.tagName, Progress, defaultProps) | ||
} | ||
|
||
static getDerivedStateFromProps(props, state) { | ||
if (state._listenForPropChanges) { | ||
if (props.visible && state._visible !== props.visible) { | ||
state.visible = state._visible = props.visible | ||
} | ||
} | ||
state._listenForPropChanges = true | ||
return state | ||
} | ||
|
||
constructor(props) { | ||
super(props) | ||
|
||
// this._id = | ||
// props.id || `dnb-progress-${Math.round(Math.random() * 999)}` // cause we need an id anyway | ||
|
||
const visible = Boolean(props.visible) | ||
this.state = { | ||
_listenForPropChanges: true, | ||
visible, | ||
_visible: visible | ||
} | ||
|
||
// this._tablistRef = React.createRef() | ||
} | ||
|
||
render() { | ||
const { | ||
visible: _visible //eslint-disable-line | ||
// ...props | ||
} = this.props | ||
|
||
// const { visible } = this.state | ||
|
||
return ( | ||
<div className="dnb-progress"> | ||
<ProgressCircular /> | ||
</div> | ||
) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/dnb-ui-lib/src/components/progress/ProgressCircular.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Web Progress Component | ||
* | ||
*/ | ||
|
||
import React, { PureComponent } from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
export default class ProgressCircular extends PureComponent { | ||
render() { | ||
return ( | ||
<div className="dnb-progress__circular"> | ||
<Circle className="dnb-progress__circular__bg" /> | ||
<Circle className="dnb-progress__circular__line" /> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
const Circle = ({ className }) => ( | ||
<svg className={className} viewBox="0 0 50 50"> | ||
<circle | ||
className="dnb-progress__circular__circle" | ||
fill="none" | ||
strokeWidth="4" | ||
cx="25" | ||
cy="25" | ||
r="20" | ||
/> | ||
</svg> | ||
) | ||
Circle.propTypes = { | ||
className: PropTypes.string.isRequired | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Component Entry | ||
* | ||
*/ | ||
|
||
import Progress from './Progress' | ||
export default Progress | ||
export * from './Progress' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Web Style Import | ||
* | ||
*/ | ||
|
||
import './style/dnb-progress.scss' |
72 changes: 72 additions & 0 deletions
72
packages/dnb-ui-lib/src/components/progress/style/_progress.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Progress component | ||
* | ||
*/ | ||
|
||
:root { | ||
--progress-circular-circle: 130; | ||
--progress-circular-circle--nreg: -130; | ||
} | ||
|
||
.dnb-progress { | ||
position: relative; | ||
|
||
// circular variant | ||
&__circular { | ||
position: relative; | ||
|
||
width: 20rem; | ||
height: 20rem; | ||
|
||
// since SVG is starting 90deg from top | ||
transform: rotate(-90deg); | ||
|
||
svg { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
&__line { | ||
stroke-dasharray: 0, var(--progress-circular-circle); | ||
stroke-dashoffset: 0; | ||
|
||
// animation details | ||
animation-name: progress-circular-line; | ||
animation-duration: 1.5s; | ||
animation-delay: 200ms; | ||
animation-iteration-count: infinite; | ||
animation-timing-function: linear; | ||
|
||
opacity: 0; | ||
} | ||
|
||
&__circle { | ||
stroke-linecap: round; | ||
stroke: var(--color-emerald-green); | ||
} | ||
&__line &__circle { | ||
stroke: var(--color-mint-green); | ||
} | ||
} | ||
} | ||
|
||
@keyframes progress-circular-line { | ||
0% { | ||
stroke-dasharray: 0, var(--progress-circular-circle); | ||
stroke-dashoffset: 0; | ||
opacity: 1; | ||
} | ||
50% { | ||
stroke-dasharray: var(--progress-circular-circle), | ||
var(--progress-circular-circle); | ||
stroke-dashoffset: 0; | ||
opacity: 1; | ||
} | ||
100% { | ||
stroke-dasharray: var(--progress-circular-circle), | ||
var(--progress-circular-circle); | ||
stroke-dashoffset: var(--progress-circular-circle--nreg); | ||
opacity: 1; | ||
} | ||
} |
Oops, something went wrong.