Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6569f9b
rms styled-system and styled-components usage from IssueLabelToken
mperrotti Aug 25, 2025
575422b
rms styled-system and styled-components usage from ProgressBar
mperrotti Aug 25, 2025
d6a3e9f
rms styled-system and styled-components usage from StateLabel
mperrotti Aug 25, 2025
c576fa1
rms styled-system and styled-components usage from deprecated ActionL…
mperrotti Aug 26, 2025
7f4b498
Merge branch 'main' of github.com:primer/react into mp/rm-sx/misc-com…
mperrotti Aug 26, 2025
f7014f3
rms styled-system and styled-components usage from Caret
mperrotti Aug 26, 2025
17d1834
rms styled-system and styled-components usage from ToggleSwitch
mperrotti Aug 26, 2025
3b335ff
addresses stylelint errors
mperrotti Aug 26, 2025
a282c1d
updates outdated Vitest snapshots
mperrotti Aug 26, 2025
09ea1fc
Merge branch 'main' of github.com:primer/react into mp/rm-sx/misc-com…
mperrotti Aug 26, 2025
059b4be
fixes broken IssueLabelToken bg color in some color modes
mperrotti Aug 26, 2025
00d9906
Merge branch 'main' of github.com:primer/react into mp/rm-sx/misc-com…
mperrotti Aug 26, 2025
89bb919
fixes StateLabel bordered style for dark high-contrast color modes
mperrotti Aug 26, 2025
b9d3c4c
adds changeset
mperrotti Aug 26, 2025
b7b2076
Merge branch 'main' into mp/rm-sx/misc-components
mperrotti Aug 27, 2025
f5f7b19
Merge branch 'main' of github.com:primer/react into mp/rm-sx/misc-com…
mperrotti Aug 27, 2025
8437a2c
fixes ToggleSwitch border color for 'on' state in dark high contrast …
mperrotti Aug 27, 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
9 changes: 9 additions & 0 deletions packages/react/src/ProgressBar/ProgressBar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,13 @@
&:where([data-progress-bar-size='large']) {
height: 10px;
}

/* Width support for containers */
&:where([data-width='auto']) {
width: auto;
}

&:where([data-width='full']) {
width: 100%;
}
}
8 changes: 2 additions & 6 deletions packages/react/src/ProgressBar/ProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React, {forwardRef} from 'react'
import type {WidthProps} from 'styled-system'
import type {SxProp} from '../sx'
import {clsx} from 'clsx'
import classes from './ProgressBar.module.css'
import {BoxWithFallback} from '../internal/components/BoxWithFallback'
Expand All @@ -15,14 +13,12 @@ type StyledProgressContainerProps = {
inline?: boolean
barSize?: 'small' | 'default' | 'large'
animated?: boolean
} & WidthProps &
SxProp
}

export type ProgressBarItems = React.HTMLAttributes<HTMLSpanElement> & {
'aria-label'?: string
className?: string
} & ProgressProp &
SxProp
} & ProgressProp

export const Item = forwardRef<HTMLSpanElement, ProgressBarItems>(
(
Expand Down
95 changes: 95 additions & 0 deletions packages/react/src/StateLabel/StateLabel.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,98 @@
.StateLabel {
display: inline-flex;
align-items: center;
font-weight: var(--base-text-weight-semibold);
/* stylelint-disable-next-line primer/typography */
line-height: 16px;
color: var(--fgColor-onEmphasis);
text-align: center;
border-radius: var(--borderRadius-full);
}

/* Size variants */
.StateLabel:where([data-variant='small']) {
padding: var(--base-size-4) var(--base-size-8);
font-size: var(--text-body-size-small);
}

.StateLabel:where([data-variant='normal']) {
padding: var(--base-size-8) var(--base-size-12);
font-size: var(--text-body-size-medium);
}

/* Status color variants */
.StateLabel:where([data-status='issueClosed']) {
background-color: var(--bgColor-done-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-done-emphasis, transparent);
}

.StateLabel:where([data-status='issueClosedNotPlanned']) {
background-color: var(--bgColor-neutral-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-neutral-emphasis, transparent);
}

.StateLabel:where([data-status='pullClosed']) {
background-color: var(--bgColor-closed-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-closed-emphasis, transparent);
}

.StateLabel:where([data-status='pullMerged']) {
background-color: var(--bgColor-done-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-done-emphasis, transparent);
}

.StateLabel:where([data-status='pullQueued']) {
background-color: var(--bgColor-attention-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-attention-emphasis, transparent);
}

.StateLabel:where([data-status='issueOpened']) {
background-color: var(--bgColor-open-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-open-emphasis, transparent);
}

.StateLabel:where([data-status='pullOpened']) {
background-color: var(--bgColor-open-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-open-emphasis, transparent);
}

.StateLabel:where([data-status='draft']) {
background-color: var(--bgColor-neutral-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-neutral-emphasis, transparent);
}

.StateLabel:where([data-status='issueDraft']) {
background-color: var(--bgColor-neutral-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-neutral-emphasis, transparent);
}

.StateLabel:where([data-status='unavailable']) {
background-color: var(--bgColor-neutral-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-neutral-emphasis, transparent);
}

.StateLabel:where([data-status='open']) {
background-color: var(--bgColor-open-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-open-emphasis, transparent);
}

.StateLabel:where([data-status='closed']) {
background-color: var(--bgColor-done-emphasis);
color: var(--fgColor-onEmphasis);
box-shadow: var(--shadow-inset) var(--borderColor-done-emphasis, transparent);
}

.Icon {
margin-right: var(--base-size-4);
}
6 changes: 0 additions & 6 deletions packages/react/src/StateLabel/StateLabel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,4 @@ Playground.argTypes = {
disable: true,
},
},
theme: {
controls: false,
table: {
disable: true,
},
},
}
146 changes: 26 additions & 120 deletions packages/react/src/StateLabel/StateLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import {
SkipIcon,
IssueDraftIcon,
IssueOpenedIcon,
QuestionIcon,
GitMergeQueueIcon,
AlertIcon,
} from '@primer/octicons-react'
import styled from 'styled-components'
import {variant} from 'styled-system'
import {get} from '../constants'
import type React from 'react'
import {forwardRef} from 'react'
import {clsx} from 'clsx'
import Octicon from '../Octicon'
import type {ComponentProps} from '../utils/types'
import classes from './StateLabel.module.css'

