-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
flex button #2078
Merged
Merged
flex button #2078
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7f6fca4
sweet pt-flex-container mixin
71030fe
break margin logic into default, last
06f3476
add "Icons only" switch to button and button group examples
5902e4b
pt-button-base() is inline flex row
666d664
remove button margins (applied by flex mixin now) and fix icon-only
00291df
Button renders text and children inside .pt-fill container
1067052
multiline and alignment support in styles
bd44590
add align prop to Button and ButtonGroup
788f97b
add AlignmentSelect to ButtonGroup examples
4e51013
fix row margin when large, right icon spacing in CSS API
1ccd10f
fix buttons in input group
a4e4b67
control-group uses pt-flex-container (already used flex)
3e84b00
let flex figure out heights of numeric-input buttons :ok_hand:
7d51281
align => alignText, add more button classes
6d47583
Merge branch 'develop' of github.com:palantir/blueprint into gg/flex-…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2018 Palantir Technologies, Inc. All rights reserved. | ||
// Licensed under the terms of the LICENSE file distributed with this project. | ||
|
||
// this element becomes a flex container in the given direction. | ||
// supply `$margin` to put space between each child. | ||
// supply `$inline: inline` to use `display: flex-inline`. | ||
// customize `flex: 1 1` child selector with $fill. | ||
@mixin pt-flex-container($direction: row, $margin: none, $inline: none, $fill: ".pt-fill") { | ||
@if $inline == inline or $inline == true { | ||
display: inline-flex; | ||
} @else { | ||
display: flex; | ||
} | ||
flex-direction: $direction; | ||
|
||
> * { | ||
flex: 0 0 auto; | ||
} | ||
|
||
> #{$fill} { | ||
flex: 1 1 auto; | ||
} | ||
|
||
@if $margin != none { | ||
@include pt-flex-margin($direction, $margin); | ||
} | ||
} | ||
|
||
// applies margin along axis of direction between every direct child, with no margins on either end. | ||
// $direction: row | column | ||
// $margin: margin[-right|-bottom] value | ||
@mixin pt-flex-margin($direction, $margin) { | ||
$margin-prop: if($direction == row, margin-right, margin-bottom); | ||
|
||
// CSS API support | ||
&::before, | ||
// space after all children | ||
> * { | ||
#{$margin-prop}: $margin; | ||
} | ||
|
||
// remove space after last child | ||
&:empty::before, | ||
> :last-child { | ||
#{$margin-prop}: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,14 @@ import * as Classes from "../../common/classes"; | |
import { IProps } from "../../common/props"; | ||
|
||
export interface IButtonGroupProps extends IProps, React.HTMLProps<HTMLDivElement> { | ||
/** | ||
* Text alignment of button contents. | ||
* `align="left"` will left-align button text and push `rightIcon` to right side. | ||
* `align="right"` right-aligns text and pushes `icon` to left side. | ||
* This prop only has an effect if buttons are wider than their default widths. | ||
*/ | ||
align?: "left" | "center" | "right"; | ||
|
||
/** | ||
* Whether the button group should take up the full width of its container. | ||
* @default false | ||
|
@@ -41,13 +49,15 @@ export class ButtonGroup extends React.PureComponent<IButtonGroupProps, {}> { | |
public static displayName = "Blueprint2.ButtonGroup"; | ||
|
||
public render() { | ||
const { className, fill, minimal, large, vertical, ...htmlProps } = this.props; | ||
const { align, className, fill, minimal, large, vertical, ...htmlProps } = this.props; | ||
const buttonGroupClasses = classNames( | ||
Classes.BUTTON_GROUP, | ||
{ | ||
[Classes.ALIGN_LEFT]: align === "left", | ||
[Classes.ALIGN_RIGHT]: align === "right", | ||
[Classes.FILL]: fill, | ||
[Classes.MINIMAL]: minimal, | ||
[Classes.LARGE]: large, | ||
[Classes.MINIMAL]: minimal, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would prefer not to add tangential new props in this PR. |
||
[Classes.VERTICAL]: vertical, | ||
}, | ||
className, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍 😍 😍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this conflicts somewhat with the
NavbarGroup
align prop -- here, you are referring to the alignment of content while for NavbarGroup (as well as most design tools),align
refers to the component's alignment in its container. I suggest renaming this totextAlignment
oralignText
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm yes good catch @adidahiya! i'll go with
alignText