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(snack-bar): align with 2018 material design spec #12634

Merged
merged 1 commit into from
Aug 23, 2018

Conversation

crisbeto
Copy link
Member

Aligns the snack bar component with the latest Material Design spec.

angular_material_-_google_chrome_2018-08-11_15-11-09
angular_material_-_google_chrome_2018-08-11_15-07-35

@crisbeto crisbeto added the target: major This PR is targeted for the next major release label Aug 11, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 11, 2018
animate(`${AnimationDurations.ENTERING} ${AnimationCurves.DECELERATION_CURVE}`)),
state('void', style({opacity: 0, transform: 'scale(0.8)'})),
state('visible', style({transform: 'scale(1)'})),
transition('* => visible', animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to move away from using the AnimationDurations?

Copy link
Member Author

Choose a reason for hiding this comment

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

I based the timing on the new tooltip animation which looks very similar to this one.

Copy link
Member

Choose a reason for hiding this comment

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

I think we likely can use the same timings as dialog here.

Additionally, we should be able to use accelerate and decelerate easing here

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

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
Copy link
Member

What's the contrast ratio on the text color to background now? Just from the screenshot it doesn't look great

@crisbeto
Copy link
Member Author

Yeah, it's not great, but it's what's in the designs. This is the reason why I kept the old text color for the dark-themed snackbar where the contrast was even worse.

@crisbeto crisbeto force-pushed the snack-bar-new-spec branch from ae6e894 to 8d46e7e Compare August 13, 2018 17:23
@jelbourn
Copy link
Member

Is the ratio an A by W3C guidelines?

@crisbeto
Copy link
Member Author

I haven't looked at the exact ratio and I'm not sure what I'm supposed to use to measure it either.

@jelbourn
Copy link
Member

It's based on the text color and the background color. I always use this tool: https://contrast-ratio.com/

@crisbeto
Copy link
Member Author

According to the tool, it's an AAA contrast (7.15). The text color is rgba(255, 255, 255, 0.7) and the background is #323232.

@jelbourn
Copy link
Member

Ah, that's perfect then.

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Aug 13, 2018
@ngbot
Copy link

ngbot bot commented Aug 13, 2018

I see that you just added the pr: merge ready label, but the following checks are still failing:
    failure status "continuous-integration/travis-ci/pr" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@jelbourn jelbourn added the P2 The issue is important to a large percentage of users, with a workaround label Aug 14, 2018
animate(`${AnimationDurations.EXITING} ${AnimationCurves.ACCELERATION_CURVE}`)),
transition('void => visible-top, void => visible-bottom',
animate(`${AnimationDurations.ENTERING} ${AnimationCurves.DECELERATION_CURVE}`)),
state('void', style({opacity: 0, transform: 'scale(0.8)'})),
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to have styles in the transition() calls?

Could this just be:

 snackBarState: trigger('state', [
    state('void', style({
      opacity: 0,
      transform: 'scale(0.8)'
    })),
    state('visible', style({
      transform: 'scale(1)',
      opacity: 1,
    })),
    transition('* => visible', animate('150ms cubic-bezier(0, 0, 0.2, 1)')),
    transition('* => void', animate('75ms cubic-bezier(0.4, 0.0, 1, 1)')),
  ])

Copy link
Member Author

@crisbeto crisbeto Aug 18, 2018

Choose a reason for hiding this comment

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

Not exactly. The code above will cause it to scale away for the exit animation, but we only want it to fade out. This means that we need a style({opacity: 0}) on the * => void. I've updated it with some tweaks.

@josephperrott josephperrott removed the action: merge The PR is ready for merge by the caretaker label Aug 17, 2018
@crisbeto crisbeto force-pushed the snack-bar-new-spec branch from 8d46e7e to 4e9c779 Compare August 18, 2018 10:52
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Aug 18, 2018
@@ -94,11 +94,11 @@ export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy
onAnimationEnd(event: AnimationEvent) {
const {fromState, toState} = event;

if ((toState === 'void' && fromState !== 'void') || toState.startsWith('hidden')) {
if (toState === 'void' && fromState !== 'void') {
Copy link
Member

@josephperrott josephperrott Aug 23, 2018

Choose a reason for hiding this comment

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

We should not need to check the from state. If we don't take action in cases where we go to void from void then it results in leaving the snackbar-container in the DOM indefinitely.

We should be able to just to if (toState === 'void') {

Copy link
Member Author

@crisbeto crisbeto Aug 23, 2018

Choose a reason for hiding this comment

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

This isn't something I introduced in this PR, I just had to rework the condition. If I remember correctly, the case where we could get the fromState and toState to both be void was on enter, which shouldn't be an issue for this PR.

Here's the commit for reference: crisbeto@8e77261

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, in my testing I didn't see any issue with removing the fromState check. I think the difference now is that we are using void instead of hidden for our hiding state.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm inclined to keep it just because it shouldn't hurt anything and these changes are dangerous enough as they are.

@crisbeto crisbeto force-pushed the snack-bar-new-spec branch from 4e9c779 to 7ce083d Compare August 23, 2018 18:27
Aligns the snack bar component with the latest Material Design spec.
@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 P2 The issue is important to a large percentage of users, with a workaround target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants