Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

fix(Popup): styles for dark and HC Teams themes #1121

Merged
merged 7 commits into from
Mar 29, 2019

Conversation

kuzhelov
Copy link
Contributor

@kuzhelov kuzhelov commented Mar 27, 2019

TODO

  • update changelog

Fixes #1053.

Provided changes address the problem of Popup styling for Dark and High Contrast Teams themes. In addition, variables that control Popup's content styling were introduced, so that now any custom popup content will be properly displayed with the right set of foreground and background colors.

Now

Dark

image

High Contrast

image

Custom popup content (plain div)

Was (barely noticeable black text on dark background)

image

Now

image

@kuzhelov kuzhelov added 🚀 ready for review 🧰 fix Introduces fix for broken behavior. labels Mar 27, 2019
@codecov
Copy link

codecov bot commented Mar 27, 2019

Codecov Report

Merging #1121 into master will increase coverage by 0.01%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1121      +/-   ##
==========================================
+ Coverage   82.36%   82.37%   +0.01%     
==========================================
  Files         727      729       +2     
  Lines        8674     8679       +5     
  Branches     1232     1232              
==========================================
+ Hits         7144     7149       +5     
  Misses       1515     1515              
  Partials       15       15
Impacted Files Coverage Δ
...t/src/themes/teams/components/Popup/popupStyles.ts 33.33% <ø> (ø) ⬆️
...es/teams/components/Popup/popupContentVariables.ts 66.66% <ø> (ø) ⬆️
...hemes/teams/components/Popup/popupContentStyles.ts 40% <0%> (ø) ⬆️
...rc/themes/teams/components/Popup/popupVariables.ts 100% <100%> (ø) ⬆️
...emes/teams-dark/components/Popup/popupVariables.ts 100% <100%> (ø)
...ams-dark/components/Popup/popupContentVariables.ts 100% <100%> (ø)
...c/themes/teams-high-contrast/componentVariables.ts 100% <100%> (ø) ⬆️
.../react/src/themes/teams-dark/componentVariables.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 845f72f...f4d9fe4. Read the comment docs.

@@ -8,6 +8,8 @@ const popupStyles: ComponentSlotStylesInput<PopupProps, PopupVariables> = {
popup: ({ variables }): ICSSInJSStyle => ({
zIndex: variables.zIndex,
position: 'absolute',
color: variables.contentColor,
background: variables.contentBackgroundColor,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we moved the background style from the PopupContent to the Popup? I'd prefer to see them in it's own component styles, rather then in the popup, especially because they are not anyhow dependent on some props from the Popup component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes - the reason is that we want to see the background and foreground colors being applied to the popup's content irregardless of what is rendered as popup content. Previously we have introduced proper styles only for the cases when PopupContent was rendered at the content slot - however, in case if user would render plain content there, there won't be any background/foreground styles applied at all. Thus, the following code

<Popup ... content={<div>Hello from popup content!</div>} />

would result in the presentation that was mentioned in the PR's description:

image

However, what client really wants here is proper basic styles applied even if plain content is provided to the slot:

image

That's why the variables were moved - note that with that we are not limiting client in overriding styles for the content in case if necessary (so, if content provides its own styles for background and color, then those will be used)

Copy link
Collaborator

@bmdalex bmdalex left a comment

Choose a reason for hiding this comment

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

great job, looks awesome, just couple of comments

}

export default (siteVars: any): PopupVariables => ({ zIndex: 1000 })
export default (siteVars: any): PopupVariables => ({
zIndex: 1000,
Copy link
Collaborator

Choose a reason for hiding this comment

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

how did we come up with this value?

Copy link
Contributor Author

@kuzhelov kuzhelov Mar 29, 2019

Choose a reason for hiding this comment

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

not sure, agreed to use the one that has worked for us back then :) Low numbers might put Popup design at risk, as there might be some client's components that rely on some elements shown on top of the others, and z-index: 1 + relative positioning is always the thing that does this trick. So, admittedly, for the sake of being on a safer side this value was introduced

@@ -8,6 +8,8 @@ const popupStyles: ComponentSlotStylesInput<PopupProps, PopupVariables> = {
popup: ({ variables }): ICSSInJSStyle => ({
zIndex: variables.zIndex,
position: 'absolute',
color: variables.contentColor,
background: variables.contentBackgroundColor,
Copy link
Collaborator

Choose a reason for hiding this comment

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

since now we have relevant styles for Dark and HC themes, can we add a few screenshot tests for these themes for relevant Popup examples?

It'd be great to add some steps too, but that can be in different PR, something like:

  • open a Popup by click and take snapshot
  • open a Popup by key and take snapshot
  • repeat these steps for different variations: inline Popups, Popups with positioning, etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, will take as a follow-up

Copy link
Member

@miroslavstastny miroslavstastny left a comment

Choose a reason for hiding this comment

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

We should find a way how to share styles between ProviderBox and Popup.
After this change, whatever we add to ProviderBox, we need to add it to Popup again.
Moreover, whatever a consumer overrides in ProviderBox, (s)he must override it again for each Popup.
See #1115 as an example of this.

@kuzhelov kuzhelov merged commit 9c4a83d into master Mar 29, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix/popup-styles-for-dark-and-hc branch March 29, 2019 16:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🧰 fix Introduces fix for broken behavior. 🚀 ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants