Skip to content

feat(material-experimental/mdc-slider): implement the SliderAdapter #21844

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

Merged
merged 12 commits into from
Feb 17, 2021

Conversation

wagnermaciel
Copy link
Contributor

@wagnermaciel wagnermaciel commented Feb 8, 2021

  • complete the core logic for MatSliderThumb and MatSlider
  • collapse slider-thumb.ts and slider-adapter.ts into slider.ts

* complete the core logic for MatSliderThumb and MatSlider
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 8, 2021
@wagnermaciel
Copy link
Contributor Author

@mmalerba & @jelbourn This is ready for review but I'm not sure how to neatly resolve this circular dependency. Should I just move the contents of slider-thumb.ts to slider.ts?

@mmalerba
Copy link
Contributor

mmalerba commented Feb 8, 2021

@jelbourn are we allowed to use type-only imports? https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export that would probably help with the circular deps

* delete commented out code
* add comment explaining why emitChangeEvent and emitInputEvent are ignored
@wagnermaciel wagnermaciel requested a review from mmalerba February 9, 2021 01:46
* remove circular dependency between MatSlider and MatSliderThumb
* change the selectors for MatSliderThumb
* add a comment describing why and how the value property on the MatSliderThumb works
* delete min, max, and step @inputs from MatSliderThumb
* remove _initialize property from MatSliderThumb
* move all of the MatSliderThumb initialization logic into ngAfterViewInit
* remove input initialization logic from MatSlider ngAfterViewInit
* add input validation logic to MatSlider ngAfterViewInit
* fix value indicator text bug where the DOM was not getting updated
* add todo to remember to add the mdc-slider back into the kitchen sink ssr app
* move _foundation.init() into the _platform.isBrowser check to avoid ssr problems
}
emitDragEndEvent(value: number, thumb: Thumb): void {
throw Error('Method not implemented.');
getValueToAriaValueTextFn = (): ((value: number) => string) | null => {
Copy link
Member

Choose a reason for hiding this comment

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

Did we ever figure out why these have to be arrow functions instead of methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

* make input validation only happen in ngDevMode
* move _validateInputs() and _throwInvalidInputConfigurationError() out of MatSlider so
  they can be tree-shaken away in production mode
* delete _getValueIndicatorText() and _getValueIndicatorTextElement() and add their logic to _setValueIndicatorText()
* made getters more efficient
* deleted unused _getValue() method
* move export class MatSliderThumb ... to its own separate line
* moved MatSliderThumb value initialization to the constructor to avoid race conditions
  when setting the min and max
* set the value property in ngAfterViewInit for MatSliderThumb
* move dummy MatSlider interfaces from slider-adapter and slider-thumb to slider-interface
* create MatSliderThumb and MatSliderDragEvent dummy interfaces to avoid a circular dep between
  slider-thumb and slider-interface when defining the dummy MatSliderThumb interface
* make MatSlider implement the dummy _MatSliderInterface
* add class description jsdoc
* move comment explaining why we use arrow fns
…r change detection problem

* use markForCheck() instead of detectChanges() in updateTickMarks()
* call detectChanges() once at the end of ngAfterViewInit() in MatSlider with
  a thorough comment explaining why it is needed
…r.ts

* delete slider-adapter.ts
* delete slider-interface.ts
* delete slider-thumb.ts
* move SliderAdapter implementation to slider.ts
* move MatSliderThumb implementation to slider.ts
* go back to using direct references instead of interfaces
* fix imports in module.ts
* fix imports in public-api.ts
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

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

LGTM with a couple API nits

* delete empty providers
* rename thumb to _thumb and make it private in MatSliderThumb
* delete thumb property in MatSliderDragEvent
@Output() readonly _focus: EventEmitter<void> = new EventEmitter<void>();

/** Indicates which slider thumb this input corresponds to. */
private _thumb: Thumb;
Copy link
Member

Choose a reason for hiding this comment

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

I would call this _thumbPosition and the enum ThumbPosition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Thumb enum comes from MDC

Copy link
Member

Choose a reason for hiding this comment

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

Ack, I would still change the name of the property

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Would you also like me to make this change to all of the SliderAdapter and MatSlider methods that use thumb as the name for this?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, any properties/variables that refer to this concept I would name thumbPosition since it's a much more clear description than thumb (which I would assume is a reference to the actual thumb itself, not just the position)

* revert to using a method to display the value indicator text instead of directly through the DOM
* avoid styling based on tag name and instead target class names applied to host elements
* fix indentation in slider.scss
* condense jsdoc to oneline
* expand MatSliderThumb jsdoc
* reworded comment in MatSliderThumb
* move initialization of _thumb value to property definition
* move input value attribute initialization to separate method
* move input min and max property initialization to separate method
* move input value property initialization to separate method
* remove unnecessary !
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

Overall LGTM aside from my last comment about the thumbPosition

@wagnermaciel wagnermaciel added the target: feature This PR is targeted for a feature branch (outside of main and semver branches) label Feb 17, 2021
@wagnermaciel wagnermaciel merged commit 124b7de into angular:mdc-slider Feb 17, 2021
wagnermaciel added a commit to wagnermaciel/components that referenced this pull request Feb 17, 2021
…ngular#21844)

* feat(material-experimental/mdc-slider): implement the SliderAdapter

* complete the core logic for MatSliderThumb and MatSlider
* collapse slider-thumb.ts and slider-adapter.ts into slider.ts
wagnermaciel added a commit to wagnermaciel/components that referenced this pull request Feb 17, 2021
…ngular#21844)

* feat(material-experimental/mdc-slider): implement the SliderAdapter

* complete the core logic for MatSliderThumb and MatSlider
* collapse slider-thumb.ts and slider-adapter.ts into slider.ts
wagnermaciel added a commit to wagnermaciel/components that referenced this pull request Mar 4, 2021
…ngular#21844)

* feat(material-experimental/mdc-slider): implement the SliderAdapter

* complete the core logic for MatSliderThumb and MatSlider
* collapse slider-thumb.ts and slider-adapter.ts into slider.ts
wagnermaciel added a commit to wagnermaciel/components that referenced this pull request Mar 11, 2021
…ngular#21844)

* feat(material-experimental/mdc-slider): implement the SliderAdapter

* complete the core logic for MatSliderThumb and MatSlider
* collapse slider-thumb.ts and slider-adapter.ts into slider.ts
wagnermaciel added a commit to wagnermaciel/components that referenced this pull request Mar 11, 2021
…ngular#21844)

* feat(material-experimental/mdc-slider): implement the SliderAdapter

* complete the core logic for MatSliderThumb and MatSlider
* collapse slider-thumb.ts and slider-adapter.ts into slider.ts
wagnermaciel added a commit to wagnermaciel/components that referenced this pull request Mar 12, 2021
…ngular#21844)

* feat(material-experimental/mdc-slider): implement the SliderAdapter

* complete the core logic for MatSliderThumb and MatSlider
* collapse slider-thumb.ts and slider-adapter.ts into slider.ts
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement target: feature This PR is targeted for a feature branch (outside of main and semver branches)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants