Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .changeset/lucky-facts-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@primer/react': major
'@primer/styled-react': patch
---

Update Truncate component to no longer support sx, add sx wrapper to @primer/styled-react.
1 change: 0 additions & 1 deletion packages/react/src/ActionList/Description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const Description: React.FC<React.PropsWithChildren<ActionListDescription
ref={containerRef}
id={inlineDescriptionId}
className={clsx(className, classes.Description)}
sx={sx}
title={effectiveTitle}
inline={true}
maxWidth="100%"
Expand Down
7 changes: 1 addition & 6 deletions packages/react/src/Truncate/Truncate.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"props": [
{
"name": "maxWidth",
"type": "number",
"type": "number | string | (number | string)[]",
"defaultValue": "125",
"description": "Sets the max-width of the text."
},
Expand All @@ -41,11 +41,6 @@
"name": "as",
"type": "React.ElementType",
"defaultValue": "'div'"
},
{
"name": "sx",
"type": "SystemStyleObject",
"deprecated": true
}
],
"subcomponents": []
Expand Down
6 changes: 0 additions & 6 deletions packages/react/src/Truncate/Truncate.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ Playground.argTypes = {
disable: true,
},
},
sx: {
controls: false,
table: {
disable: true,
},
},
theme: {
controls: false,
table: {
Expand Down
15 changes: 5 additions & 10 deletions packages/react/src/Truncate/Truncate.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import React from 'react'
import {clsx} from 'clsx'
import type {MaxWidthProps} from 'styled-system'
import type {SxProp} from '../sx'
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
import {BoxWithFallback} from '../internal/components/BoxWithFallback'
import classes from './Truncate.module.css'

type TruncateProps = React.HTMLAttributes<HTMLElement> & {
title: string
inline?: boolean
expandable?: boolean
} & MaxWidthProps &
SxProp
maxWidth?: number | string | (number | string)[]
}

const Truncate = React.forwardRef(function Truncate(
{as, children, className, title, inline, expandable, maxWidth = 125, style, sx, ...rest},
{as: Component = 'div', children, className, title, inline, expandable, maxWidth = 125, style, ...rest},
ref,
) {
return (
<BoxWithFallback
<Component
{...rest}
ref={ref}
as={as}
className={clsx(className, classes.Truncate)}
data-expandable={expandable}
data-inline={inline}
Expand All @@ -33,10 +29,9 @@ const Truncate = React.forwardRef(function Truncate(
typeof maxWidth === 'number' ? `${maxWidth}px` : typeof maxWidth === 'string' ? maxWidth : undefined,
} as React.CSSProperties
}
sx={sx}
>
{children}
</BoxWithFallback>
</Component>
)
}) as PolymorphicForwardRefComponent<'div', TruncateProps>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports[`@primer/styled-react exports 1`] = `
[
"ToggleSwitch",
"Truncate",
"ActionList",
"ActionMenu",
"Autocomplete",
Expand Down Expand Up @@ -49,7 +50,6 @@ exports[`@primer/styled-react exports 1`] = `
"Timeline",
"Token",
"Tooltip",
"Truncate",
"UnderlineNav",
"Box",
"sx",
Expand Down
6 changes: 3 additions & 3 deletions packages/styled-react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {ToggleSwitch as PrimerToggleSwitch} from '@primer/react'
import {Truncate as PrimerTruncate, ToggleSwitch as PrimerToggleSwitch} from '@primer/react'
import {createStyledComponent} from './utils/createStyledComponent'

const Truncate: ReturnType<typeof createStyledComponent> = /*#__PURE__*/ createStyledComponent(PrimerTruncate)
const ToggleSwitch: ReturnType<typeof createStyledComponent> = /*#__PURE__*/ createStyledComponent(PrimerToggleSwitch)
export {ToggleSwitch}
export {ToggleSwitch, Truncate}

export {
ActionList,
Expand Down Expand Up @@ -51,7 +52,6 @@ export {
Timeline,
Token,
Tooltip,
Truncate,
UnderlineNav,

// styled-components components or types
Expand Down
Loading