Skip to content

Conversation

@lukasoppermann
Copy link
Contributor

Closes https://github.com/github/primer/issues/5274

Changelog

CounterLabel: Deprecated scheme prop in favor of variant prop

New

Changed

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@lukasoppermann lukasoppermann requested a review from a team as a code owner November 12, 2025 07:38
@changeset-bot
Copy link

changeset-bot bot commented Nov 12, 2025

🦋 Changeset detected

Latest commit: 0517d2c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Nov 12, 2025
@github-actions
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

Copilot finished reviewing on behalf of lukasoppermann November 12, 2025 07:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR deprecates the scheme prop in favor of the variant prop for the CounterLabel component, aligning with the design system's naming conventions while maintaining backward compatibility.

  • The variant prop is introduced as the new API with the same values ('primary' | 'secondary')
  • The scheme prop is marked as deprecated with JSDoc annotation
  • Fallback logic ensures variant takes precedence over scheme, with 'secondary' as the default

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
CounterLabel.tsx Added variant prop, deprecated scheme prop, implemented fallback logic with precedence handling, updated data attribute from data-scheme to data-variant
CounterLabel.test.tsx Added tests for the new variant prop (primary and secondary), updated test description to reflect both props, maintained backward compatibility tests for scheme
CounterLabel.stories.tsx Updated Playground story to use variant prop instead of scheme in default args
CounterLabel.features.stories.tsx Updated PrimaryTheme story to use variant prop, kept SecondaryTheme using scheme for backward compatibility demonstration
CounterLabel.module.css Updated CSS selectors from data-scheme to data-variant for primary and secondary styles
.changeset/busy-masks-kiss.md Added changeset documenting the deprecation as a minor version change
Comments suppressed due to low confidence (3)

packages/react/src/CounterLabel/CounterLabel.test.tsx:48

  • This test should verify that the default data-variant attribute is set to 'secondary'. Add an assertion expect(container.firstChild).toHaveAttribute('data-variant', 'secondary') to validate the default behavior.
  it('renders with secondary variant when no "scheme" or "variant" prop is provided', () => {
    const {container} = HTMLRender(<CounterLabel>1234</CounterLabel>)
    expect(container.firstChild).toBeInTheDocument()
    expect(container.firstChild).toHaveTextContent('1234')
  })

packages/react/src/CounterLabel/CounterLabel.test.tsx:48

  • Missing test case for precedence: when both variant and scheme props are provided, variant should take precedence. Add a test like it('gives precedence to variant over scheme when both are provided', () => { const {container} = HTMLRender(<CounterLabel variant=\"primary\" scheme=\"secondary\">1234</CounterLabel>); expect(container.firstChild).toHaveAttribute('data-variant', 'primary'); }) to verify this critical behavior.
  })

packages/react/src/CounterLabel/CounterLabel.stories.tsx:21

  • The argTypes should include configuration for the new variant prop in addition to the deprecated scheme prop. This allows Storybook users to interact with the new API. Add a variant entry with the same control configuration to properly document both the new and deprecated props.
  argTypes: {
    scheme: {
      control: 'select',
      options: ['primary', 'secondary'],
    },
  },

Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

Only minor feedback, approving in advance :)

it('respects the secondary "variant" prop', () => {
const {container} = HTMLRender(<CounterLabel variant="secondary">1234</CounterLabel>)
expect(container.firstChild).toBeInTheDocument()
expect(container.firstChild).toHaveTextContent('1234')
Copy link
Member

Choose a reason for hiding this comment

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

Both of the added tests check for the same thing 🤔

What are we testing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. I somehow just copied the old tests and didn't get that they don't quite make sense.

const {container} = HTMLRender(<CounterLabel>1234</CounterLabel>)
expect(container.firstChild).toBeInTheDocument()
expect(container.firstChild).toHaveTextContent('1234')
})
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a good idea to add this test as well: "prefers variant prop over deprecated scheme prop"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test for that.

lukasoppermann and others added 2 commits November 13, 2025 09:09
Co-authored-by: Siddharth Kshetrapal <siddharthkp@github.com>
Co-authored-by: Siddharth Kshetrapal <siddharthkp@github.com>
@github-actions github-actions bot requested a deployment to storybook-preview-7185 November 13, 2025 08:13 Abandoned
@primer-integration
Copy link

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/6782

@github-actions github-actions bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Nov 13, 2025
@primer-integration
Copy link

🟢 ci completed with status success.

Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

Looks great, ship it

@lukasoppermann lukasoppermann added this pull request to the merge queue Nov 13, 2025
@lukasoppermann lukasoppermann removed the request for review from TylerJDev November 13, 2025 12:34
Merged via the queue into main with commit a05b1f9 Nov 13, 2025
51 checks passed
@lukasoppermann lukasoppermann deleted the @lukasoppermann/counterLabel branch November 13, 2025 12:43
@primer primer bot mentioned this pull request Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants