Skip to content

Conversation

joshblack
Copy link
Member

Closes #6791

Changelog

New

Changed

  • Update how we render the icons to use an object instead of a function to look up the correct asset

Removed

  • Remove support for sx from InlineMessage

Rollout strategy

  • Major release; if selected, include a written rollout or migration plan

This component has no sx usage downstream and is safe to remove

@Copilot Copilot AI review requested due to automatic review settings September 9, 2025 17:14
@joshblack joshblack requested a review from a team as a code owner September 9, 2025 17:14
@joshblack joshblack requested a review from pksjce September 9, 2025 17:14
Copy link

changeset-bot bot commented Sep 9, 2025

🦋 Changeset detected

Latest commit: 3780ad0

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

This PR includes changesets to release 2 packages
Name Type
@primer/react Major
@primer/styled-react Major

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 staff Author is a staff member label Sep 9, 2025
Copy link
Contributor

@Copilot 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 removes support for the sx prop from the InlineMessage component as part of a major release. The change simplifies the component by removing the styling prop interface and refactoring icon handling to use static objects instead of functions.

Key changes:

  • Remove sx prop support and related type definitions
  • Replace function-based icon lookup with static object-based approach
  • Switch from BoxWithFallback to native div element

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/react/src/InlineMessage/InlineMessage.tsx Remove sx prop support, refactor icon handling to use objects, and replace BoxWithFallback with div
.changeset/shy-flies-marry.md Add changeset entry documenting the breaking change

Comment on lines +19 to 38
const icons: Record<MessageVariant, React.ReactNode> = {
warning: <AlertIcon className={classes.InlineMessageIcon} />,
critical: <AlertIcon className={classes.InlineMessageIcon} />,
success: <CheckCircleIcon className={classes.InlineMessageIcon} />,
unavailable: <AlertIcon className={classes.InlineMessageIcon} />,
}

const variantToSmallIcon = (variant: MessageVariant): React.ReactNode => {
const icons = {
warning: <AlertFillIcon className={classes.InlineMessageIcon} size={12} />,
critical: <AlertFillIcon className={classes.InlineMessageIcon} size={12} />,
success: <CheckCircleFillIcon className={classes.InlineMessageIcon} size={12} />,
unavailable: <AlertFillIcon className={classes.InlineMessageIcon} size={12} />,
}
return icons[variant]
const smallIcons: Record<MessageVariant, React.ReactNode> = {
warning: <AlertFillIcon className={classes.InlineMessageIcon} size={12} />,
critical: <AlertFillIcon className={classes.InlineMessageIcon} size={12} />,
success: <CheckCircleFillIcon className={classes.InlineMessageIcon} size={12} />,
unavailable: <AlertFillIcon className={classes.InlineMessageIcon} size={12} />,
}

export function InlineMessage({children, className, size = 'medium', variant, ...rest}: InlineMessageProps) {
const icon = size === 'small' ? variantToSmallIcon(variant) : variantToIcon(variant)
const icon = size === 'small' ? smallIcons[variant] : icons[variant]

return (
<BoxWithFallback
className={clsx(className, classes.InlineMessage)}
{...rest}
data-size={size}
data-variant={variant}
>
<div {...rest} className={clsx(className, classes.InlineMessage)} data-size={size} data-variant={variant}>
{icon}
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

Creating React elements at module level means these icons will be created on every module load rather than when needed. Consider using factory functions or lazy initialization to avoid unnecessary React element creation.

See below for a potential fix:

const icons: Record<MessageVariant, React.ComponentType<{className: string}>> = {
  warning: AlertIcon,
  critical: AlertIcon,
  success: CheckCircleIcon,
  unavailable: AlertIcon,
}

const smallIcons: Record<MessageVariant, React.ComponentType<{className: string; size: number}>> = {
  warning: AlertFillIcon,
  critical: AlertFillIcon,
  success: CheckCircleFillIcon,
  unavailable: AlertFillIcon,
}

export function InlineMessage({children, className, size = 'medium', variant, ...rest}: InlineMessageProps) {
  const IconComponent = size === 'small' ? smallIcons[variant] : icons[variant]

  return (
    <div {...rest} className={clsx(className, classes.InlineMessage)} data-size={size} data-variant={variant}>
      {size === 'small' ? (
        <IconComponent className={classes.InlineMessageIcon} size={12} />
      ) : (
        <IconComponent className={classes.InlineMessageIcon} />
      )}

Copilot uses AI. Check for mistakes.

Copy link
Contributor

github-actions bot commented Sep 9, 2025

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@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 Sep 9, 2025
Copy link
Contributor

github-actions bot commented Sep 9, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 88.64 KB (0%)
packages/react/dist/browser.umd.js 88.73 KB (0%)

@primer-integration
Copy link

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

@primer-integration
Copy link

🟢 ci completed with status success.

@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 Sep 10, 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 staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove support for sx from the InlineMessage component in @primer/react/experimental
2 participants