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(stepper): allow for header icons to be customized #7482

Merged

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Oct 2, 2017

Currently users are locked into using the Material create and done icon for the step headers. These changes add the ability to customize the icons by providing an ng-template with an override.

Fixes #7384.

Note: I'm not too sure about the naming (matStepperIcon vs matStepIcon). I went with matStepperIcon, because it applies to the entire stepper, rather than an individual step.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 2, 2017
@crisbeto crisbeto force-pushed the 7384/stepper-icon-customization branch from c19ecbd to 585023a Compare October 3, 2017 15:16
@jelbourn jelbourn added the target: major This PR is targeted for the next major release label Oct 29, 2017
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.

This is a breaking API change that wasn't on the radar for RC. I'm not sure we are able to swing it, but can do a presubmit to see

/** Icon for the given step. */
@Input() icon: string;
/** State of the given step. */
@Input() state: string;
Copy link
Member

Choose a reason for hiding this comment

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

From the name I'm not sure that state is meant to be

Copy link
Member Author

Choose a reason for hiding this comment

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

This component is internal anyway, but it's supposed to mean the state that the header is in (e.g. done, current).


/** Label of the given step. */
@Input() label: MatStepLabel | string;

/** Overrides for the header icons, passed in via the stepper. */
@Input() iconOverrides: {[key: string]: TemplateRef<any>};
Copy link
Member

Choose a reason for hiding this comment

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

Why not a map?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't need to be. It's just a string->TemplateRef map.

* Template to be used to override the icons inside the step header.
*/
@Directive({
selector: 'ng-template[matStepperIcon]',
Copy link
Member

Choose a reason for hiding this comment

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

Does this work with

<mat-icon *matStepperIcon>

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I haven't tried it but I suppose.

Copy link
Member Author

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

@jelbourn It's not a breaking API change. It's true that I renamed an input, however it's on the mat-step-header which is only used internally (see https://github.com/angular/material2/blob/master/src/lib/stepper/stepper-horizontal.html).


/** Label of the given step. */
@Input() label: MatStepLabel | string;

/** Overrides for the header icons, passed in via the stepper. */
@Input() iconOverrides: {[key: string]: TemplateRef<any>};
Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't need to be. It's just a string->TemplateRef map.

/** Icon for the given step. */
@Input() icon: string;
/** State of the given step. */
@Input() state: string;
Copy link
Member Author

Choose a reason for hiding this comment

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

This component is internal anyway, but it's supposed to mean the state that the header is in (e.g. done, current).

* Template to be used to override the icons inside the step header.
*/
@Directive({
selector: 'ng-template[matStepperIcon]',
Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I haven't tried it but I suppose.

@jelbourn jelbourn removed the target: major This PR is targeted for the next major release label Oct 30, 2017
@jelbourn
Copy link
Member

Ah, I didn't know it was an internal component. I'll leave it to @mmalerba to review, then

@AsafAgranat
Copy link

Additionally, currently the steppers icons are rendered using the web-font variant. SVG icons (using the svgIcon attribute) should be supported too.

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.

Looks good, needs rebase though

@crisbeto crisbeto force-pushed the 7384/stepper-icon-customization branch 2 times, most recently from aa115f8 to f120014 Compare November 13, 2017 21:42
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed pr: needs rebase labels Nov 13, 2017
@crisbeto crisbeto force-pushed the 7384/stepper-icon-customization branch 2 times, most recently from 8fd1dd0 to 8cc1aff Compare November 20, 2017 20:48
@crisbeto crisbeto added the target: minor This PR is targeted for the next minor release label Dec 6, 2017
@aamir1995
Copy link

Any update on this PR?

@ganqqwerty
Copy link

so, guys, what are you waiting for? Merge that thing!

Currently users are locked into using the Material `create` and `done` icon for the step headers. These changes add the ability to customize the icons by providing an `ng-template` with an override.

Fixes angular#7384.
@crisbeto crisbeto force-pushed the 7384/stepper-icon-customization branch from 8cc1aff to 0515a0b Compare January 14, 2018 16:33
@tinayuangao tinayuangao merged commit adc251c into angular:master Jan 30, 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 8, 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.

stepper dependency on material icons
8 participants