Skip to content

Use system colors for tooltip and snackbar components#14524

Merged
Gio2018 merged 10 commits intodevelopfrom
issue/14136-notice-background-color
Jul 28, 2020
Merged

Use system colors for tooltip and snackbar components#14524
Gio2018 merged 10 commits intodevelopfrom
issue/14136-notice-background-color

Conversation

@Gio2018
Copy link
Copy Markdown
Contributor

@Gio2018 Gio2018 commented Jul 24, 2020

Fixes #14136

This PR changes the colors used in all Notices (Tooltips and snackbar components), as listed below:

os iOS 13 or later iOS 12
Background inverted systemGray5 rgba(44.0, 44.0, 46.0, 1.0)
Primary title inverted label white
Secondary title/text inverted secondaryLabel rgba(235.0, 235.0, 245.0, 0.6)
Action primary blue (shade40) primary blue (shade40)

Note: inverted colors are system colors of the opposite appearance. For example, inverted systemGray5 means that in light appearance, we are using the value of systemGray5 from dark appearance, etc

here are some screenshots for reference

element light appearance dark appearance
FAB
QuickStart step
QuickStart suggest
Reader actions

To test:

  • make a fresh install (so that the FAB tooltip will be shown)
  • create a site and tap "yes help me" when prompted, so that the quick start will begin
  • perform actions in the reader
  • in all these steps, verify that the tooltips, snackbars and toast look as expected and do not have visual bugs in both dark and light appearance, as well as on iOS 12.

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@Gio2018 Gio2018 added this to the 15.5 milestone Jul 24, 2020
@Gio2018 Gio2018 self-assigned this Jul 24, 2020
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Jul 24, 2020

You can trigger an installable build for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Jul 24, 2020

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@Gio2018 Gio2018 marked this pull request as draft July 24, 2020 20:53
@Gio2018 Gio2018 marked this pull request as ready for review July 25, 2020 16:55
Copy link
Copy Markdown
Contributor

@frosty frosty 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 to me! I'm not a designer, so I'll let them weigh in about the visual appearance :)

actionButton.titleLabel?.adjustsFontForContentSizeCategory = true
actionButton.setTitleColor(.white, for: .normal)
if #available(iOS 13.0, *) {
actionButton.setTitleColor(.label, for: .normal)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you move this to the NoticeStyle extension as another var? actionButtonTitleColor or something, and handle the if #available there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure!

@osullivanchris
Copy link
Copy Markdown

@Gio2018 @frosty

Hey the colors look good...But I think you might have flipped light and dark mode? i.e. I expect a dark tooltip/snackbar on light mode, and a light one on dark mode. But I'm seeing light on light, and dark on dark. Unless I'm missing a design decision or other reason that we changed it!

@Gio2018
Copy link
Copy Markdown
Contributor Author

Gio2018 commented Jul 27, 2020

Hey @osullivanchris !

Hey the colors look good...But I think you might have flipped light and dark mode?

the systemGray5 background, which is what is specified in #14136 adjusts automatically in light and dark mode (will be darker in dark mode, lighter in light mode). Should we replace this background with a different shade for the background and the tiltles? @iamthomasbishop, thoughts?

@iamthomasbishop
Copy link
Copy Markdown

Ah good catch, @osullivanchris. That was my intention, and we discussed this early on but I must've missed the detail when reviewing the screenshots in isolation last week (my bad @Gio2018 !). The colors should be inverted:

  • Light mode: dark-gray background (systemGray5 from dark mode)
  • Dark mode: light-gray background (systemGray5 from light mode)

Note: text colors should also be inverted as a result.

@Gio2018
Copy link
Copy Markdown
Contributor Author

Gio2018 commented Jul 27, 2020

Oh I see now @osullivanchris and @iamthomasbishop !

Sorry about the confusion, I misread this in the original issue, it was stated that the colors were to be inverted.

The only issue is that, as far as I know, there is no way to automatically "invert" the system colors between dark and light appearance, so the solution would be to use custom colors, that look like the system colors in the opposite appearance. While this is perfectly feasible, we would not be really using system colors (which I thought it was one of the goals of #14136), because, for example, iOS in light appearance has no system-equivalent of rgba[44.0, 44.0, 46.0, 1.0], which is systemGray5 in dark mode.
Another alternative is to find, among the available system colors, those that 'almost' match the inverted look that we are looking for. What do you think?

@frosty
Copy link
Copy Markdown
Contributor

frosty commented Jul 27, 2020

@Gio2018 I think you should be able to make use of some of our existing UIColor convenience methods to add a 'flipped' version of e.g. systemGray5 to UIColor in an extension. For example:

extension UIColor {
    static var invertedSystem5: UIColor {
        let originalDark = UIColor.systemGray5.color(for: UITraitCollection(userInterfaceStyle: .dark))
        let originalLight = UIColor.systemGray5.color(for: UITraitCollection(userInterfaceStyle: .light))

        return UIColor(light: originalDark, dark: originalLight)
    }
}

This only takes care of iOS 13+ – you'd need to check for that and do something a little different for earlier OS versions. Do you think this could work?

One thing to note is that Apple recommends against hard-coding the color values for their system colors, so the above would be preferable. 🙂

@Gio2018
Copy link
Copy Markdown
Contributor Author

Gio2018 commented Jul 27, 2020

Hey @frosty !

I think you should be able to make use of some of our existing UIColor convenience methods to add a 'flipped' version of e.g. systemGray5 to UIColor in an extension
Do you think this could work?

I believe it could. To be noted that even if we are using colors that are derived from system colors, these are, in fact, custom colors.
Not an issue by itself, I just wanted to point this out. It's a subtle difference, but especially for semantically defined system colors (e.g. label which we are using for the primary text in notices) we might not be using it strictly as intended.

Apple recommends against hard-coding the color values for their system colors, so the above would be preferable.

I agree, this implementation (for iOS 13+) has the advantage of not hardcoding RGB values. For iOS 12, I think the only option is instead to hardcode them?

actionButton.titleLabel?.adjustsFontForContentSizeCategory = true
actionButton.setTitleColor(.white, for: .normal)
actionButton.setTitleColor(notice.style.actionButtonTitleColor, for: .normal)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

@Gio2018
Copy link
Copy Markdown
Contributor Author

Gio2018 commented Jul 27, 2020

@osullivanchris , @iamthomasbishop , @frosty , colors are now updated to use their "inverted" version

Copy link
Copy Markdown

@osullivanchris osullivanchris left a comment

Choose a reason for hiding this comment

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

Hey looks great now @Gio2018 ! Thanks for the new build.

I can totally understand why this is not fully out-of-the-box as we're effectively using dark colors in light mode and light colors in dark mode. But everything looks good visually to me, and as I understand you were able to do it without much customisation. And we're using the same code across all tooltips and snackbars which is a win too.

@iamthomasbishop
Copy link
Copy Markdown

Looks really solid overall, @Gio2018 ! One minor thing: are we using blue 40 on both light/dark mode (I believe so based on the description above)? If so, can we use our standard link colors, which are blue 50 in light mode and blue 30 in dark mode? That'd help to provide a bit more contrast against the backgrounds.

Other than that, everything looks good to go. Thank you!

@Gio2018
Copy link
Copy Markdown
Contributor Author

Gio2018 commented Jul 28, 2020

Hey @iamthomasbishop !

are we using blue 40 on both light/dark mode (I believe so based on the description above)?

I'd say so, I kept the existing setting on this one

If so, can we use our standard link colors, which are blue 50 in light mode and blue 30 in dark mode?

Sure! I assume they should also be inverted like all the other colors in the notices? I am asking because if I don't invert them, they seem a little less readable. Here are example screenshots of both scenarios:

colors light appearance dark appearance
light: shade50, dark: shade30 light50Dark30_light light50Dark30_dark
ight: shade30, dark: shade50 light30Dark50_light light30Dark50_dark

@iamthomasbishop
Copy link
Copy Markdown

I assume they should also be inverted like all the other colors in the notices? I am asking because if I don't invert them, they seem a little less readable.

@Gio2018 Ahh okay, if we're automatically inverting the colors, the second examples you shared look correct (light: shade30, dark: shade50).

@Gio2018 Gio2018 merged commit 4b642f6 into develop Jul 28, 2020
@Gio2018 Gio2018 deleted the issue/14136-notice-background-color branch July 28, 2020 18:03
@frosty
Copy link
Copy Markdown
Contributor

frosty commented Jul 28, 2020

@Gio2018 I just noticed one other thing on this PR – in dark mode (light backgrounds) we lose the dividers between the content and buttons of the larger quick start notice:

Screenshot 2020-07-28 at 20 15 55

Is that something we could address separately?

@Gio2018
Copy link
Copy Markdown
Contributor Author

Gio2018 commented Jul 28, 2020

in dark mode (light backgrounds) we lose the dividers between the content and buttons of the larger quick start notice:
Is that something we could address separately?

@frosty sure! I just merged this PR but I can open a new one for this specific issue. It looks like right now we are using white with alpha = 0.25 for both light and dark appearance. @iamthomasbishop , @osullivanchris what color should we use for the dividers in dark mode/light notice backgrounds? Is the existing ok for light mode/dark backgrounds ok, or should we change it too?
Thanks!!

@iamthomasbishop
Copy link
Copy Markdown

@Gio2018 can we use Separator (flipped between light/dark modes, obviously)? If not, can we use the equivalent rgba values or opaque rgb values (happy to provide those if needed)?

@Gio2018
Copy link
Copy Markdown
Contributor Author

Gio2018 commented Jul 28, 2020

@Gio2018 can we use Separator (flipped between light/dark modes, obviously)? If not, can we use the equivalent rgba values or opaque rgb values (happy to provide those if needed)?

Sure we can! I'll do similarly to what I did for the other colors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Use system-defined grays for Tooltip and Snackbar components'

5 participants