Skip to content

Commit 7c5e358

Browse files
committed
feat(StepNavigation): vertical and small StepNavigation added
1 parent 75d9106 commit 7c5e358

File tree

10 files changed

+121
-63
lines changed

10 files changed

+121
-63
lines changed

.storybook/config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import React from 'react';
2-
import { addParameters, configure, addDecorator } from '@storybook/react';
2+
import { configure, addDecorator } from '@storybook/react';
33
import { withInfo } from '@storybook/addon-info';
44
import { withOptions } from '@storybook/addon-options';
5-
import addonAPI from '@storybook/addons';
6-
// import { checkA11y } from 'storybook-addon-a11y';
75

86
import { getStorybook } from '@storybook/react';
97
import withNotes from './wfp-storybook';

src/components/InlineLoading/InlineLoading-story.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import React, { PureComponent } from 'react';
99
import { storiesOf } from '@storybook/react';
1010
import { action } from '@storybook/addon-actions';
11-
1211
import { withKnobs, boolean, number, text } from '@storybook/addon-knobs';
1312

1413
import Button from '../Button';

src/components/StepNavigation/StepNavigation-story.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { storiesOf } from '@storybook/react';
3-
import { withKnobs } from '@storybook/addon-knobs';
3+
import { withKnobs, boolean, number, text } from '@storybook/addon-knobs';
44

55
import StepNavigation from '../StepNavigation';
66
import StepNavigationItem from '../StepNavigationItem';
@@ -9,11 +9,18 @@ const handleTabClick = index => {
99
this.setState({ page: index });
1010
};
1111

12+
const props = () => ({
13+
vertical: boolean('Display vertical (vertical)', false),
14+
small: boolean('Small size (small)', false),
15+
selectedPage: number('Currently selected page (selectedPage)', 1),
16+
handleTabClick: handleTabClick,
17+
});
18+
1219
storiesOf('StepNavigation', module)
1320
.addDecorator(withKnobs)
1421

