Skip to content

Commit 44a58ac

Browse files
committed
fix(pf4,suir): Make sort icons consistent among all dual-list selectors
Signed-off-by: Boaz Shuster <[email protected]>
1 parent fbf6fa6 commit 44a58ac

File tree

6 files changed

+61
-21
lines changed

6 files changed

+61
-21
lines changed

packages/pf4-component-mapper/src/files/dual-list-select.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import {
1818
} from '@patternfly/react-core';
1919

2020
import {
21-
SortAlphaDownIcon,
22-
SortAlphaUpIcon,
21+
PficonSortCommonAscIcon,
22+
PficonSortCommonDescIcon,
2323
SearchIcon,
2424
AngleDoubleLeftIcon,
2525
AngleDoubleRightIcon,
@@ -93,7 +93,7 @@ const Toolbar = ({ sortTitle, onFilter, onSort, sortDirection, value, placeholde
9393
</DataToolbarItem>
9494
<DataToolbarItem>
9595
<Button onClick={onSort} title={sortTitle} variant="plain">
96-
{!sortDirection ? <SortAlphaDownIcon size="md" /> : <SortAlphaUpIcon size="md" />}
96+
{!sortDirection ? <PficonSortCommonAscIcon size="md" /> : <PficonSortCommonDescIcon size="md" />}
9797
</Button>
9898
</DataToolbarItem>
9999
</DataToolbarContent>

packages/pf4-component-mapper/src/tests/dual-list-select.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { FormGroup, TextInput } from '@patternfly/react-core';
77
import { DataToolbar } from '@patternfly/react-core/dist/js/experimental';
88
import {
99
SearchIcon,
10-
SortAlphaUpIcon,
11-
SortAlphaDownIcon,
10+
PficonSortCommonAscIcon,
11+
PficonSortCommonDescIcon,
1212
AngleDoubleLeftIcon,
1313
AngleDoubleRightIcon,
1414
AngleLeftIcon,
@@ -71,8 +71,8 @@ describe('DualListSelect', () => {
7171
expect(wrapper.find(DataToolbar)).toHaveLength(2);
7272
expect(wrapper.find(TextInput)).toHaveLength(2);
7373
expect(wrapper.find(SearchIcon)).toHaveLength(2);
74-
expect(wrapper.find(SortAlphaUpIcon)).toHaveLength(2);
75-
expect(wrapper.find(SortAlphaDownIcon)).toHaveLength(0);
74+
expect(wrapper.find(PficonSortCommonDescIcon)).toHaveLength(2);
75+
expect(wrapper.find(PficonSortCommonAscIcon)).toHaveLength(0);
7676
expect(wrapper.find(AngleRightIcon)).toHaveLength(1);
7777
expect(wrapper.find(AngleLeftIcon)).toHaveLength(1);
7878
expect(wrapper.find(AngleDoubleRightIcon)).toHaveLength(1);
@@ -396,7 +396,7 @@ describe('DualListSelect', () => {
396396
).toEqual('zebras');
397397
await act(async () => {
398398
wrapper
399-
.find(SortAlphaUpIcon)
399+
.find(PficonSortCommonDescIcon)
400400
.first()
401401
.parent()
402402
.props()
@@ -422,7 +422,7 @@ describe('DualListSelect', () => {
422422
).toEqual('cats');
423423
await act(async () => {
424424
wrapper
425-
.find(SortAlphaDownIcon)
425+
.find(PficonSortCommonAscIcon)
426426
.first()
427427
.parent()
428428
.props()
@@ -469,7 +469,7 @@ describe('DualListSelect', () => {
469469
).toEqual('zebras');
470470
await act(async () => {
471471
wrapper
472-
.find(SortAlphaUpIcon)
472+
.find(PficonSortCommonDescIcon)
473473
.last()
474474
.parent()
475475
.props()
@@ -495,7 +495,7 @@ describe('DualListSelect', () => {
495495
).toEqual('cats');
496496
await act(async () => {
497497
wrapper
498-
.find(SortAlphaDownIcon)
498+
.find(PficonSortCommonAscIcon)
499499
.last()
500500
.parent()
501501
.props()
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const dualListSchemaDDF = {
2+
title: 'Testing dual list',
3+
fields: [
4+
{
5+
component: 'dual-list-select',
6+
name: 'dual-list-select',
7+
label: 'choose favorite animal',
8+
options: [
9+
{
10+
value: 'cats',
11+
label: 'cats'
12+
},
13+
{
14+
value: 'cats_1',
15+
label: 'cats_1'
16+
},
17+
{
18+
value: 'cats_2',
19+
label: 'cats_2'
20+
},
21+
{
22+
value: 'zebras',
23+
label: 'zebras'
24+
},
25+
{
26+
value: 'pigeons',
27+
label: 'pigeons'
28+
}
29+
]
30+
}
31+
]
32+
};
33+
34+
export default dualListSchemaDDF;

packages/suir-component-mapper/demo/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import FormRenderer, { componentTypes } from '@data-driven-forms/react-form-rend
55
import { componentMapper, FormTemplate } from '../src';
66
import demoSchema from '@data-driven-forms/common/src/demoschema';
77
import fieldArraySchema from './demo-schemas/field-array-schema';
8-
8+
import dualListSchema from './demo-schemas/dual-list-select-schema';
99
import wizardSchema from './demo-schemas/wizard-schema';
1010
import { Button } from 'semantic-ui-react';
1111

@@ -29,6 +29,7 @@ const App = () => {
2929
<Button onClick={() => setSchema(demoSchema)}>Demo schema</Button>
3030
<Button onClick={() => setSchema(fieldArraySchema)}>Field array</Button>
3131
<Button onClick={() => setSchema(wizardSchema)}>Wizard</Button>
32+
<Button onClick={() => setSchema(dualListSchema)}>Dual list</Button>
3233
</div>
3334
<div style={{ padding: 32 }}>
3435
<FormRenderer

packages/suir-component-mapper/src/files/dual-list-select.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ Toolbar.propTypes = {
102102
};
103103

104104
Toolbar.defaultProps = {
105-
sortUpIcon: 'sort up',
106-
sortDownIcon: 'sort down'
105+
sortUpIcon: 'sort amount up',
106+
sortDownIcon: 'sort amount down'
107107
};
108108

109109
const useDualListStyles = createUseStyles({
@@ -120,6 +120,11 @@ const useDualListStyles = createUseStyles({
120120
'&>label': {
121121
display: 'inline-block !important'
122122
}
123+
},
124+
'@media screen and (max-width: 767px)': {
125+
transferButton: {
126+
transform: 'rotate(90deg)'
127+
}
123128
}
124129
});
125130

@@ -192,7 +197,7 @@ const DualList = ({
192197
className={clsx(classes.formField, labelClassName)}
193198
/>
194199
<Grid key="0">
195-
<GridColumn mobile={16} tablet={16} computer={7}>
200+
<GridColumn mobile={16} tablet={7} computer={7}>
196201
<Grid>
197202
<GridColumn mobile={16} tablet={16}>
198203
<Header sub {...OptionsHeaderProps}>
@@ -224,7 +229,7 @@ const DualList = ({
224229
</GridColumn>
225230
</Grid>
226231
</GridColumn>
227-
<GridColumn className={clsx(classes.dualListButtons, buttonGridClassName)} {...ButtonGridProps} mobile={16} tablet={16} computer={2}>
232+
<GridColumn className={clsx(classes.dualListButtons, buttonGridClassName)} {...ButtonGridProps} mobile={16} tablet={2} computer={2}>
228233
<Grid>
229234
<GridColumn tablet={16} mobile={4}>
230235
<Button
@@ -276,7 +281,7 @@ const DualList = ({
276281
</GridColumn>
277282
</Grid>
278283
</GridColumn>
279-
<GridColumn mobile={16} tablet={16} computer={7}>
284+
<GridColumn mobile={16} tablet={7} computer={7}>
280285
<Grid>
281286
<GridColumn tablet={16}>
282287
<Header sub {...ValuesHeaderProps}>

packages/suir-component-mapper/src/tests/dual-list-select.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ describe('DualListSelect', () => {
367367
).toEqual('zebras');
368368
await act(async () => {
369369
wrapper
370-
.findWhere((node) => node.prop('icon') === 'sort up')
370+
.findWhere((node) => node.prop('icon') === 'sort amount up')
371371
.first()
372372
.find('button')
373373
.simulate('click');
@@ -392,7 +392,7 @@ describe('DualListSelect', () => {
392392
).toEqual('cats');
393393
await act(async () => {
394394
wrapper
395-
.findWhere((node) => node.prop('icon') === 'sort down')
395+
.findWhere((node) => node.prop('icon') === 'sort amount down')
396396
.find('button')
397397
.first()
398398
.simulate('click');
@@ -438,7 +438,7 @@ describe('DualListSelect', () => {
438438
).toEqual('zebras');
439439
await act(async () => {
440440
wrapper
441-
.findWhere((node) => node.prop('icon') === 'sort up')
441+
.findWhere((node) => node.prop('icon') === 'sort amount up')
442442
.last()
443443
.find('button')
444444
.simulate('click');
@@ -463,7 +463,7 @@ describe('DualListSelect', () => {
463463
).toEqual('cats');
464464
await act(async () => {
465465
wrapper
466-
.findWhere((node) => node.prop('icon') === 'sort down')
466+
.findWhere((node) => node.prop('icon') === 'sort amount down')
467467
.find('button')
468468
.last()
469469
.simulate('click');

0 commit comments

Comments
 (0)