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

Add variant prop to Button and ButtonGroup #7197

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from

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.

@changelog-app
Copy link

changelog-app bot commented Jan 24, 2025

Generate changelog in packages/core/changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Add variant prop to Button


Generate changelog in packages/docs-app/changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Add variant prop to Button


Check the box to generate changelog(s)

  • Generate changelog entry

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

@@ -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
Copy link
Contributor Author

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.

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");

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

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

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

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

@@ -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).
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 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.

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.

3 participants