diff --git a/docs/src/data/tailwind-migration-status.yaml b/docs/src/data/tailwind-migration-status.yaml index 648039fefc..9dfe561e10 100644 --- a/docs/src/data/tailwind-migration-status.yaml +++ b/docs/src/data/tailwind-migration-status.yaml @@ -107,6 +107,6 @@ TimelineStep: false Toast: true ToastRoot: false Tooltip: true -Truncate: false +Truncate: true Wizard: false WizardStep: false diff --git a/packages/orbit-components/src/Truncate/__tests__/index.test.tsx b/packages/orbit-components/src/Truncate/__tests__/index.test.tsx index 7c8d455fa2..9d27e69736 100644 --- a/packages/orbit-components/src/Truncate/__tests__/index.test.tsx +++ b/packages/orbit-components/src/Truncate/__tests__/index.test.tsx @@ -6,28 +6,15 @@ import Text from "../../Text"; import Heading from "../../Heading"; describe("Truncate", () => { - it("should have expected DOM output", () => { - const { container } = render( - - children - , - ); - expect(screen.getByTestId("test")).toBeInTheDocument(); - expect(screen.getByText("children")).toBeInTheDocument(); - expect(container.childNodes[1]).toHaveStyle({ - minWidth: 0, - maxWidth: "10rem", - }); - }); - it("should truncate children, as well as Text and Heading", () => { render( - + children text heading , ); + expect(screen.getByTestId("test")).toBeInTheDocument(); expect(screen.getByText("children")).toHaveStyle({ textOverflow: "ellipsis" }); expect(screen.getByText("text")).toHaveStyle({ textOverflow: "ellipsis" }); expect(screen.getByText("heading")).toHaveStyle({ textOverflow: "ellipsis" }); diff --git a/packages/orbit-components/src/Truncate/index.tsx b/packages/orbit-components/src/Truncate/index.tsx index 2f2b4ad4f1..d27feec581 100644 --- a/packages/orbit-components/src/Truncate/index.tsx +++ b/packages/orbit-components/src/Truncate/index.tsx @@ -1,32 +1,23 @@ "use client"; import * as React from "react"; -import styled from "styled-components"; +import cx from "clsx"; import type { Props } from "./types"; -const StyledTruncate = styled.div<{ maxWidth?: string }>` - ${({ maxWidth }) => ` - min-width: 0; - flex: 0 1 ${maxWidth === "none" ? "100%" : maxWidth}; - max-width: ${maxWidth}; - `}; -`; - -const StyledTruncateContent = styled.div` - &, - .orbit-text, - .orbit-heading { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } -`; - const Truncate = ({ children, maxWidth = "100%", dataTest }: Props) => ( - - {children} - +
+
+ {children} +
+
); export default Truncate;