Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d555156
Revert "Revert "Chore: remove styled system components" (#6964)"
francinelucca Oct 8, 2025
3987c40
Merge branch 'main' into revert-6964-revert-6941-chore/remove-styled-…
francinelucca Oct 8, 2025
b790d75
fix types
francinelucca Oct 8, 2025
08d6cec
add HTML attributes to Text
francinelucca Oct 8, 2025
63b653e
explicitly add cllassName to text
francinelucca Oct 8, 2025
f9fa7e8
text type fixes
francinelucca Oct 8, 2025
569a352
Merge branch 'main' into revert-6964-revert-6941-chore/remove-styled-…
francinelucca Oct 8, 2025
6b3498d
type fix
francinelucca Oct 8, 2025
2e22643
Merge branch 'revert-6964-revert-6941-chore/remove-styled-system' of …
francinelucca Oct 8, 2025
010d2fe
add className to TextProps
francinelucca Oct 8, 2025
7965b97
fix type
francinelucca Oct 9, 2025
0fcc16d
type fix
francinelucca Oct 9, 2025
ccb2b18
type fixes
francinelucca Oct 9, 2025
b9ff584
type fix
francinelucca Oct 9, 2025
b95ef2b
use types from utils
francinelucca Oct 9, 2025
f7b4046
Merge branch 'main' into revert-6964-revert-6941-chore/remove-styled-…
francinelucca Oct 9, 2025
f783898
lint fix
francinelucca Oct 9, 2025
bc99e88
Merge branch 'revert-6964-revert-6941-chore/remove-styled-system' of …
francinelucca Oct 9, 2025
40a23a2
Merge branch 'main' into revert-6964-revert-6941-chore/remove-styled-…
francinelucca Oct 9, 2025
2a9ede1
Merge branch 'main' into revert-6964-revert-6941-chore/remove-styled-…
francinelucca Oct 9, 2025
5816d4e
type fix?
francinelucca Oct 9, 2025
a7db6d6
Merge branch 'revert-6964-revert-6941-chore/remove-styled-system' of …
francinelucca Oct 9, 2025
f3962d4
Update packages/react/src/BranchName/BranchName.tsx
francinelucca Oct 10, 2025
d0b044d
lint
francinelucca Oct 10, 2025
fe9450b
Merge branch 'main' into revert-6964-revert-6941-chore/remove-styled-…
francinelucca Oct 10, 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/chilled-spoons-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": major
---

Chore/remove styled. components: deprecated UnderlineNav, ValidationAnimation, LabelGroup, Tooltip
23 changes: 8 additions & 15 deletions packages/react/src/BranchName/BranchName.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import React, {type ForwardedRef} from 'react'
import type React from 'react'
import type {ForwardedRef} from 'react'
import {clsx} from 'clsx'
import classes from './BranchName.module.css'
import {fixedForwardRef, type PolymorphicProps} from '../utils/modern-polymorphic'

