Skip to content

feat(progress-spinner): add injection token for configuring the diameter and stroke globally #11493

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 1 commit into from
May 25, 2018

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented May 24, 2018

Adds the MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS injection token that can be used to globally configure the diameter and stroke (and any other options we decide to add) for all progress spinners.

Fixes #11490.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 24, 2018
@CharlBest
Copy link

CharlBest commented May 24, 2018

Thank you for this. I think it's worth putting in the "strokeWidth" as well to set your own default globally if it's not to much extra work. Probably not part of this PR just thought I'd say something. :) Thanks again.

@crisbeto crisbeto force-pushed the 11490/spinner-global-diameter branch from af3f745 to b64b335 Compare May 24, 2018 14:40
@crisbeto crisbeto changed the title feat(progress-spinner): add injection token for configuring the diameter globally feat(progress-spinner): add injection token for configuring the diameter and stroke globally May 24, 2018
@crisbeto
Copy link
Member Author

Done.

…ter and stroke globally

Adds the `MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS` injection token that can be used to globally configure the diameter and stroke (and any other options we decide to add) for all progress spinners.

Fixes angular#11490.
@crisbeto crisbeto force-pushed the 11490/spinner-global-diameter branch from b64b335 to 8f33b26 Compare May 24, 2018 14:45
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.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release labels May 24, 2018
// @deletion-target 7.0.0 _animationMode and _defaults parameters to be made required.
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string,
@Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)
private _defaults?: MatProgressSpinnerDefaultOptions) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we have our own defaults value in a instance of MatProgressSpinnerDefaultOptions?

Then we can just Object.assign it, rather than holding our defaults inline in location.

In the file above the class:

export interface MatProgressSpinnerDefaultOptions {
  /** Diameter of the spinner. */
  diameter?: number;
  /** Width of the spinner's stroke. */
  strokeWidth?: number;
}

const BASE_OPTIONS  = {
  diameter: 100,
  strokeWidth: 10
};

In the class:

export class MatProgressSpinner 
  ...
  private defaults: MatProgressSpinnerDefaultOptions
  ...
  constructor(
  ...
  @Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS) defaults: MatProgressSpinnerDefaultOptions) {
    this.defaults = Object.assign(BASE_OPTIONS, defaults);
  ...
  }
...

Copy link
Member Author

@crisbeto crisbeto May 25, 2018

Choose a reason for hiding this comment

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

Our defaults are provided as the MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS token. I kept the inline defaults until we can make the defaults a required parameter.

Copy link
Member

Choose a reason for hiding this comment

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

My concern here is that since the interface for MatProgressSpinnerDefaultOptions has all optional properties, that someone who provides a MatProgressSpinnerDefaultOptions, would not provide everything thats needed.

@mmalerba mmalerba merged commit c3899cf into angular:master May 25, 2018
@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 Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mat-spinner] Global diameter configuration
6 participants