-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
feat(progress-spinner): add injection token for configuring the diameter and stroke globally #11493
Conversation
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. |
af3f745
to
b64b335
Compare
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.
b64b335
to
8f33b26
Compare
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.
LGTM
// @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) { |
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.
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);
...
}
...
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.
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.
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.
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.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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.