Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-turtles-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

update token close button sizing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

18 changes: 6 additions & 12 deletions packages/react/src/Token/TokenBase.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
white-space: nowrap;
border-radius: var(--borderRadius-full);
align-items: center;
/* stylelint-disable-next-line primer/typography */
line-height: 1;
}

.TokenBase:where([data-cursor-is-interactive='true']) {
Expand All @@ -19,42 +21,34 @@

.TokenBase:where([data-size='small']) {
width: auto;
height: 16px;
height: var(--base-size-16);
padding-right: var(--base-size-4);
padding-left: var(--base-size-4);
font-size: var(--text-body-size-small);
/* stylelint-disable-next-line primer/typography */
line-height: 16px;
}

.TokenBase:where([data-size='medium']) {
width: auto;
height: 20px;
height: var(--base-size-20);
padding-right: var(--base-size-8);
padding-left: var(--base-size-8);
font-size: var(--text-body-size-small);
/* stylelint-disable-next-line primer/typography */
line-height: 20px;
}

.TokenBase[data-size='large'] {
width: auto;
height: 24px;
height: var(--base-size-24);
padding-right: var(--base-size-8);
padding-left: var(--base-size-8);
font-size: var(--text-body-size-small);
/* stylelint-disable-next-line primer/typography */
line-height: 24px;
}

.TokenBase[data-size='xlarge'] {
width: auto;
height: 32px;
height: var(--base-size-32);
padding-top: 0;
padding-right: var(--base-size-16);
padding-bottom: 0;
padding-left: var(--base-size-16);
font-size: var(--text-body-size-medium);
/* stylelint-disable-next-line primer/typography */
line-height: 32px;
}
10 changes: 4 additions & 6 deletions packages/react/src/Token/_RemoveTokenButton.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
}

.TokenButton[data-size='medium'] {
width: 20px;
height: 20px;
width: var(--base-size-20);
height: var(--base-size-20);
}

.TokenButton[data-size='large'] {
Expand All @@ -40,11 +40,9 @@

.TokenButton:hover,
.TokenButton:focus {
/* TODO: choose a better functional color variable for this */
background-color: var(--bgColor-neutral-muted);
background-color: var(--control-transparent-bgColor-hover);
}

.TokenButton:active {
/* TODO: choose a better functional color variable for this */
background-color: var(--bgColor-neutral-muted);
background-color: var(--control-transparent-bgColor-active);
}
8 changes: 3 additions & 5 deletions packages/react/src/Token/_RemoveTokenButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type React from 'react'
import {XIcon} from '@primer/octicons-react'
import {clsx} from 'clsx'
import type {TokenSizeKeys} from './TokenBase'
import {tokenSizes, defaultTokenSize} from './TokenBase'
import {defaultTokenSize} from './TokenBase'

import classes from './_RemoveTokenButton.module.css'

Expand All @@ -12,8 +12,6 @@ interface TokenButtonProps {
isParentInteractive?: boolean
}

const getTokenButtonIconSize = (size?: TokenSizeKeys) => parseInt(tokenSizes[size || defaultTokenSize], 10) * 0.75

type RemoveTokenButtonProps = TokenButtonProps & Omit<React.HTMLProps<HTMLSpanElement | HTMLButtonElement>, 'size'>

const RemoveTokenButton = ({
Expand All @@ -39,7 +37,7 @@ const RemoveTokenButton = ({
transform: `translate(${borderOffset}px, -${borderOffset}px)`,
}}
>
<XIcon size={getTokenButtonIconSize(size)} />
<XIcon size={size === 'small' || size === 'medium' || size === 'large' ? 12 : 16} />
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

[nitpick] The repeated conditional logic for icon sizing could be extracted into a helper function or constant mapping for better maintainability and consistency.

Copilot uses AI. Check for mistakes.

</span>
)
}
Expand All @@ -56,7 +54,7 @@ const RemoveTokenButton = ({
ref={rest.ref as React.Ref<HTMLButtonElement>}
type="button"
>
<XIcon size={getTokenButtonIconSize(size)} />
<XIcon size={size === 'small' || size === 'medium' || size === 'large' ? 12 : 16} />
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

[nitpick] This duplicates the same conditional logic from line 40. Consider extracting this into a shared function or constant to avoid code duplication.

Copilot uses AI. Check for mistakes.

</button>
)
}
Expand Down
Loading