Skip to content

Commit

Permalink
Add className back to TokenBase (#5420)
Browse files Browse the repository at this point in the history
* Add className back to TokenBase

* Adding tests and fixing implementation

* Create dirty-wasps-behave.md

---------

Co-authored-by: Marie Lucca <[email protected]>
  • Loading branch information
TylerDixon and francinelucca committed Dec 12, 2024
1 parent b2e1fa5 commit f2d188f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-wasps-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Add className back to TokenBase
1 change: 1 addition & 0 deletions packages/react/src/Token/AvatarToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const AvatarToken = forwardRef(({avatarSrc, id, size = defaultTokenSize, classNa
sx={{
paddingLeft: get('space.1'),
}}
className={className}
{...rest}
ref={forwardedRef}
/>
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/Token/IssueLabelToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const IssueLabelToken = forwardRef((props, forwardedRef) => {
text={text}
size={size}
sx={labelStyles}
className={className}
{...(!hasMultipleActionTargets ? interactiveTokenProps : {})}
{...rest}
ref={forwardedRef}
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/Token/Token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const Token = forwardRef((props, forwardedRef) => {
text={text}
size={size}
sx={mergedSx}
className={className}
{...(!hasMultipleActionTargets ? interactiveTokenProps : {})}
{...rest}
ref={forwardedRef}
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/Token/TokenBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const TokenBase = React.forwardRef<HTMLButtonElement | HTMLAnchorElement | HTMLS
onRemove()
}
}}
className={className}
id={id?.toString()}
size={size}
{...rest}
Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/Token/__tests__/Token.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ const testTokenComponent = (Component: React.ComponentType<React.PropsWithChildr
expect(onRemoveMock).toHaveBeenCalled()
})

it('adds className to rendered component', () => {
const {getByText} = HTMLRender(<Component text="token" className="testing-class" />)
const domNode = getByText('token')

expect(domNode.parentElement).toHaveClass('testing-class')
})

it('should have no axe violations', async () => {
const {container} = HTMLRender(<Component text="token" />)
const results = await axe.run(container)
Expand Down

0 comments on commit f2d188f

Please sign in to comment.