-
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
Add variant
prop to Button and ButtonGroup
#7197
base: develop
Are you sure you want to change the base?
Conversation
Generate changelog in
|
Add example and docsBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Add deprecation warnings in consoleBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
variant
prop to Buttonvariant
prop to Button and ButtonGroup
Add "variant" prop to ButtonGroup componentBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Move eslint deprecation lines for multi-line declarationBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
723e7cc
to
a71f72a
Compare
Move eslint deprecation lines for multi-line declarationBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
@@ -51,12 +65,12 @@ export const ButtonOutlinedExample: React.FC<ExampleProps> = props => { | |||
const code = dedent` | |||
<Button text="Outlined" outlined={true} /> | |||
<Button text="Primary" outlined={true} intent="primary" /> | |||
<Button text="Disabled" minimal={true} disabled={true} />`; |
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 was a typo in the current Button outlined example (unrelated to the rest of these changes)
@@ -120,3 +120,11 @@ export const OVERLAY_WITH_MULTIPLE_CHILDREN_REQUIRES_CHILD_REFS = | |||
ns + ` <Overlay2> requires childRefs prop when rendering multiple child elements`; | |||
export const OVERLAY_CHILD_REQUIRES_KEY = | |||
ns + ` <Overlay2> requires each child element to have a unique key prop when childRefs is used`; | |||
|
|||
// prop deprecation warnings |
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 will be quite a few other warnings related to prop deprecations in upcoming PRs, so creating a new section to house them here.
blueprint/packages/core/src/common/errors.ts
Lines 130 to 151 in 61b79df
export const BUTTON_WARN_LARGE = deprecatedSizeWarning("Button", "large"); | |
export const BUTTON_WARN_SMALL = deprecatedSizeWarning("Button", "small"); | |
export const BUTTON_GROUP_WARN_LARGE = deprecatedSizeWarning("ButtonGroup", "large"); | |
export const CHECKBOX_WARN_LARGE = deprecatedSizeWarning("Checkbox", "large"); | |
export const COMPOUND_TAG_WARN_LARGE = deprecatedSizeWarning("CompoundTagInput", "large"); | |
export const FILE_INPUT_WARN_LARGE = deprecatedSizeWarning("FileInput", "large"); | |
export const FILE_INPUT_WARN_SMALL = deprecatedSizeWarning("FileInput", "small"); | |
export const INPUT_WARN_LARGE = deprecatedSizeWarning("InputGroup", "large"); | |
export const INPUT_WARN_SMALL = deprecatedSizeWarning("InputGroup", "small"); | |
export const MENU_WARN_LARGE = deprecatedSizeWarning("Menu", "large"); | |
export const MENU_WARN_SMALL = deprecatedSizeWarning("Menu", "small"); | |
export const NUMERIC_INPUT_WARN_LARGE = deprecatedSizeWarning("NumericInput", "large"); | |
export const NUMERIC_INPUT_WARN_SMALL = deprecatedSizeWarning("NumericInput", "small"); | |
export const RADIO_WARN_LARGE = deprecatedSizeWarning("Radio", "large"); | |
export const SEGMENTED_CONTROL_WARN_LARGE = deprecatedSizeWarning("SegmentedControl", "large"); | |
export const SEGMENTED_CONTROL_WARN_SMALL = deprecatedSizeWarning("SegmentedControl", "small"); | |
export const SWITCH_WARN_LARGE = deprecatedSizeWarning("Switch", "large"); | |
export const TABS_WARN_LARGE = deprecatedSizeWarning("Tabs", "large"); | |
export const TAG_INPUT_WARN_LARGE = deprecatedSizeWarning("TagInput", "large"); | |
export const TAG_WARN_LARGE = deprecatedSizeWarning("Tag", "large"); | |
export const TEXT_AREA_WARN_LARGE = deprecatedSizeWarning("TextArea", "large"); | |
export const TEXT_AREA_WARN_SMALL = deprecatedSizeWarning("TextArea", "small"); |
Extract ButtonVariant typeBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Organize jsdoc declarationsBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
[Classes.MINIMAL]: minimal || variant === "minimal", | ||
[Classes.OUTLINED]: outlined || variant === "outlined", |
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 bit of code has some unintended side effects. I think that we should make the behavior be that variant
supersedes both outlined
and minimal
. However, if we do the following:
<Button text="Button" variant="minimal" outlined={true} />
We end up with an outlined button instead of a minimal button as would be hoped for. The same issue occurs with ButtonGroup
s.
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.
Technically, this behavior already exists between the minimal
and outlined
props where outlined
overwrites the styles of minimal
if both are applied simultaneously.
<Button text="Button" minimal={true} outlined={true} />
I think it is fair, however, that we wouldn't want to continue this behavior!
a2889bd wraps the logic into a utility function, providing the proper application of classes based on precedence. This technically changes the behavior of the presence of classes (for the case described above), but in practice it doesn't matter much since, as we've established, the outlined
classes overwrite minimal
anyways.
Edit: fd62b36 preserves the existing behavior
Add comments heading up constantsBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Update Button/ButtonGroup interactive examples with new variant selectBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
e96ff83
to
cd08b19
Compare
Update Button/ButtonGroup interactive examples with new variant selectBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
Refactor variantClass utilityBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
abf4155
to
86746b6
Compare
Simplify types passed to variantClass utilityBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
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.
LGTM! Excited about this change
@@ -22,14 +22,29 @@ visual style, it’s recommended to apply the same `intent` to all buttons withi | |||
|
|||
@reactCodeExample ButtonGroupIntentExample | |||
|
|||
@## Variant | |||
|
|||
Most of **ButtonGroup**'s props are also supported by [**Button**](#core/components/buttons) directly. Setting these props on **ButtonGroup** will apply the same value to all buttons in the group. Note that most modifiers, once enabled on the group, cannot be overridden on child buttons (due to the cascading nature of CSS). |
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 bit feels a bit incongruous in this position, which is refering to a specific prop. Its also duplicated in the outlined and minimal section below. I think we should take this section and move it to the top of the page and remove it from both of these sections.
Part of #7202
Proposed changes:
Adds a new
variant
prop to replace the (now deprecated)minimal
andoutlined
props onButton
/AnchorButton
andButtonGroup
.