-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat(TimeRangeSelector): added new input Time Range Selector #216
Conversation
Preview is ready. |
Playwright Test Component is ready. |
return times.filter(({value: time}) => time > cutoff); | ||
} | ||
|
||
return times.filter(({value: time}) => time < cutoff); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove the code duplication
just like that
return times.filter(({value: time}) => direction === 'greater' ? time > cutoff : time < cutoff)
import {ObjectIndependentView, ViewController, isStringSpec} from '../../../../core'; | ||
|
||
const START_TIME = 'start'; | ||
const END_TIME = 'end'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen similar constants in TimeRangeSelector 👀
|
||
_spec.viewSpec.layout = 'row'; | ||
|
||
endTimeSpec = _spec; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code is duplicated
let's do something like this
const [startTimeSpec, endTimeSpec] = [START_TIME, END_TIME].map((key) => {
if (spec.properties?.[key] && isStringSpec(spec.properties[key])) {
const spec = cloneDeep(spec.properties[key]);
spec.viewSpec.layout = 'row';
return spec;
}
return;
});
|
||
if (input.value?.[END_TIME] && isString(input.value[END_TIME])) { | ||
startTimeOptions = filterTimeArray(defaultTimeOptions, input.value[END_TIME], 'less'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment about duplication
const _spec = cloneDeep(spec.properties[END_TIME]); | ||
|
||
endTimeSpec = _spec; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment about duplication
const property = spec.properties?.[key]; | ||
|
||
if (isStringSpec(property)) { | ||
const _spec = cloneDeep(property); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have no reason to clone this spec
it looks like this memo might be like this
const [startTimeSpec, endTimeSpec] = React.useMemo(() =>
[START_TIME, END_TIME].map(
(key) => isStringSpec(spec.properties?.[key]) ? spec.properties?.[key] : undefined)
, [spec.properties]);
No description provided.