type BranchNameProps<As extends React.ElementType> = {
as?: As
} & DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? 'a' : As>, 'as'> & {
export type BranchNameProps<As extends React.ElementType> = PolymorphicProps<
As,
'a',
{
className?: string
}
>

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function BranchName<As extends React.ElementType>(props: BranchNameProps<As>, ref: ForwardedRef<any>) {
Expand All @@ -18,17 +22,6 @@ function BranchName<As extends React.ElementType>(props: BranchNameProps<As>, re
)
}

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
type FixedForwardRef = <T, P = {}>(
render: (props: P, ref: React.Ref<T>) => React.ReactNode,
) => (props: P & React.RefAttributes<T>) => React.ReactNode

const fixedForwardRef = React.forwardRef as FixedForwardRef

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends any ? Omit<T, TOmitted> : never

BranchName.displayName = 'BranchName'

export type {BranchNameProps}
export default fixedForwardRef(BranchName)
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function shouldAcceptAs() {
export function defaultAsIsAnchor() {
return (
<BranchName
onClick={event => {
onClick={(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
type test = Expect<Equal<typeof event, React.MouseEvent<HTMLAnchorElement, MouseEvent>>>
}}
/>
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/DialogV1/Dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Component = () => {
<div data-testid="inner">
<Dialog.Header id="header">Title</Dialog.Header>
<div style={{padding: 'var(--stack-gap-normal)'}}>
<Text fontFamily="sans-serif">Some content</Text>
<Text style={{fontFamily: 'sans-serif'}}>Some content</Text>
</div>
</div>
</Dialog>
Expand All @@ -37,7 +37,7 @@ const ClosedDialog = () => {
<div data-testid="inner">
<Dialog.Header id="header">Title</Dialog.Header>
<div style={{padding: 'var(--stack-gap-normal)'}}>
<Text fontFamily="sans-serif">Some content</Text>
<Text style={{fontFamily: 'sans-serif'}}>Some content</Text>
</div>
</div>
</Dialog>
Expand All @@ -51,7 +51,7 @@ const DialogWithCustomFocusRef = () => {
<div data-testid="inner">
<Dialog.Header id="header">Title</Dialog.Header>
<div style={{padding: 'var(--stack-gap-normal)'}}>
<Text fontFamily="sans-serif">Some content</Text>
<Text style={{fontFamily: 'sans-serif'}}>Some content</Text>
<button type="button" data-testid="inner-button" ref={buttonRef}>
hi
</button>
Expand Down Expand Up @@ -80,7 +80,7 @@ const DialogWithCustomFocusRefAndReturnFocusRef = () => {
<div data-testid="inner">
<Dialog.Header id="header">Title</Dialog.Header>
<div style={{padding: 'var(--stack-gap-normal)'}}>
<Text fontFamily="sans-serif">Some content</Text>
<Text style={{fontFamily: 'sans-serif'}}>Some content</Text>
<button type="button" data-testid="inner-button" ref={buttonRef}>
hi
</button>
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/FormControl/FormControlLeadingVisual.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type React from 'react'
import {get} from '../constants'
import type {SxProp} from '../sx'
import {useFormControlContext} from './_FormControlContext'
import styled from 'styled-components'
Expand All @@ -24,7 +23,7 @@ const FormControlLeadingVisual: React.FC<React.PropsWithChildren<SxProp & {style
}

const StyledLeadingVisual = styled.div`
--leadingVisual-size: ${get('fontSizes.2')};
--leadingVisual-size: var(--text-title-size-small);

color: var(--fgColor-default);

Expand All @@ -42,7 +41,7 @@ const StyledLeadingVisual = styled.div`
}

&:where([data-has-caption]) {
--leadingVisual-size: ${get('fontSizes.4')};
--leadingVisual-size: var(--base-size-24);
}

${sx}
Expand Down
38 changes: 38 additions & 0 deletions packages/react/src/LabelGroup/LabelGroup.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
.Container {
display: flex;
flex-wrap: nowrap;
gap: var(--base-size-4);
/* stylelint-disable-next-line primer/typography */
line-height: 1;
max-width: 100%;
overflow: hidden;

&:where([data-overflow='inline']) {
flex-wrap: wrap;
}

&:where([data-list]) {
padding-inline-start: 0;
margin-block-start: 0;
margin-block-end: 0;
list-style-type: none;
}
}

.ItemWrapper {
display: flex;
align-items: center;
/* This min-height matches the height of the expand/collapse button.
Without it, the labels/tokens will do a slight layout shift when expanded.
This is because the height of the first row will match the token sizes,
but the height of the second row will be the height of the collapse button.
*/
min-height: 28px;
}

.ItemWrapper--hidden {
order: 9999;
pointer-events: none;
visibility: hidden;
}

.OverlayContainer {
align-items: flex-start;
display: flex;
Expand Down
68 changes: 15 additions & 53 deletions packages/react/src/LabelGroup/LabelGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react'
import styled from 'styled-components'
import {XIcon} from '@primer/octicons-react'
import {getFocusableChild} from '@primer/behaviors/utils'
import {get} from '../constants'
import VisuallyHidden from '../_VisuallyHidden'
import {AnchoredOverlay} from '../AnchoredOverlay'
import {Button, IconButton} from '../Button'
import {clsx} from 'clsx'
import theme from '../theme'
import classes from './LabelGroup.module.css'

Expand All @@ -18,45 +17,6 @@ export type LabelGroupProps = {
visibleChildCount?: 'auto' | number
className?: string
}

const StyledLabelGroupContainer = styled.div`
display: flex;
flex-wrap: nowrap;
gap: ${get('space.1')};
line-height: 1;
max-width: 100%;
overflow: hidden;

&[data-overflow='inline'] {
flex-wrap: wrap;
}

&[data-list] {
padding-inline-start: 0;
margin-block-start: 0;
margin-block-end: 0;
list-style-type: none;
}
`

const ItemWrapper = styled.div`
display: flex;
align-items: center;

/* This min-height matches the height of the expand/collapse button.
Without it, the labels/tokens will do a slight layout shift when expanded.
This is because the height of the first row will match the token sizes,
but the height of the second row will be the height of the collapse button.
*/
min-height: 28px;

&.ItemWrapper--hidden {
order: 9999;
pointer-events: none;
visibility: hidden;
}
`

// Calculates the width of the overlay to cover the labels/tokens and the expand button.
const getOverlayWidth = (
buttonClientRect: DOMRect,
Expand Down Expand Up @@ -151,7 +111,7 @@ const LabelGroup: React.FC<React.PropsWithChildren<LabelGroupProps>> = ({
children,
visibleChildCount,
overflowStyle = 'overlay',
as = 'ul',
as: Component = 'ul',
className,
}) => {
const containerRef = React.useRef<HTMLElement>(null)
Expand Down Expand Up @@ -320,28 +280,30 @@ const LabelGroup: React.FC<React.PropsWithChildren<LabelGroupProps>> = ({
}
}, [overflowStyle, isOverflowShown])

const isList = as === 'ul' || as === 'ol'
const isList = Component === 'ul' || Component === 'ol'
const ToggleWrapper = isList ? 'li' : React.Fragment

const ItemWrapperComponent = isList ? 'li' : 'span'

// If truncation is enabled, we need to render based on truncation logic.
return visibleChildCount ? (
<StyledLabelGroupContainer
<Component
ref={containerRef}
data-overflow={overflowStyle === 'inline' && isOverflowShown ? 'inline' : undefined}
data-list={isList || undefined}
className={className}
as={as}
className={clsx(className, classes.Container)}
>
{React.Children.map(children, (child, index) => (
<ItemWrapper
<ItemWrapperComponent
// data-index is used as an identifier we can use in the IntersectionObserver
data-index={index}
className={hiddenItemIds.includes(index.toString()) ? 'ItemWrapper--hidden' : undefined}
as={isList ? 'li' : 'span'}
className={clsx(classes.ItemWrapper, {
[classes['ItemWrapper--hidden']]: hiddenItemIds.includes(index.toString()),
})}
key={index}
>
{child}
</ItemWrapper>
</ItemWrapperComponent>
))}
<ToggleWrapper>
{overflowStyle === 'inline' ? (
Expand Down Expand Up @@ -369,15 +331,15 @@ const LabelGroup: React.FC<React.PropsWithChildren<LabelGroupProps>> = ({
</OverlayToggle>
)}
</ToggleWrapper>
</StyledLabelGroupContainer>
</Component>
) : (
<StyledLabelGroupContainer data-overflow="inline" data-list={isList || undefined} as={as} className={className}>
<Component data-overflow="inline" data-list={isList || undefined} className={clsx(className, classes.Container)}>
{isList
? React.Children.map(children, (child, index) => {
return <li key={index}>{child}</li>
})
: children}
</StyledLabelGroupContainer>
</Component>
)
}

Expand Down
Loading
Loading