1522
.add('Default (work in progress)', () => (
16-
<StepNavigation selectedPage={1} handleTabClick={handleTabClick}>
23+
<StepNavigation {...props()}>
1724
<StepNavigationItem label="Item without Status" page={0} />
1825
<StepNavigationItem label="Active Item" page={1} />
1926
<StepNavigationItem

src/components/StepNavigation/StepNavigation.js

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ import PropTypes from 'prop-types';
22
import React from 'react';
33
import classNames from 'classnames';
44

5+
import settings from '../../globals/js/settings';
6+
7+
const { prefix } = settings;
8+
59
export default class StepNavigation extends React.Component {
610
static propTypes = {
711
/**
8-
* Specify the text to be read by screen-readers when visiting the <Tabs>
9-
* component
10-
*/
11-
ariaLabel: PropTypes.string,
12-
13-
/**
14-
* Pass in a collection of <Tab> children to be rendered depending on the
12+
* Pass in a collection of <StepNavigationItem> children to be rendered depending on the
1513
* currently selected tab
1614
*/
1715
children: PropTypes.node,
@@ -29,14 +27,14 @@ export default class StepNavigation extends React.Component {
2927
customTabContent: PropTypes.bool,
3028

3129
/**
32-
* Specify whether the Tabs are displayed inline
30+
* Specify whether the StepNavigation will be displayed small
3331
*/
34-
inline: PropTypes.bool,
32+
small: PropTypes.bool,
3533

3634
/**
37-
* Specify whether the Tab content is hidden
35+
* Specify whether the StepNavigation will be displayed vertically
3836
*/
39-
hidden: PropTypes.bool,
37+
vertical: PropTypes.bool,
4038

4139
/**
4240
* By default, this value is "navigation". You can also provide an alternate
@@ -50,34 +48,16 @@ export default class StepNavigation extends React.Component {
5048
*/
5149
onClick: PropTypes.func,
5250

53-
/**
54-
* Optionally provide an `onKeyDown` handler that is invoked when keyed
55-
* navigation is triggered
56-
*/
57-
onKeyDown: PropTypes.func,
58-
5951
/**
6052
* Provide an optional handler that is called whenever the selection
6153
* changes. This method is called with the index of the tab that was
6254
* selected
6355
*/
6456
onSelectionChange: PropTypes.func,
65-
66-
/**
67-
* Provide a string that represents the `href` for the triggered <Tab>
68-
*/
69-
triggerHref: PropTypes.string.isRequired,
70-
7157
/**
7258
* Optionally provide an index for the currently selected <Tab>
7359
*/
7460
selected: PropTypes.number,
75-
76-
/**
77-
* Provide a description that is read out when a user visits the caret icon
78-
* for the dropdown menu of items
79-
*/
80-
iconDescription: PropTypes.string.isRequired,
8161
};
8262

8363
static defaultProps = {
@@ -180,6 +160,8 @@ export default class StepNavigation extends React.Component {
180160
render() {
181161
const {
182162
inline,
163+
small,
164+
vertical,
183165
className,
184166
role,
185167
selectedPage,
@@ -203,7 +185,12 @@ export default class StepNavigation extends React.Component {
203185
});
204186

205187
const classes = {
206-
tabs: classNames('wfp--step-navigation', className),
188+
tabs: classNames(className, {
189+
[`${prefix}--step-navigation`]: true,
190+
[`${prefix}--step-navigation--vertical`]: vertical,
191+
[`${prefix}--step-navigation--small`]: small,
192+
[`${prefix}--step-navigation--regular`]: !small,
193+
}),
207194
tablist: classNames('wfp--step-navigation__nav', {
208195
'wfp--step-navigation__nav--hidden': this.state.dropdownHidden,
209196
'wfp--step-navigation__nav--inline': inline,

src/components/StepNavigation/_step-navigation.scss

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
display: flex;
3434
align-items: center;
3535
justify-content: space-between;
36-
padding: 0 $spacing-md;
37-
height: rem(40px);
36+
//padding: 0 $spacing-md;
37+
height: 2em;
3838
cursor: pointer;
3939
//background-color: $field-02;
4040

4141
svg {
42-
width: rem(12px);
43-
height: rem(12px);
42+
width: 1em;
43+
height: 1em;
4444
fill: $brand-01;
4545
}
4646

@@ -53,7 +53,6 @@
5353
text-decoration: none;
5454
font-weight: 600;
5555
color: $text-01;
56-
5756
&:focus {
5857
@include focus-outline('border');
5958
}
@@ -98,6 +97,24 @@
9897
}
9998
}
10099

100+
// Small StepNavigation
101+
.#{$prefix}--step-navigation--small {
102+
font-size: 0.5rem;
103+
.#{$prefix}--step-navigation__nav-item__text {
104+
display: none;
105+
}
106+
}
107+
108+
// Vertical StepNavigation
109+
.#{$prefix}--step-navigation--vertical {
110+
ul {
111+
flex-direction: row;
112+
}
113+
.#{$prefix}--step-navigation__nav-item__text {
114+
margin-right: 0.5em;
115+
}
116+
}
117+
101118
// Skeleton state
102119
.#{$prefix}--step-navigation.#{$prefix}--skeleton {
103120
pointer-events: none;

src/components/StepNavigationItem/StepNavigationItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export default class StepNavigationItem extends React.Component {
102102
description="sss"
103103
/>
104104
) : (
105-
<React.Fragment>{page + 1}</React.Fragment>
105+
<span>{page + 1}</span>
106106
)}
107107
</span>
108108
<span className="wfp--step-navigation__nav-item__text">

src/components/StepNavigationItem/_step-navigation-item.scss

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,22 @@
6161
}*/
6262

6363
.#{$prefix}--step-navigation__nav-item__indicator {
64-
display: block;
64+
display: flex;
65+
align-items: center;
66+
justify-content: center;
6567
position: relative;
6668
background: $ui-01;
6769
border: 2px solid $brand-01;
6870
flex-shrink: 0;
69-
border-radius: 34px;
70-
width: rem(34px);
71-
height: rem(34px);
72-
line-height: rem(32px);
73-
margin: 14px rem(14px) 14px rem(5px);
71+
border-radius: 3em;
72+
width: 3em;
73+
height: 3em;
74+
.#{$prefix}--step-navigation--small & {
75+
width: 1.5em;
76+
height: 1.5em;
77+
}
78+
line-height: 1em;
79+
margin: 0.7em 1em 0.7em 0;
7480
text-align: center;
7581
z-index: 2;
7682
color: $brand-01;
@@ -79,16 +85,38 @@
7985
position: relative;
8086
top: 1px;
8187
fill: $brand-01;
88+
width: 1em;
89+
height: 1em;
90+
.#{$prefix}--step-navigation--small & {
91+
width: 0.8em;
92+
height: 0.8em;
93+
}
8294
}
8395
&:after {
8496
display: block;
8597
width: 2px;
86-
height: 22px;
98+
height: 1.1em;
99+
bottom: 3em;
100+
.#{$prefix}--step-navigation--small & {
101+
bottom: 1.5em;
102+
}
103+
.#{$prefix}--step-navigation--vertical.#{$prefix}--step-navigation--regular
104+
& {
105+
display: none;
106+
}
107+
.#{$prefix}--step-navigation--vertical.#{$prefix}--step-navigation--small
108+
& {
109+
height: 2px;
110+
width: 1em;
111+
left: inherit;
112+
right: 1.5em;
113+
bottom: 50%;
114+
}
87115
position: absolute;
88116
z-index: 1;
89117
//z-index: -1px;
90-
bottom: rem(35px);
91-
left: 53%;
118+
119+
left: calc(50% - 0px);
92120
margin-left: -1px;
93121
content: '';
94122
background: $ui-04;
@@ -109,7 +137,7 @@
109137
}
110138

