Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
60228e1
remove sx support from CircleBadge.tsx
llastflowers Aug 26, 2025
89f3cff
remove sx from docs
llastflowers Aug 26, 2025
55df642
Update CircleBadge to remove sx support
llastflowers Aug 26, 2025
8c2577d
update tests to match updated component
llastflowers Aug 26, 2025
572f588
Merge branch 'main' into llastflowers/5780/no-sx-CircleBadge
llastflowers Sep 5, 2025
726baeb
tests fix for CI
llastflowers Sep 5, 2025
26c05eb
Merge branch 'main' into llastflowers/5780/no-sx-CircleBadge
llastflowers Sep 8, 2025
9909b83
Merge branch 'main' into llastflowers/5780/no-sx-CircleBadge
llastflowers Sep 10, 2025
b42adef
Merge branch 'main' into llastflowers/5780/no-sx-CircleBadge
llastflowers Sep 11, 2025
64c6e06
Merge branch 'main' into llastflowers/5780/no-sx-CircleBadge
llastflowers Sep 15, 2025
dd65b9e
pull in version updates from main and update exports for CircleBadge
llastflowers Sep 15, 2025
91667fb
Merge branch 'main' into llastflowers/5780/no-sx-CircleBadge
llastflowers Sep 17, 2025
b271d41
fix import order
llastflowers Sep 17, 2025
f728b30
Merge branch 'main' of github.com:primer/react into llastflowers/5780…
francinelucca Sep 23, 2025
1704e1a
convert to css modules
francinelucca Sep 23, 2025
09fa5ac
format
francinelucca Sep 23, 2025
e7d7d8c
remove console.log
francinelucca Sep 23, 2025
02da762
fix export
francinelucca Sep 23, 2025
fe993c4
Merge branch 'main' into llastflowers/5780/no-sx-CircleBadge
francinelucca Sep 23, 2025
c4ff809
Create lazy-elephants-shave.md
francinelucca Sep 23, 2025
7fa6fe0
fix props
francinelucca Sep 23, 2025
788f05a
Merge branch 'llastflowers/5780/no-sx-CircleBadge' of github.com:prim…
francinelucca Sep 23, 2025
4e61811
type fixes
francinelucca Sep 23, 2025
1e8c865
lint fix
francinelucca Sep 23, 2025
4894bcb
ignore error
francinelucca Sep 23, 2025
0a70abb
fix(CircleBadge): update snapshots, add className
francinelucca Sep 23, 2025
ce9144f
remove unused import
francinelucca Sep 23, 2025
fada74d
type fixes
francinelucca Sep 23, 2025
d00fba0
Merge branch 'main' into llastflowers/5780/no-sx-CircleBadge
francinelucca Sep 23, 2025
ed8b30b
Merge branch 'main' into llastflowers/5780/no-sx-CircleBadge
francinelucca Sep 23, 2025
9f01823
Merge branch 'main' of github.com:primer/react into llastflowers/5780…
francinelucca Sep 29, 2025
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/cool-apricots-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': major
---

Update CircleBadge component to no longer support sx
6 changes: 6 additions & 0 deletions .changeset/lazy-elephants-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@primer/react": patch
"@primer/styled-react": patch
---

