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

Update overlay components to new theme system #209

Merged
merged 7 commits into from
Jul 29, 2019

Conversation

lederer
Copy link
Contributor

@lederer lederer commented Jul 26, 2019

Target Branch

Note this is a request to merge to feature/theme, not develop. All theme-related PRs should target feature/theme until the theme upgrade is complete.

Overview

Updates the following components to the new theme system:

  • Tooltip
  • Dialog

Updates the Dialog docs page with a fully working example and clearer instructions for how to close the dialog.

Checklist

  • Relevant documentation pages have been created or updated
  • Description of PR is in an appropriate section of the changelog and grouped with similar changes if possible
  • Relevant status has been updated on the status page

Upgrade instructions

If there are any of the following in this PR, provide proper instructions on how to upgrade:

  • Changes to the prop names or types of existing components
  • Changes in intended behavior of existing component props
  • Changes in the theme file's structure
  • A required version bump to a non-dev dependency of the project

Notes

Did a some drive-by tweaks to Callout, Breadcrumbs, Button.

This PR does not change the underlying tooltip and dialog libraries used by Tooltip and Dialog.

Testing Instructions

  • Fiddle with the corresponding docs pages

Closes #171
Closes #172
Closes #131
Closes #205

@lederer lederer requested a review from designmatty July 26, 2019 18:16
@lederer
Copy link
Contributor Author

lederer commented Jul 29, 2019

Just added an unrelated fix for Checkbox and Radio vertical alignment.

@lederer
Copy link
Contributor Author

lederer commented Jul 29, 2019

Just added an unrelated fix for Grouper alignment.

@@ -1,24 +1,33 @@
import React from "react";
import PropTypes from "prop-types";
import { transparentize } from "polished";
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

minWidth: ${themeGet("dialog.minWidths.minWidth")};
maxWidth: ${themeGet("dialog.maxWidths.maxWidth")};
minHeight: ${themeGet("dialog.minHeights.minHeight")};
maxHeight: ${themeGet("dialog.maxHeights.maxHeight")};
Copy link
Contributor

Choose a reason for hiding this comment

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

incorrect syntax

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gah! I keep doing that.

@@ -70,7 +79,7 @@ const Dialog = ({
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: `rgba(0, 0, 0, ${themeGet(`opacity.${opacity}`, opacity)(props)})`,
backgroundColor: `rgba(0, 0, 0, ${opacity})`,
Copy link
Contributor

Choose a reason for hiding this comment

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

we might consider allowing user-defined colors here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that – it's actually the source of that stray polished transparentize import – but couldn't get it working. Decided to punt for now. I'll open an issue.

Copy link
Contributor

@designmatty designmatty Jul 29, 2019

Choose a reason for hiding this comment

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

The following should work:

const overlayStyle = {
    ...
    background: transparentize(opacity, backdropColor)
}

And obviously, you would then need to pass backdropColor as a prop and pass a defaultProp value.

Copy link
Contributor

Choose a reason for hiding this comment

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

image
image

Copy link
Contributor

Choose a reason for hiding this comment

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

The biggest downside to this approach is the lack of access to the theme. That might require a larger rewrite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah the problem I had was supporting the overlay color in the theme file too. Would have to add some logic to use the prop if present, else fallback on the theme. We do this a lot inside our styled component definitions, but not in a standalone const. I'm sure it's doable, I just hit a wall and so punted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, yeah that's fair. Agreed on the issue then.

Notable props include `opacity` for adjusting the scrim opacity, `boxShadow` for
setting the dialog drop shadow, and `closeTimeoutMS` for adjusting the transition
timing. Transitions are hard-coded for now. Only the timing is adjustable.
Overlay opacity can be adjusted via the `opacity` prop.
Copy link
Contributor

Choose a reason for hiding this comment

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

If you end up making the suggested change about user-defined colors, update this as well.

@@ -49,7 +45,7 @@ const ButtonLoading = styled.span`
align-items: center;
justify-content: center;

> ${ButtonIcon} {
> .icon {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing wrong with this change, just curious about the decision behind 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.

ButtonIcon was a styled(Icon). I've opted to stop using that syntax entirely (in favor of styled.div or other built-in html elements), so I just used the Icon component directly in the jsx. Hence needed to give it a classname to refer to it here.

@@ -7,47 +7,89 @@ route: /overlays/dialog
import { Playground, Props } from 'docz'
import Dialog from './'
import Button from '../../../core/components/button'
import Heading from '../../../core/components/heading'
Copy link
Contributor

Choose a reason for hiding this comment

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

these imports can simply be '../button' and '../heading'

@@ -1,38 +1,43 @@
import React from "react";
import PropTypes from "prop-types";
import styled, { css } from "styled-components";
Copy link
Contributor

Choose a reason for hiding this comment

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

css import not needed

@lederer
Copy link
Contributor Author

lederer commented Jul 29, 2019

Thanks for catching all those. Ready for another look.

Copy link
Contributor

@designmatty designmatty 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

@lederer lederer merged commit 3a39001 into feature/theme Jul 29, 2019
@lederer lederer deleted the feature/sml/theme-overlays branch July 29, 2019 19:06
alkamin pushed a commit that referenced this pull request Jul 29, 2019
* Add aria-hidden to Callout icon and Breadcrumbs icons

* Remove styled(Icon) from Button. Add aria attributes.

* Update Tooltip to new theme system

* Update Dialog to new theme system

* Align Checkbox and Radio

* Add justify prop to Grouper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants