Skip to content

Add variant prop to Button and ButtonGroup #7197

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

Merged
merged 27 commits into from
Feb 14, 2025

Conversation

ggdouglas
Copy link
Contributor

@ggdouglas ggdouglas commented Jan 24, 2025

Part of #7202

Proposed changes:

Adds a new variant prop to replace the (now deprecated) minimal and outlined props on Button/AnchorButton and ButtonGroup.

@svc-palantir-github
Copy link

Add example and docs

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@svc-palantir-github
Copy link

Add deprecation warnings in console

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@ggdouglas ggdouglas changed the title Add variant prop to Button Add variant prop to Button and ButtonGroup Jan 28, 2025
@svc-palantir-github
Copy link

Add "variant" prop to ButtonGroup component

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@svc-palantir-github
Copy link

Move eslint deprecation lines for multi-line declaration

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@ggdouglas ggdouglas force-pushed the gdouglas/proposal-button-variant branch from 723e7cc to a71f72a Compare February 4, 2025 16:15
@svc-palantir-github
Copy link

Move eslint deprecation lines for multi-line declaration

Build artifact links for this commit: documentation | landing | table | demo

This 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} />`;
Copy link
Contributor Author

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)

@ggdouglas ggdouglas marked this pull request as ready for review February 4, 2025 16:34
@svc-palantir-github
Copy link

Extract ButtonVariant type

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@svc-palantir-github
Copy link

Organize jsdoc declarations

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Comment on lines 109 to 110
[Classes.MINIMAL]: minimal || variant === "minimal",
[Classes.OUTLINED]: outlined || variant === "outlined",
Copy link
Contributor

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 ButtonGroups.

Copy link
Contributor Author

@ggdouglas ggdouglas Feb 4, 2025

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

@svc-palantir-github
Copy link

Add comments heading up constants

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@svc-palantir-github
Copy link

Update Button/ButtonGroup interactive examples with new variant select

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@ggdouglas ggdouglas force-pushed the gdouglas/proposal-button-variant branch from e96ff83 to cd08b19 Compare February 4, 2025 22:08
@svc-palantir-github
Copy link

Refactor variantClass utility

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@ggdouglas ggdouglas force-pushed the gdouglas/proposal-button-variant branch from abf4155 to 86746b6 Compare February 5, 2025 18:26
@svc-palantir-github
Copy link

Simplify types passed to variantClass utility

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

jscheiny
jscheiny previously approved these changes Feb 5, 2025
Copy link
Contributor

@jscheiny jscheiny left a 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

@policy-bot policy-bot bot dismissed jscheiny’s stale review February 12, 2025 18:10

Invalidated by push of a6e75cf

@svc-palantir-github
Copy link

Add `variant` prop to blocklist of removeNonHTMLProps

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@svc-palantir-github
Copy link

Update ESLint deprecation ignore statements

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

jscheiny
jscheiny previously approved these changes Feb 13, 2025
@svc-palantir-github
Copy link

Remove comment that is no longer relevant

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@policy-bot policy-bot bot dismissed jscheiny’s stale review February 14, 2025 02:04

Invalidated by push of a618564

@svc-palantir-github
Copy link

Remove minimal/outlined from ButtonGroup popover example

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@svc-palantir-github
Copy link

Ignore errors constant file in test coverage

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@ggdouglas ggdouglas merged commit d315706 into develop Feb 14, 2025
12 of 13 checks passed
@ggdouglas ggdouglas deleted the gdouglas/proposal-button-variant branch February 14, 2025 03:36
@bvandercar-vt
Copy link
Contributor

Tag component has deprecated size but not deprecated variants.

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