111139
@include breakpoint(bp--sm--major) {
112-
padding: 0 $spacing-3xs;
140+
padding: 0 0.2em;
113141
width: auto;
114142
&:focus {
115143
background-color: transparent;
@@ -151,6 +179,14 @@
151179

152180
.#{$prefix}--step-navigation__nav-item--warning {
153181
.#{$prefix}--step-navigation__nav-item__indicator {
182+
.#{$prefix}--step-navigation--small & {
183+
border-color: $support-03;
184+
background: $support-03;
185+
> svg {
186+
top: -0.05em;
187+
fill: $ui-01 !important;
188+
}
189+
}
154190
> svg {
155191
fill: $support-03 !important;
156192
}
@@ -168,6 +204,13 @@
168204

169205
.#{$prefix}--step-navigation__nav-item--complete {
170206
.#{$prefix}--step-navigation__nav-item__indicator {
207+
.#{$prefix}--step-navigation--small & {
208+
border-color: $support-02;
209+
background: $support-02;
210+
> svg {
211+
fill: $ui-01 !important;
212+
}
213+
}
171214
> svg {
172215
fill: $support-02 !important;
173216
position: relative;
@@ -212,15 +255,17 @@
212255
}
213256
.#{$prefix}--step-navigation__nav-item__indicator {
214257
border-color: $ui-04;
215-
clip-path: polygon(
216-
0 -100%,
217-
56% -100%,
218-
56% 14%,
219-
93% 50%,
220-
56% 90%,
221-
56% 100%,
222-
0 100%
223-
);
258+
.#{$prefix}--step-navigation--regular & {
259+
clip-path: polygon(
260+
0 -100%,
261+
56% -100%,
262+
56% 14%,
263+
93% 50%,
264+
56% 90%,
265+
56% 100%,
266+
0 100%
267+
);
268+
}
224269
> svg {
225270
top: 0px;
226271
fill: $ui-05 !important;

src/components/Table/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { TablePagination } from '@wfp/ui';
1111
// Replacing the Pagination Component of React-Table
1212

1313
<ReactTable
14+
{...yourTableProps}
1415
PaginationComponent={TablePagination}
15-
{...yourOtherProps}
1616
{...otherPropsForThePaginationToo}
1717
/>
1818
```

src/components/Table/Table-story.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ storiesOf('Table', module)
7575
defaultPageSize={5}
7676
columns={columns}
7777
className="-border -striped -highlight"
78+
onPageChange={page => {
79+
// eslint-disable-next-line no-console
80+
console.log('page', page);
81+
}}
7882
pageSizesDisabled
83+
totalItems={100}
7984
PaginationComponent={TablePagination}
8085
/>
8186
));

src/components/TablePagination/TablePagination.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const ReactTablePagination = ({
7878
onChange={changePage}
7979
pageSizes={pageSizeOptions}
8080
page={page + 1}
81-
totalItems={totalItems ? totalItems : data.length}
81+
totalItems={totalItems ? totalItems : data ? data.length : undefined}
8282
{...propList}
8383
/>
8484
</div>

0 commit comments

Comments
 (0)