Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(datepicker): calendar panel theme supports dark mode #11201

Merged
merged 1 commit into from
Apr 10, 2018

Conversation

rudzikdawid
Copy link
Contributor

@rudzikdawid rudzikdawid commented Mar 29, 2018

PR Checklist

Please check that your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

The datepicker calendar panel is always using light mode hues even when the theme is dark mode.

Issue Number:
#11200

What is the new behavior?

The datepicker calendar panel use dark mode hues when the theme is set to dark mode.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Before dark mode:

After dark mode:

After light mode:

@googlebot
Copy link

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. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@googlebot googlebot added the cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ label Mar 29, 2018
@rudzikdawid
Copy link
Contributor Author

rudzikdawid commented Mar 29, 2018

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ and removed cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ labels Mar 29, 2018
@Splaktar Splaktar self-assigned this Mar 30, 2018
@Splaktar Splaktar requested review from crisbeto and Splaktar March 30, 2018 01:39
@Splaktar Splaktar added this to the 1.1.9 milestone Mar 30, 2018
@Splaktar Splaktar added the needs: manual testing This issue or PR needs to have some manual testing and verification done label Mar 30, 2018
@Splaktar
Copy link
Member

Thank you for your contribution! Update the commit message to include Closes #11200 on the last line, after a blank line. I'll try to take a look at the color changes and verify. After looking at the changes, there is one color that I am a little concerned about, but want to test.

@Splaktar Splaktar added type: bug ui: theme P4: minor Minor issues. May not be fixed without community contributions. labels Mar 30, 2018
@rudzikdawid rudzikdawid force-pushed the fixDatepickerPopupTheme branch from f034a52 to 0e927f1 Compare March 30, 2018 07:19
@rudzikdawid
Copy link
Contributor Author

rudzikdawid commented Mar 30, 2018

ok commit message fixed.
I was thinking about

tr:last-child td {
     border-bottom-color: '{{background-200}}';
}

but any value rgba with alpha less than 1: {{background-200-0.2}} makes ugly border.
border-collapse: collapse makes the lines overlap each others. With rgba alpha=1 it's not a problem but with a little bit transparent lines it is big glitch.

that's why i did not change it

@Splaktar
Copy link
Member

Splaktar commented Apr 5, 2018

Please make sure to test effects of your changes in light mode as well. As you can see below, the focused background is much lighter and the day of week background is missing/white.

Before:
screen shot 2018-04-04 at 10 35 51 pm

After:
screen shot 2018-04-04 at 10 35 45 pm

Copy link
Member

@Splaktar Splaktar left a comment

Choose a reason for hiding this comment

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

Please address the changes to light mode (which ideally should be kept the same, or only very slightly modified if the modification is specified by the spec).

@Splaktar Splaktar added in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs and removed needs: manual testing This issue or PR needs to have some manual testing and verification done labels Apr 5, 2018
@rudzikdawid
Copy link
Contributor Author

rudzikdawid commented Apr 5, 2018

https://material.io/guidelines/components/pickers.html#pickers-date-pickers
in official material style guide there is no difference between months header background and calendar background. There is only differences between color of the font.

also in material2 implementation there is no difference between these background colors
https://material.angular.io/components/datepicker/overview

Why in material1 You want keep these background color difference ?
Maybe we should just change the color of the fonts in the months header ?

@rudzikdawid rudzikdawid force-pushed the fixDatepickerPopupTheme branch from 0e927f1 to 808b22f Compare April 5, 2018 20:47
@rudzikdawid
Copy link
Contributor Author

rudzikdawid commented Apr 5, 2018

ok i pushed fix
hover background: '{{background-500-0.33}}'; looks almost the same in light mode as master build
but also its ok i dark mode

Also i changed separeted lines

tr:last-child td {
  border-bottom-color: '{{background-hue-2}}';
}

before:

after:

but still in my opinion we should change background color of months header to the calendar background color. There should be no differences between these background colors. But we can open another issue for that

@Splaktar
Copy link
Member

Splaktar commented Apr 7, 2018

Yes, I think that months header change should be part of a separate issue/PR so that we don't put these changes at additional risk. Thanks for updating. I'll do some manually testing on this soon.

@Splaktar Splaktar added the needs: manual testing This issue or PR needs to have some manual testing and verification done label Apr 7, 2018
Copy link
Member

@Splaktar Splaktar left a comment

Choose a reason for hiding this comment

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

Thank you for putting this together. There appear to be some small differences in light mode themes which I've made notes about.

@@ -28,7 +28,7 @@
.md-calendar-date-selection-indicator {
.md-calendar-date.md-focus &,
&:hover {
background: '{{background-300}}';
background: '{{background-500-0.33}}';
Copy link
Member

Choose a reason for hiding this comment

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

This seems very slightly off in Light mode.

  • master => rgb(224, 224, 224).
  • This branch => rgba(158, 158, 158, 0.33) which converts to rgb(223, 223, 223).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'{{background-500-0.32}}' its better => rgb(224, 224, 224)

}
}
.md-THEME_NAME-theme {
.md-calendar-day-header {
background: '{{background-300}}';
color: '{{background-A200-0.87}}';
background: '{{background-500-0.33}}';
Copy link
Member

Choose a reason for hiding this comment

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

Same as below with being just slightly different than master in light mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be'{{background-500-0.32}}'


tr:last-child td {
border-bottom-color: '{{background-200}}';
border-bottom-color: '{{background-hue-2}}';
Copy link
Member

Choose a reason for hiding this comment

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

Light mode:

  • master => rgb(238, 238, 238)
  • updates => rgb(245, 245, 245)

Copy link
Contributor Author

@rudzikdawid rudzikdawid Apr 8, 2018

Choose a reason for hiding this comment

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

i can't find proper value with alpha channel === 1.0 which looks good in dark mode and also looks the same as master build. Using alpha channel less than 1.0 makes render glitches.
I think '{{background-hue-2}}' is a reasonable compromise. We have very small difference in light mode whitch doesnt' affect on UX and also good dark theme mode.

Copy link
Member

Choose a reason for hiding this comment

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

OK, we can try to presubmit it using that value and see if it gets through.

background: '{{background-A100}}';
color: '{{background-A200-0.87}}';
background: '{{background-hue-1}}';
color: '{{foreground-1}}';
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a simple md-calendar demo?
We have the directive docs but there is no demo for using the md-calendar directly w/o an md-datepicker.

Copy link
Contributor Author

@rudzikdawid rudzikdawid Apr 8, 2018

Choose a reason for hiding this comment

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

md-calendar is name of whole overlapping panel, check DOM tree

<table role="grid" tabindex="0" class="md-calendar" aria-readonly="true">

also you can enter into special calendar mode by open datepicker and click into .md-calendar-month-label

Copy link
Member

Choose a reason for hiding this comment

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

Right, but this is targeting class="md-calendar" via .md-calendar and not the md-calendar element via CSS. md-datepicker doesn't seem to apply the md-calendar class at all.

But just using md-calendar directly seems to apply this class to the table:
screen shot 2018-04-08 at 4 24 52 am

Copy link
Contributor Author

@rudzikdawid rudzikdawid Apr 8, 2018

Choose a reason for hiding this comment

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

md-datepicker doesn't seem to apply the md-calendar class at all.

not exactly. Simple test shows something different:

.md-calendar.md-THEME_NAME-theme {
  background: red;
}

after that whole overlapping panel has red background. So md-datepicker apply .md-calendar class to panel

Copy link
Member

Choose a reason for hiding this comment

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

Interesting. I wasn't able to find the class in the DOM, but I'll take your word for it.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I found it now. Strange that Chrome DevTools search didn't work...

@Splaktar Splaktar removed the needs: manual testing This issue or PR needs to have some manual testing and verification done label Apr 8, 2018
@rudzikdawid rudzikdawid force-pushed the fixDatepickerPopupTheme branch from 808b22f to 1698fb9 Compare April 8, 2018 08:41
@rudzikdawid
Copy link
Contributor Author

rudzikdawid commented Apr 8, 2018

done i pushed fixes

After dark mode:

After light mode:

@Splaktar Splaktar added the needs: manual testing This issue or PR needs to have some manual testing and verification done label Apr 8, 2018
@@ -28,7 +28,7 @@
.md-calendar-date-selection-indicator {
.md-calendar-date.md-focus &,
&:hover {
background: '{{background-300}}';
background: '{{background-500-0.32}}';
}
}

Copy link
Member

Choose a reason for hiding this comment

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

The comments on Lines 47-50 need to be updated as they are no longer accurate. Perhaps just removing ", even on the dark theme," is enough.

Copy link
Member

@Splaktar Splaktar Apr 9, 2018

Choose a reason for hiding this comment

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

.md-calendar-date-disabled,
.md-calendar-month-label-disabled {

I think that we need to update the disabled date/month colors too.

Copy link
Contributor Author

@rudzikdawid rudzikdawid Apr 9, 2018

Choose a reason for hiding this comment

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

You have right https://material.angularjs.org/latest/demo/datepicker
example Only weekends are selectable

i will fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do You think about

.md-calendar-date-disabled,
.md-calendar-month-label-disabled {
  color: '{{foreground-3}}';
}

its a litle bit brighter than background-A200-0.435 in light mode.
But in both modes light/dark looks great.

Copy link
Contributor Author

@rudzikdawid rudzikdawid Apr 9, 2018

Choose a reason for hiding this comment

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

a lot of components use '{{foreground-3}}' in [disabled] selectors.
So its seems right. What do you think? Can we use it?

example '{{foreground-3}}'

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. There is a comment in theming.js:
* {{foreground-3}} - used for disabled text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix was pushed

@Splaktar
Copy link
Member

Splaktar commented Apr 9, 2018

If I use the docs-dark theme with this branch, I'm seeing the following
screen shot 2018-04-09 at 4 11 21 am

If I make a modification to calendar-theme.scss line 3 to:

.md-calendar.md-THEME_NAME-theme,
.md-THEME_NAME-theme .md-calendar {
  background: '{{background-hue-1}}';
  color: '{{foreground-1-0.87}}';

Then I get this:
screen shot 2018-04-09 at 4 15 34 am
Note the black chevron icons and white popup border.

I'm not sure why I am seeing such a difference from the screenshots that you posted.

@Splaktar Splaktar removed the needs: manual testing This issue or PR needs to have some manual testing and verification done label Apr 9, 2018
@rudzikdawid
Copy link
Contributor Author

rudzikdawid commented Apr 9, 2018

i used

$mdThemingProvider.theme('default')
      .primaryPalette('docs-blue')
      .accentPalette('docs-red')
      .dark();

i dont see dark icons in dark theme. Also with this config i have bright icons:

$mdThemingProvider.theme('default')
      .primaryPalette('yellow')
      .dark();

@rudzikdawid rudzikdawid force-pushed the fixDatepickerPopupTheme branch from 1698fb9 to b8ffb2a Compare April 9, 2018 08:31
@Splaktar
Copy link
Member

Splaktar commented Apr 9, 2018

OK, yeah, changing the theme works best in docs/app/js/app.js rather than in the examples themselves.

Copy link
Member

@Splaktar Splaktar left a comment

Choose a reason for hiding this comment

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

LGTM

@Splaktar Splaktar added pr: merge ready This PR is ready for a caretaker to review pr: lgtm This PR has been approved by the reviewer and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Apr 9, 2018
@Splaktar Splaktar assigned jelbourn and unassigned Splaktar Apr 9, 2018
@jelbourn jelbourn assigned tinayuangao and unassigned jelbourn Apr 9, 2018
@tinayuangao tinayuangao merged commit 2360764 into angular:master Apr 10, 2018
chmelevskij pushed a commit to chmelevskij/material that referenced this pull request Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ P4: minor Minor issues. May not be fixed without community contributions. pr: lgtm This PR has been approved by the reviewer pr: merge ready This PR is ready for a caretaker to review type: bug ui: theme
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants