Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAT-136771: Added new DrumPicker component #542

Open
wants to merge 65 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
8595881
first commit
daniel-stoian-lgp Feb 24, 2021
0ae8891
second commit
daniel-stoian-lgp Feb 24, 2021
f85c211
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136480
daniel-stoian-lgp Feb 25, 2021
244b560
new commit
daniel-stoian-lgp Feb 25, 2021
566839c
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136480
daniel-stoian-lgp Feb 26, 2021
c139c87
updated range picker
daniel-stoian-lgp Feb 26, 2021
0c0a51e
update
daniel-stoian-lgp Mar 1, 2021
6de64b1
update
daniel-stoian-lgp Mar 2, 2021
de23b18
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136480
daniel-stoian-lgp Mar 3, 2021
a12c8cc
update
daniel-stoian-lgp Mar 3, 2021
4ceba7a
update
daniel-stoian-lgp Mar 3, 2021
87b776b
update
daniel-stoian-lgp Mar 3, 2021
d7203f1
update
daniel-stoian-lgp Mar 4, 2021
bdc52d9
update
daniel-stoian-lgp Mar 4, 2021
804ceee
update
daniel-stoian-lgp Mar 4, 2021
a8159c8
update
daniel-stoian-lgp Mar 4, 2021
b858b14
update
daniel-stoian-lgp Mar 4, 2021
834fe1f
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136771
daniel-stoian-lgp Mar 4, 2021
491a16b
update
daniel-stoian-lgp Mar 4, 2021
9d45417
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136771
daniel-stoian-lgp Mar 9, 2021
0b200e5
moved code to DrumPicker
daniel-stoian-lgp Mar 10, 2021
5182ed3
moved code to DrumPicker
daniel-stoian-lgp Mar 10, 2021
64d913e
revert
daniel-stoian-lgp Mar 10, 2021
a60cf04
revert
daniel-stoian-lgp Mar 10, 2021
ab53eb7
adapted styling for DrumPicker
daniel-stoian-lgp Mar 10, 2021
da468a3
adapted styling for DrumPicker
daniel-stoian-lgp Mar 10, 2021
cd8fabb
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136771
daniel-stoian-lgp Mar 11, 2021
2ddbf72
fixed resolution independence
daniel-stoian-lgp Mar 11, 2021
5d75cbf
added support for horizontal picker onMouse
daniel-stoian-lgp Mar 11, 2021
2dba7e2
code cleanup
daniel-stoian-lgp Mar 12, 2021
3e6c1b7
added support for horizontal picker
daniel-stoian-lgp Mar 12, 2021
20ebc96
fixed classnames
daniel-stoian-lgp Mar 12, 2021
10dbe34
added changelog and updated a few tests
daniel-stoian-lgp Mar 12, 2021
08401a7
added changelog and updated a few tests
daniel-stoian-lgp Mar 12, 2021
19bd3e4
updated unit tests
daniel-stoian-lgp Mar 15, 2021
2c57d29
updated unit tests
daniel-stoian-lgp Mar 15, 2021
249e85a
Merge branch 'develop' of https://github.com/enactjs/agate into featu…
daniel-stoian-lgp Mar 15, 2021
dbdb5a7
small update
daniel-stoian-lgp Mar 15, 2021
d30bd58
updated ui tests
daniel-stoian-lgp Mar 16, 2021
35c8495
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136771
daniel-stoian-lgp Mar 16, 2021
15869d4
fixed unit tests
daniel-stoian-lgp Mar 16, 2021
8727f39
added support for incrementing/decrementing on click
daniel-stoian-lgp Mar 16, 2021
ba839a2
updated ui tests for pointer
daniel-stoian-lgp Mar 16, 2021
c9f75f8
updated ui tests for pointer
daniel-stoian-lgp Mar 16, 2021
6e140e1
updated ui tests
daniel-stoian-lgp Mar 16, 2021
3f99d89
Fixed unit tests for time and date pickers
daniel-stoian-lgp Mar 17, 2021
d28151b
Fixed unit tests for internal/drumPicker
daniel-stoian-lgp Mar 17, 2021
0226c48
removed commented css
daniel-stoian-lgp Mar 17, 2021
641cf6e
added event listener of MouseLeave
daniel-stoian-lgp Mar 17, 2021
7d24354
code review fixes
daniel-stoian-lgp Mar 17, 2021
71e2d1b
small fixes
daniel-stoian-lgp Mar 17, 2021
21ead59
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136771
daniel-stoian-lgp Mar 18, 2021
73965c6
Merge branch 'develop' of https://github.com/enactjs/agate into featu…
daniel-stoian-lgp Mar 30, 2021
0046424
Merge branch 'develop' of https://github.com/enactjs/agate into featu…
daniel-stoian-lgp Mar 31, 2021
571a978
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136771
daniel-stoian-lgp Mar 31, 2021
acea626
attempted to limit the rendered dom elements
daniel-stoian-lgp Apr 1, 2021
c2bcdb4
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136771
daniel-stoian-lgp Apr 7, 2021
73c604a
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136771
daniel-stoian-lgp Apr 19, 2021
351ec1d
added onFlick
daniel-stoian-lgp Apr 19, 2021
5c08ac7
added onFlick
daniel-stoian-lgp Apr 19, 2021
c604fef
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136771
daniel-stoian-lgp Apr 21, 2021
c32cf5e
increased number of nodes to 15
daniel-stoian-lgp Apr 22, 2021
7585178
Merge remote-tracking branch 'origin/develop' into feature/PLAT-136771
daniel-stoian-lgp Apr 26, 2021
470dac5
added setTimeout
daniel-stoian-lgp Apr 29, 2021
8be8ff7
Merge branch 'develop' into feature/PLAT-136771
MikyungKim Jun 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The following is a curated list of changes in the Enact agate module, newest cha
### Changed

- `agate/Dropdown` to use `agate/ContextualPopup`
- `agate/Picker` and `agate/RangePicker` to use the new DrumPicker component
- `agate/ThemeDecorator` to exclude `enact-fit` className when `disableFullscreen` is true
- `agate/ArcPicker` and `agate/ArcSlider` to have a max-width for `slotCenter`

Expand Down
3 changes: 1 addition & 2 deletions DatePicker/tests/DatePicker-specs.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {mount} from 'enzyme';

import DatePicker from '../DatePicker';
import {DatePicker} from '../DatePicker';
import css from '../DatePicker.module.less';

// Note: Tests pass 'locale' because there's no I18nDecorator to provide a value via context and
// otherwise, nothing renders in the label.

describe('DatePicker', () => {

test(
'should emit an onChange event when changing a component picker',
() => {
Expand Down
1 change: 0 additions & 1 deletion DateTimePicker/tests/DateTimePicker-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import timeCss from '../../TimePicker/TimePicker.module.less';
// otherwise, nothing renders in the label.

describe('DateTimePicker', () => {

test(
'should emit an onChange event when changing a component picker',
() => {
Expand Down
16 changes: 10 additions & 6 deletions Picker/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
*/

import kind from '@enact/core/kind';
import {mapAndFilterChildren} from '@enact/core/util';
import Changeable from '@enact/ui/Changeable';
import Pure from '@enact/ui/internal/Pure';
import PropTypes from 'prop-types';
import clamp from 'ramda/src/clamp';
import compose from 'ramda/src/compose';
import {Children} from 'react';

import PickerCore, {ChangeAdapter, PickerItem} from '../internal/Picker';
import PickerCore, {DrumPickerItem} from '../internal/DrumPicker';

/**
* The base `Picker` component.
Expand Down Expand Up @@ -134,9 +135,13 @@ const PickerBase = kind({
},

computed: {
children: ({children}) => Children.map(children, (child) => (
<PickerItem>{child}</PickerItem>
)),
children: ({children, value}) => {
// send to internal/DrumPicker only 5 children. Current selected +/-2
const childrenArray = children.filter((child, index) => index >= value - 2 && index <= value + 2);
return (mapAndFilterChildren(childrenArray, (child) => (
<DrumPickerItem key={value}>{child}</DrumPickerItem>
)));
},
disabled: ({children, disabled}) => Children.count(children) > 1 ? disabled : true,
max: ({children}) => children && children.length ? children.length - 1 : 0,
value: ({value, children}) => {
Expand Down Expand Up @@ -172,8 +177,7 @@ const PickerBase = kind({
*/
const PickerDecorator = compose(
Pure,
Changeable,
ChangeAdapter
Changeable
);

/**
Expand Down
8 changes: 4 additions & 4 deletions Picker/tests/Picker-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {mount} from 'enzyme';
import {Picker, PickerBase} from '../Picker';

describe('Picker Specs', () => {
test('should render selected child wrapped with <PickerItem/>', () => {
test('should render selected child wrapped with <DrumPickerItem/>', () => {
const picker = mount(
<Picker value={1}>
{[1, 2, 3, 4]}
</Picker>
);

const expected = '2';
const actual = picker.find('PickerItem').at(1).text();
const actual = picker.find('DrumPickerItem').at(1).text();

expect(actual).toBe(expected);
});
Expand All @@ -25,7 +25,7 @@ describe('Picker Specs', () => {
);

const expected = 3;
const actual = picker.find('Picker').last().prop('max');
const actual = picker.find('DrumPicker').last().prop('max');

expect(actual).toBe(expected);
}
Expand All @@ -38,7 +38,7 @@ describe('Picker Specs', () => {
</PickerBase>
);

const actual = picker.find('Picker').last().prop('disabled');
const actual = picker.find('DrumPicker').last().prop('disabled');

expect(actual).toBe(true);
});
Expand Down
26 changes: 18 additions & 8 deletions RangePicker/RangePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
*/

import kind from '@enact/core/kind';
import {clamp} from '@enact/core/util';
import {clamp, mapAndFilterChildren} from '@enact/core/util';
import Changeable from '@enact/ui/Changeable';
import Pure from '@enact/ui/internal/Pure';
import PropTypes from 'prop-types';
import compose from 'ramda/src/compose';

import PickerCore, {ChangeAdapter} from '../internal/Picker';
import PickerItem from '../internal/Picker/PickerItem';
import PickerCore from '../internal/DrumPicker';
import DrumPickerItem from '../internal/DrumPicker/DrumPickerItem';

/**
* RangePicker base component.
Expand Down Expand Up @@ -171,17 +171,28 @@ const RangePickerBase = kind({
wrap: PropTypes.bool
},

defaultProps: {
step: 1
},

computed: {
children: ({min, max, step, value}) => {
// send to internal/DrumPicker only 5 children. Current selected +/-2
const childrenArray = Array(Math.floor((max - min) / step) + 1).fill(min).map( ((x, i) => (x + i * step))).filter(child => child >= value - (step * 2) && child <= value + (step * 2));
return (mapAndFilterChildren(childrenArray, (child) => (
<DrumPickerItem key={value} marqueeDisabled>{child}</DrumPickerItem>
)));
},
disabled: ({disabled, max, min}) => min >= max ? true : disabled,
value: ({min, max, value}) => {
return clamp(min, max, value);
}
},

render: ({value, ...rest}) => {
render: ({children, value, ...rest}) => {
return (
<PickerCore {...rest} index={0} type="number" value={value}>
<PickerItem key={value} marqueeDisabled style={{direction: 'ltr'}}>{value}</PickerItem>
<PickerCore {...rest} type="number" value={value}>
{children}
</PickerCore>
);
}
Expand All @@ -197,8 +208,7 @@ const RangePickerBase = kind({
*/
const RangePickerDecorator = compose(
Pure,
Changeable,
ChangeAdapter
Changeable
);

/**
Expand Down
39 changes: 28 additions & 11 deletions RangePicker/tests/RangePicker-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,62 @@ import {mount} from 'enzyme';

import {RangePicker, RangePickerBase} from '../RangePicker';

import css from '../../internal/Picker/Picker.module.less';
import css from '../../internal/DrumPicker/DrumPicker.module.less';

const decrement = (picker) => picker.find(`.${css.itemDecrement}`).first().simulate('click');
const increment = (picker) => picker.find(`.${css.itemIncrement}`).first().simulate('click');
const keyDown = (keyCode) => (picker) => picker.find(`.${css.root}`).first().simulate('keydown', {keyCode});

const upKeyDown = keyDown(38);
const downKeyDown = keyDown(40);

describe('RangePicker Specs', () => {
beforeEach(() => {
global.Element.prototype.getBoundingClientRect = jest.fn(() => {
return {
bottom: 310,
height: 84,
left: 45,
right: 1348,
top: 226,
width: 1303,
x: 45,
y: 226
};
});
});

test('should render a single child with the current value', () => {
const picker = mount(
<RangePicker min={-10} max={20} value={10} />
);

const expected = '10';
const actual = picker.find('.active').first().text();
const actual = picker.find('.selectedItem').first().text();

expect(actual).toBe(expected);
});

test('should increase by step amount on increment press', () => {
const picker = mount(
<RangePicker defaultValue={10} min={0} max={100} noAnimation step={1} />
<RangePicker defaultValue={10} min={0} max={20} noAnimation step={1} />
);

increment(picker);
downKeyDown(picker);

const expected = '11';
const actual = picker.find('.active').first().text();
const actual = picker.find('.selectedItem').first().text();

expect(actual).toBe(expected);
});

test('should decrease by step amount on decrement press', () => {
const picker = mount(
<RangePicker defaultValue={10} min={0} max={100} noAnimation step={1} />
<RangePicker defaultValue={10} min={0} max={20} noAnimation step={1} />
);

decrement(picker);
upKeyDown(picker);

const expected = '9';
const actual = picker.find('.active').first().text();
const actual = picker.find('.selectedItem').first().text();

expect(actual).toBe(expected);
});
Expand All @@ -50,7 +67,7 @@ describe('RangePicker Specs', () => {
<RangePickerBase min={0} max={0} value={0} />
);

const actual = picker.find('Picker').last().prop('disabled');
const actual = picker.find('DrumPicker').last().prop('disabled');
expect(actual).toBe(true);
});
});
3 changes: 0 additions & 3 deletions TimePicker/tests/TimePicker-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import css from '../TimePicker.module.less';
// otherwise, nothing renders in the label.

describe('TimePicker', () => {

// Suite-wide setup

test('should emit an onChange event when changing a component picker',
() => {
const handleChange = jest.fn();
Expand Down
14 changes: 7 additions & 7 deletions internal/DateComponentPicker/DateComponentPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import Changeable from '@enact/ui/Changeable';
import PropTypes from 'prop-types';
import {Children} from 'react';

import PickerCore, {PickerItem} from '../Picker';
import PickerCore, {DrumPickerItem} from '../DrumPicker';

import css from './DateComponentPicker.module.less';
import componentCss from './DateComponentPicker.module.less';

/**
* {@link agate/internal/DataComponentPicker.DateComponentPickerBase} allows the selection of one
* part of the date or time using a {@link agate/internal/Picker.Picker}.
* part of the date or time using a {@link agate/internal/DrumPicker.DrumPicker}.
*
* @class DateComponentPickerBase
* @memberof agate/internal/DateComponentPicker
Expand Down Expand Up @@ -66,23 +66,23 @@ const DateComponentPickerBase = kind({
},

styles: {
css,
css: componentCss,
className: 'dateComponentPicker'
},

computed: {
children: ({children}) => mapAndFilterChildren(children, (child) => (
<PickerItem>{child}</PickerItem>
<DrumPickerItem>{child}</DrumPickerItem>
)),
max: ({children}) => children ? Children.count(children) - 1 : 0
},

render: ({accessibilityHint, 'aria-valuetext': ariaValuetext, children, max, value, wrap, ...rest}) => (
render: ({accessibilityHint, 'aria-valuetext': ariaValuetext, children, className, max, value, wrap, ...rest}) => (
<PickerCore
{...rest}
accessibilityHint={accessibilityHint}
aria-valuetext={(accessibilityHint == null) ? ariaValuetext : null}
css={css}
className={className}
index={value}
max={max}
min={0}
Expand Down
8 changes: 4 additions & 4 deletions internal/DateComponentPicker/DateComponentRangePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';

import {RangePickerBase} from '../../RangePicker';

import css from './DateComponentPicker.module.less';
import componentCss from './DateComponentPicker.module.less';

/**
* {@link agate/internal/DataComponentPicker.DateComponentRangePicker} allows the selection of
Expand Down Expand Up @@ -68,15 +68,15 @@ const DateComponentRangePickerBase = kind({
},

styles: {
css,
css: componentCss,
className: 'dateComponentPicker'
},

render: ({accessibilityHint, max, min, value, wrap, ...rest}) => (
render: ({accessibilityHint, className, max, min, value, wrap, ...rest}) => (
<RangePickerBase
{...rest}
accessibilityHint={(accessibilityHint == null) ? value : accessibilityHint}
css={css}
className={className}
max={max}
min={min}
orientation="vertical"
Expand Down
Loading