const octiconMap = {
Expand Down Expand Up @@ -48,126 +46,34 @@ const labelMap: Record<keyof typeof octiconMap, 'Issue' | 'Issue, not planned' |
closed: '',
}

const colorVariants = variant({
prop: 'status',
variants: {
issueClosed: {
backgroundColor: 'done.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-done-emphasis, transparent)',
},
issueClosedNotPlanned: {
backgroundColor: 'neutral.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-neutral-emphasis, transparent)',
},
pullClosed: {
backgroundColor: 'closed.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-closed-emphasis, transparent)',
},
pullMerged: {
backgroundColor: 'done.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-done-emphasis, transparent)',
},
pullQueued: {
backgroundColor: 'attention.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-attention-emphasis, transparent)',
},
issueOpened: {
backgroundColor: 'open.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-open-emphasis, transparent)',
},
pullOpened: {
backgroundColor: 'open.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-open-emphasis, transparent)',
},
draft: {
backgroundColor: 'neutral.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-neutral-emphasis, transparent)',
},
issueDraft: {
backgroundColor: 'neutral.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-neutral-emphasis, transparent)',
},
unavailable: {
backgroundColor: 'neutral.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-neutral-emphasis, transparent)',
},
open: {
backgroundColor: 'open.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-open-emphasis, transparent)',
},
closed: {
backgroundColor: 'done.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-done-emphasis, transparent)',
},
},
})

const sizeVariants = variant({
prop: 'variant',
variants: {
small: {
paddingX: 2,
paddingY: 1,
fontSize: 0,
},
normal: {
paddingX: '12px',
paddingY: 2,
fontSize: 1,
},
},
})
Comment on lines -52 to -131
Copy link
Member

Choose a reason for hiding this comment

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

🔥


type StyledStateLabelBaseProps = {
export type StateLabelProps = React.HTMLAttributes<HTMLSpanElement> & {
variant?: 'small' | 'normal'
status: keyof typeof octiconMap
}

const StateLabelBase = styled.span<StyledStateLabelBaseProps>`
display: inline-flex;
align-items: center;
font-weight: ${get('fontWeights.bold')};
line-height: 16px;
color: ${get('colors.canvas.default')};
text-align: center;
border-radius: ${get('radii.3')};
${colorVariants};
${sizeVariants};
`
const StateLabel = forwardRef<HTMLSpanElement, StateLabelProps>(
({children, status, variant: variantProp = 'normal', className, ...rest}, ref) => {
const octiconProps = variantProp === 'small' ? {width: '1em'} : {}
// Open and closed statuses, we don't want to show an icon
const noIconStatus = status === 'open' || status === 'closed'

export type StateLabelProps = ComponentProps<typeof StateLabelBase>
return (
<span
{...rest}
ref={ref}
className={clsx(classes.StateLabel, className)}
data-variant={variantProp}
data-status={status}
>
{!noIconStatus && (
<Octicon {...octiconProps} icon={octiconMap[status]} aria-label={labelMap[status]} className={classes.Icon} />
)}
{children}
</span>
)
},
)

function StateLabel({children, status, variant: variantProp = 'normal', ...rest}: StateLabelProps) {
const octiconProps = variantProp === 'small' ? {width: '1em'} : {}
// Open and closed statuses, we don't want to show an icon
const noIconStatus = status === 'open' || status === 'closed'
return (
<StateLabelBase {...rest} variant={variantProp} status={status}>
{/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */}
{status && !noIconStatus && (
<Octicon
{...octiconProps}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
icon={octiconMap[status] || QuestionIcon}
aria-label={labelMap[status]}
className={classes.Icon}
/>
)}
{children}
</StateLabelBase>
)
}
StateLabel.displayName = 'StateLabel'

export default StateLabel
Loading
Loading