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

feat(kit): Range use Slider inside #1538

Merged
merged 8 commits into from
Apr 5, 2022
Merged

feat(kit): Range use Slider inside #1538

merged 8 commits into from
Apr 5, 2022

Conversation

nsbarsukov
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows Conventional Commits
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Refactoring
  • Code style update
  • Build or CI related changes
  • Documentation content changes

What is the current behavior?

Closes #

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

@nsbarsukov nsbarsukov self-assigned this Mar 25, 2022
@lumberjack-bot
Copy link

lumberjack-bot bot commented Mar 25, 2022

Pull request was closed ✔️

All saved screenshots (for current PR) were deleted 🗑️

@github-actions
Copy link
Contributor

github-actions bot commented Mar 25, 2022

Visit the preview URL for this PR (updated for commit 6824717):

https://taiga-ui--pr1538-range-refactor-ddqp2l3d.web.app

(expires Wed, 06 Apr 2022 08:10:10 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@codecov
Copy link

codecov bot commented Mar 25, 2022

Codecov Report

Merging #1538 (6824717) into main (9cdbde9) will decrease coverage by 1.11%.
The diff coverage is 60.24%.

@@            Coverage Diff             @@
##             main    #1538      +/-   ##
==========================================
- Coverage   63.43%   62.32%   -1.12%     
==========================================
  Files         910      696     -214     
  Lines        9953     8496    -1457     
  Branches     1920     1658     -262     
==========================================
- Hits         6314     5295    -1019     
+ Misses       3200     2793     -407     
+ Partials      439      408      -31     
Flag Coverage Δ
addon-charts 74.69% <ø> (ø)
addon-doc 26.15% <ø> (ø)
addon-editor 45.87% <ø> (ø)
addon-mobile ∅ <ø> (∅)
addon-table 81.39% <ø> (ø)
addon-tablebars ∅ <ø> (∅)
cdk ?
core 68.70% <ø> (ø)
kit 62.92% <60.24%> (+0.03%) ⬆️
summary 62.32% <60.24%> (-1.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
projects/kit/components/range/range.module.ts 100.00% <ø> (ø)
projects/kit/components/slider/slider.module.ts 100.00% <ø> (ø)
...cts/kit/components/range/range-change.directive.ts 24.24% <24.24%> (ø)
...kit/components/slider/slider-readonly.directive.ts 77.77% <77.77%> (ø)
projects/kit/abstract/slider/slider.ts 60.90% <83.33%> (-0.70%) ⬇️
projects/kit/components/range/range.component.ts 83.33% <84.37%> (+16.66%) ⬆️
...ects/kit/components/slider/slider-old.component.ts 93.75% <100.00%> (+0.89%) ⬆️
projects/cdk/classes/validation-error.ts
projects/cdk/date-time/date-separator.ts
projects/cdk/utils/math/clamp.ts
... and 215 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9cdbde9...6824717. Read the comment docs.

@nsbarsukov nsbarsukov force-pushed the range-refactor branch 7 times, most recently from b17be23 to 13cfc63 Compare March 29, 2022 09:08
@nsbarsukov nsbarsukov changed the title [WIP] refactor(kit): Range use Slider inside refactor(kit): Range use Slider inside Mar 29, 2022
@nsbarsukov nsbarsukov marked this pull request as ready for review March 29, 2022 09:22
@nsbarsukov nsbarsukov changed the title refactor(kit): Range use Slider inside feat(kit): Range use Slider inside Mar 30, 2022
* TODO replace with pointer events (when all supported browsers can handle them).
* Dont forget to use setPointerCapture instead of listening all documentRef events
*/
private readonly pointerDown$ = merge(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same stream is used in tuiPan, maybe it makes sense to think about sharing this code 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this directive listens to the same events. But it does different things.

Should we create tuiPointerDown$, tuiPointerMove$, tuiPointerUp$ services ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need separate services but if we can somehow provide and reuse Pan it would be nice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I can't reuse pan service (or I dont understand how to do it).

PanService emits values on every *Move event but i also need first emission of *Down-event

@import 'taiga-ui-local';

.range {
z-index: 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To overlap tick's label

when we click on tick's label, the click event fires on Range

z-index: 1;

/* (Optionally) expand clickable area as you wish */
&:after {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it makes sense to add a mixin for that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we want support it :)
Range already has increased clickable area.

Manually expanding it is optional.
And this manually expanded area can be of any shape.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, creating of pseudo-element is rather simple)

top: @track-height / 2;
left: 0;
right: 0;
z-index: 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thumb is filled by semi-transparent color during hover.
It will show what happens under it otherwise.

* TODO replace with pointer events (when all supported browsers can handle them).
* Dont forget to use setPointerCapture instead of listening all documentRef events
*/
private readonly pointerDown$ = merge(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need separate services but if we can somehow provide and reuse Pan it would be nice

) {
super(control, changeDetectorRef, documentRef, fromToTexts$);
}

get nativeFocusableElement(): TuiNativeFocusableElement | null {
if (this.computedDisabled || !this.dotLeft || !this.dotRight) {
const [sliderLeftRef, sliderRightRef] = this.slidersRefs;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't know you could do that :) I would use const {first, last} :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array deconstructing is convenient here because we can choose naming.

Do you think that I should use const {first, last} instead ?

.pipe(
tap(({clientX, target}) => {
activeThumb = this.detectActiveThumb(clientX, target);
elementRef.nativeElement.focus();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should just drop setNativeFocused completely and use native method everywhere, like here 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed usage of setNativeFocused from kit/components/range-directory

@nsbarsukov nsbarsukov force-pushed the range-refactor branch 3 times, most recently from dfac1cb to 42128a1 Compare April 5, 2022 07:08
@nsbarsukov nsbarsukov merged commit 245c8d5 into main Apr 5, 2022
@nsbarsukov nsbarsukov deleted the range-refactor branch April 5, 2022 12:39
@well-done-bot
Copy link

well-done-bot bot commented Apr 5, 2022

'Well done'

@nsbarsukov nsbarsukov linked an issue Apr 5, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

🛠 - Sliders
4 participants