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

Refactor buttons borders #537

Merged
merged 5 commits into from
Jan 26, 2017
Merged

Refactor buttons borders #537

merged 5 commits into from
Jan 26, 2017

Conversation

llorca
Copy link
Contributor

@llorca llorca commented Jan 24, 2017

Fixes #233, countless of unreported button groups and control groups visual issues

Changes proposed in this pull request:

  • Refactor buttons to use box shadows instead of borders
  • Add new variable to deal with buttons on top of non-plain content: $button-box-shadow-overlay
  • Update shadow values for buttons (done with @piotrk)

Reviewers should focus on:

  • Play with button groups and control groups in both themes, including with disabled buttons/inputs, readonly inputs, and all kinds of weird combinations that you can think of.
  • Make sure everything is aligned and that there's no blurry edge or pixels.

Screenshot

Example from #233.

Before:
image

After:
image

@blueprint-bot
Copy link

Fix stacking and alignment of elements in control groups

Preview: docs
Coverage: core | datetime

@adidahiya
Copy link
Contributor

Interesting, you're proposing going back to box shadows? What are the tradeoffs / remind me why we moved away from box shadows in the first place?

@llorca
Copy link
Contributor Author

llorca commented Jan 25, 2017

Hehe, glad you're asking. Yes, we're basically going back to box-shadow. Borders were a good experiment but in the end, they're too hard to maintain and iterate on for a few reasons:

  • borders take up space unlike shadows, therefore changing the box-sizing of elements. This PR gets rid of unwanted maths in a few places (- $button-border-width * 2 for instance)
  • borders are defined for every direction, making them verbose and adding constraints in button groups and control groups configurations. With shadows, there's no need to remove a border-right in button groups for instance; the same shadow works in all configurations
  • can't stack borders with drop shadows (I discovered that after merging the border approach a while ago, sad times)
  • alignment of control group elements was messed up for a while in dark theme
  • some <select> configuration (.pt-large in particular) had their text that was not vertically centered
  • have to manage the value of box-sizing in addition to border

Shadows solve all of the above problems, + more. Why did I even use borders in the first place? It was because we wanted the default light theme button to have their border outside of the background shape, which we can't achieve with a box-shadow on a single element (we can, but the button would look 2px taller). Now we're back to shadows, the way I solve this problem is by using an alternative set of box shadows ($button-box-shadow-overlay) in required cases: switches and sliders.

@llorca
Copy link
Contributor Author

llorca commented Jan 25, 2017

The shadow stuff from this PR is actually not that interesting because it's super straightforward and easy to understand. The meaty stuff is the z-index ordering in button groups and control groups

@adidahiya
Copy link
Contributor

@llorca Thanks for explaining. I think it would be really great to include that explanation of tradeoffs in code comments.

@llorca
Copy link
Contributor Author

llorca commented Jan 25, 2017

@adidahiya I thought about it but didn't so appropriate for code comments. I can do it, however it will be quite a large block of comments to explain all of that

@adidahiya
Copy link
Contributor

@llorca yeah, a large block comment is totally reasonable, and IMO preferable when there are important design decisions that are hard to glean from just reading code

@llorca
Copy link
Contributor Author

llorca commented Jan 25, 2017

Cool, I'll add a block comment describing the tradeoffs between borders and buttons 👍

@llorca
Copy link
Contributor Author

llorca commented Jan 25, 2017

Tried to keep the comment as short as possible. How's that?

@blueprint-bot
Copy link

Add comment explaining why we’re not using borders

Preview: docs
Coverage: core | datetime

Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

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

🔥 this is so hot!

@@ -13,45 +13,67 @@ $button-border-width: 1px !default;
$button-padding: 0 $pt-grid-size !default;
$button-padding-large: 0 ($pt-grid-size * 1.5) !default;
$button-icon-spacing: ($pt-button-height - $pt-icon-size-standard) / 2 !default;
$button-icon-spacing-large: ($pt-button-height-large - $pt-icon-size-large) / 2 !default;
$button-icon-spacing-large: ($pt-button-height-large - $pt-icon-size-standard) / 2 !default;
Copy link
Contributor

Choose a reason for hiding this comment

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

dbl check that this is correct

}

&:active,
&.pt-active {
z-index: 4;
z-index: 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

brief code comments outlining the z-index layers here might be helpful

&:not(.pt-minimal) {
> .pt-popover-target:not(:last-child) .pt-button,
> .pt-button:not(:last-child) {
margin-right: $button-border-width;
Copy link
Contributor

Choose a reason for hiding this comment

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

explain this huge selector

$button-intent-box-shadow-active:
inset 0 0 0 $button-border-width rgba($black, 0.4),
inset 0 1px 2px rgba($black, 0.2) !default;
$button-box-shadow-overlay:
Copy link
Contributor

Choose a reason for hiding this comment

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

explain when to use -overlay vs regular shadows? something about shadows blending with elements beneath

@blueprint-bot
Copy link

Add a bunch of explanations in comments

Preview: docs | table
Coverage: core | datetime

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

Successfully merging this pull request may close these issues.

4 participants