-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Stepper alternative label #12674
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
Stepper alternative label #12674
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I already signed the CLA earlier today as a Corporate (Dreamonkey S.r.l.) of which I'm the Point of Contact. I'm not even sure about how to fix the |
I can confirm that the Corporate CLA has been accepted for my company |
CLAs look good, thanks! |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
I squashed all commits in a single one and removed the import which gave problems, but it seems that now CLA is complaining. |
Hi @IlCallo! This PR has merge conflicts due to recent upstream merges. |
It looks like you somehow wound up including a bunch of other commits from other authors, if it's too difficult to fix you can just move the changes to a new PR |
CLAs look good, thanks! |
Everything should be fine now |
src/lib/stepper/stepper.ts
Outdated
@@ -123,6 +126,7 @@ export class MatStepper extends _CdkStepper implements AfterContentInit { | |||
inputs: ['selectedIndex'], | |||
host: { | |||
'class': 'mat-stepper-horizontal', | |||
'[class.mat-stepper--alternative-label]': 'alternativeLabel', |
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.
nit: I don't think we use the --
style anywhere else in our code, use -
for consistency
src/lib/stepper/stepper.scss
Outdated
margin: 0; | ||
min-width: 0; | ||
position: relative; | ||
top: $mat-stepper-side-gap + $mat-stepper-label-header-height/2; |
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.
nit: put space around '/'
src/lib/stepper/stepper.scss
Outdated
display: inline-block; | ||
height: 0; | ||
position: absolute; | ||
top: $mat-stepper-side-gap + $mat-stepper-label-header-height/2; |
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.
nit: space around '/'
src/lib/stepper/stepper.scss
Outdated
height: 0; | ||
position: absolute; | ||
top: $mat-stepper-side-gap + $mat-stepper-label-header-height/2; | ||
width: calc(50% - #{$mat-stepper-label-header-height/2} - #{$mat-stepper-line-gap}); |
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.
you can combine the second and third terms in SASS:
calc(50% - #{$mat-stepper-label-header-height / 2 - $mat-stepper-line-gap});
src/lib/stepper/stepper.scss
Outdated
@@ -44,6 +68,33 @@ $mat-stepper-line-gap: 8px !default; | |||
margin-left: $mat-stepper-line-gap; | |||
} | |||
} | |||
.mat-stepper-alternative-label & { |
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.
nit: \n
src/lib/stepper/stepper.scss
Outdated
&:not(:last-child)::after { | ||
@extend %mat-header-horizontal-line-alternative-label; | ||
right: 0; | ||
} |
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.
nit: \n
src/lib/stepper/stepper.scss
Outdated
&:not(:first-child)::before { | ||
@extend %mat-header-horizontal-line-alternative-label; | ||
left: 0; | ||
} |
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.
nit: \n
src/lib/stepper/stepper.scss
Outdated
& .mat-step-icon, | ||
& .mat-step-icon-not-touched { | ||
margin-right: 0; | ||
} |
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.
nit: \n
src/lib/stepper/stepper.ts
Outdated
export class MatHorizontalStepper extends MatStepper { | ||
/** Whether the label should display in the alternative or normal mode. */ | ||
@Input() | ||
get alternativeLabel(): boolean { return this._alternativeLabel; } |
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.
Although the spec calls it an "alternative label", I don't think it's an intuitive name to give it in the API. How about labelPosition
which can have the following values: bottom
- below the icon, end
- after the icon (to the right in LTR / to the left in RTL). This would also leave open the possibility of future values like top
and start
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.
How should I change CSS classes name with the API you proposed?
label-bottom and label-end don't really seem good names...
I agree with you that alternativeLabel
may not be the perfect name, but I'd prefer leaving it as an on/off property until someone actually needs to put it in top or start position...
(Sorry for delay, I was in vacation)
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.
I'm not saying we should add support for start
and top
right now. I'm just saying that its more clear what the API does if we call it labelPosition
and it leaves us open to adding new values in the future. I think class names like .mat-step-label-position-end
would be good
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.
I should have addressed all of yor concerns.
I did not changed previous code (I did not created a .mat-step-label-position-end
SCSS class) to avoid breaking things (even if that class is actually added to the element for consistency).
Now the alternative label is applied when labelPosition
is set to bottom
<button mat-button (click)="stepper.reset()">Reset</button> | ||
</div> | ||
</mat-step> | ||
</mat-horizontal-stepper> |
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.
nit: \n
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.
src/lib/stepper/stepper.scss
Outdated
// We use auto instead of fixed 104px (by spec) because when there is an optional step | ||
// the height is greater than that | ||
height: auto; | ||
min-width: 100px; |
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.
where does this 100px
come from?
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.
Nowhere currently, the spec doesn't specify a minimum width (or I didn't find it) so I chose one.
Do you have any suggestions about?
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.
Is having a min-width
important to get it to lay out right? if not I would just leave it off and people can specify their own if they want. If we do need one just put it in an SCSS variable
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.
It just shrinks until only the step icon is still visible, making the label useless.
Shall I remove it?
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.
Yeah I think its best to just remove it and let people decide their own min
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.
Fixed RTL and removed min-width
No problem, thank you for pointing it out, I didn't even see that :) |
Awesome, looks good aside from this lint error:
|
Hi @IlCallo! This PR has merge conflicts due to recent upstream merges. |
3 similar comments
Hi @IlCallo! This PR has merge conflicts due to recent upstream merges. |
Hi @IlCallo! This PR has merge conflicts due to recent upstream merges. |
Hi @IlCallo! This PR has merge conflicts due to recent upstream merges. |
Added the "alternative label" version, as by [(old) spec](https://material.io/archive/guidelines/components/steppers.html#steppers-types-of-steppers). Tryed on Chrome, Firefox, Edge and IE11 and everything seems fine. Added a paragraph in the stepper documentation and an example. I'm not sure the code style is ok so if you have suggestions I'll be happy to clean it up a bit, just tell me how :)
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. |
Added the "alternative label" version, as by (old) spec.
Tryed on Chrome, Firefox, Edge and IE11 and everything seems fine.
Added a paragraph in the stepper documentation and an example.
I'm not sure the code style is ok so if you have suggestions I'll be happy to clean it up a bit, just tell me how :)