Remove support for `sx` from `CircleBadge` component
5 changes: 0 additions & 5 deletions packages/react/src/CircleBadge/CircleBadge.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
"name": "as",
"type": "React.ElementType",
"defaultValue": "\"div\""
},
{
"name": "sx",
"type": "SystemStyleObject",
"deprecated": true
}
],
"subcomponents": [
Expand Down
18 changes: 18 additions & 0 deletions packages/react/src/CircleBadge/CircleBadge.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.CircleBadge {
display: flex;
align-items: center;
justify-content: center;
background-color: var(--bgColor-default);
border-radius: 50%;
box-shadow: var(--shadow-resting-medium);

&:where([data-inline]) {
display: inline-flex;
}
}

.CircleBadgeIcon {
height: auto;
max-height: 55%;
max-width: 60%;
}
10 changes: 3 additions & 7 deletions packages/react/src/CircleBadge/CircleBadge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ export const Default = () => (
</CircleBadge>
)

export const Playground: StoryFn<typeof CircleBadge> = ({'CircleBadge.Icon aria-label': iconAriaLabel, args}) => (
export const Playground: StoryFn<typeof CircleBadge> = args => (
<CircleBadge {...args}>
<CircleBadge.Icon icon={ZapIcon} aria-label={iconAriaLabel} />
<CircleBadge.Icon icon={ZapIcon} aria-label="Zap" />
</CircleBadge>
)

Playground.args = {
variant: 'medium',
size: null,
size: undefined,
inline: false,
as: 'div',
'CircleBadge.Icon aria-label': undefined,
}

Playground.argTypes = {
Expand All @@ -45,7 +44,4 @@ Playground.argTypes = {
type: 'boolean',
},
},
'CircleBadge.Icon aria-label': {
type: 'string',
},
}
43 changes: 19 additions & 24 deletions packages/react/src/CircleBadge/CircleBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,45 @@
import styled from 'styled-components'
import {get} from '../constants'
import Octicon from '../Octicon'
import type {SxProp} from '../sx'
import sx from '../sx'
import isNumeric from '../utils/isNumeric'
import type {ComponentProps} from '../utils/types'

import styles from './CircleBadge.module.css'
import type {OcticonProps} from '../Octicon'
import {clsx} from 'clsx'

const variantSizes = {
small: 56,
medium: 96,
large: 128,
}

type StyledCircleBadgeProps = {
export type CircleBadgeProps<As extends React.ElementType> = {
inline?: boolean
variant?: keyof typeof variantSizes
size?: number
} & SxProp
as?: As
className?: string
} & React.ComponentPropsWithRef<React.ElementType extends As ? 'a' : As>

const sizeStyles = ({size, variant = 'medium'}: StyledCircleBadgeProps) => {
const sizeStyles = ({size, variant = 'medium'}: CircleBadgeProps<React.ElementType>) => {
const calc = isNumeric(size) ? size : variantSizes[variant]
return {
width: calc,
height: calc,
}
}

const CircleBadge = styled.div<StyledCircleBadgeProps>`
display: ${({inline = false}) => (inline ? 'inline-flex' : 'flex')};
align-items: center;
justify-content: center;
background-color: ${get('colors.canvas.default')};
border-radius: 50%;
box-shadow: ${get('shadows.shadow.medium')};
${sizeStyles};
${sx};
`
const CircleBadgeIcon = styled(Octicon)`
height: auto;
max-width: 60%;
max-height: 55%;
`
const CircleBadge = <As extends React.ElementType>({as: Component = 'div', ...props}: CircleBadgeProps<As>) => (
<Component
{...props}
className={clsx(styles.CircleBadge, props.className)}
data-inline={props.inline ? '' : undefined}
style={sizeStyles(props)}
/>
)

CircleBadgeIcon.displayName = 'CircleBadge.Icon'
const CircleBadgeIcon = (props: OcticonProps) => <Octicon className={styles.CircleBadgeIcon} {...props} />

export type CircleBadgeProps = ComponentProps<typeof CircleBadge>
CircleBadgeIcon.displayName = 'CircleBadge.Icon'

export type CircleBadgeIconProps = ComponentProps<typeof CircleBadgeIcon>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@

exports[`CircleBadge > respects the inline prop 1`] = `
<div
class="sc-gEvEer lNPvJ"
class="prc-CircleBadge-CircleBadge-LZ7wp"
data-inline=""
style="width: 96px; height: 96px;"
/>
`;

exports[`CircleBadge > respects the variant prop 1`] = `
<div
class="sc-gEvEer irZoQl"
class="prc-CircleBadge-CircleBadge-LZ7wp"
style="width: 128px; height: 128px;"
variant="large"
/>
`;

exports[`CircleBadge > uses the size prop to override the variant prop 1`] = `
<div
class="sc-gEvEer ceBMXF"
class="prc-CircleBadge-CircleBadge-LZ7wp"
size="20"
style="width: 20px; height: 20px;"
variant="large"
/>
`;
21 changes: 21 additions & 0 deletions packages/styled-react/src/components/CircleBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
CircleBadge as PrimerCircleBadge,
type CircleBadgeProps as PrimerCircleBadgeProps,
sx,
type SxProp,
} from '@primer/react'
import styled from 'styled-components'
import {type ForwardRefComponent} from '../polymorphic'

type CircleBadgeProps<As extends React.ElementType> = PrimerCircleBadgeProps<As> & SxProp

const CircleBadge: ForwardRefComponent<React.ElementType, CircleBadgeProps<React.ElementType>> = styled(
PrimerCircleBadge,
).withConfig({
shouldForwardProp: prop => (prop as keyof CircleBadgeProps<React.ElementType>) !== 'sx',
})<CircleBadgeProps<React.ElementType>>`
${sx}
`

export {CircleBadge}
export type {CircleBadgeProps}
2 changes: 1 addition & 1 deletion packages/styled-react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export {Breadcrumbs} from '@primer/react'
export {Box, type BoxProps} from './components/Box'
export {Button} from '@primer/react'
export {CheckboxGroup} from '@primer/react'
export {CircleBadge} from '@primer/react'
export {Details} from '@primer/react'
export {FormControl} from '@primer/react'
export {Heading} from '@primer/react'
Expand All @@ -32,6 +31,7 @@ export {useColorSchemeVar} from '@primer/react'
export {useTheme} from '@primer/react'

export {Checkbox, type CheckboxProps} from './components/Checkbox'
export {CircleBadge} from './components/CircleBadge'
export {CounterLabel, type CounterLabelProps} from './components/CounterLabel'
export {Dialog, type DialogProps} from './components/Dialog'
export {Flash} from './components/Flash'
Expand Down
Loading