From e551bb56fda72940e4a12aa2bebc2d5c3345b2ec Mon Sep 17 00:00:00 2001 From: Aleksandr Shumilov Date: Mon, 2 Sep 2024 08:53:40 +0100 Subject: [PATCH] Migrate ShowMore to Tailwind (#4517) --- .changeset/red-keys-smile.md | 9 +++++ packages/base/ShowMore/package.json | 7 ++-- .../base/ShowMore/src/ShowMore/ShowMore.tsx | 19 ++++------ .../src/ShowMore/__snapshots__/test.tsx.snap | 36 +++++++++---------- packages/base/ShowMore/src/ShowMore/styles.ts | 24 ------------- packages/base/ShowMore/tsconfig.json | 2 ++ 6 files changed, 40 insertions(+), 57 deletions(-) create mode 100644 .changeset/red-keys-smile.md delete mode 100644 packages/base/ShowMore/src/ShowMore/styles.ts diff --git a/.changeset/red-keys-smile.md b/.changeset/red-keys-smile.md new file mode 100644 index 0000000000..b2df6ae572 --- /dev/null +++ b/.changeset/red-keys-smile.md @@ -0,0 +1,9 @@ +--- +'@toptal/picasso-show-more': major +'@toptal/picasso': patch +--- + +### ShowMore + +- migrate to TailwindCSS, `material-ui@4` is no longer required for this package +- update peer dependencies diff --git a/packages/base/ShowMore/package.json b/packages/base/ShowMore/package.json index c055006bb4..2c7c6511b8 100644 --- a/packages/base/ShowMore/package.json +++ b/packages/base/ShowMore/package.json @@ -25,7 +25,6 @@ "@toptal/picasso-button": "4.0.1", "@toptal/picasso-icons": "1.6.0", "@toptal/picasso-typography": "4.0.0", - "classnames": "^2.5.1", "react-truncate": "^2.4.0" }, "sideEffects": [ @@ -33,14 +32,16 @@ "**/styles.js" ], "peerDependencies": { - "@material-ui/core": "4.12.4", + "@toptal/picasso-tailwind": ">=2.7", + "@toptal/picasso-tailwind-merge": "^2.0.0", "react": ">=16.12.0 < 19.0.0" }, "exports": { ".": "./dist-package/src/index.js" }, "devDependencies": { - "@toptal/picasso-test-utils": "1.1.1" + "@toptal/picasso-test-utils": "1.1.1", + "@toptal/picasso-tailwind-merge": "2.0.0" }, "files": [ "dist-package/**", diff --git a/packages/base/ShowMore/src/ShowMore/ShowMore.tsx b/packages/base/ShowMore/src/ShowMore/ShowMore.tsx index e5f94dd981..569b81d413 100644 --- a/packages/base/ShowMore/src/ShowMore/ShowMore.tsx +++ b/packages/base/ShowMore/src/ShowMore/ShowMore.tsx @@ -1,15 +1,12 @@ import type { ReactNode } from 'react' import React, { forwardRef, useMemo, useCallback, useState } from 'react' -import cx from 'classnames' -import type { Theme } from '@material-ui/core/styles' -import { makeStyles } from '@material-ui/core/styles' +import { twJoin } from '@toptal/picasso-tailwind-merge' import Truncate from 'react-truncate' import type { BaseProps } from '@toptal/picasso-shared' import { ChevronRight16 } from '@toptal/picasso-icons' import { Typography } from '@toptal/picasso-typography' import { ButtonAction } from '@toptal/picasso-button' -import styles from './styles' import { replaceLineBreaksWithTags } from './utils' export interface Props extends BaseProps { @@ -33,8 +30,6 @@ export interface Props extends BaseProps { } } -const useStyles = makeStyles(styles, { name: 'PicassoShowMore' }) - export const ShowMore = forwardRef(function ShowMore( props, ref @@ -52,7 +47,6 @@ export const ShowMore = forwardRef(function ShowMore( testIds, ...rest } = props - const classes = useStyles() const [shownMore, setShownMore] = useState(initialExpanded) const [needsTruncation, setNeedsTruncation] = useState(true) const content = useMemo( @@ -97,13 +91,14 @@ export const ShowMore = forwardRef(function ShowMore( setShownMore(nextState) onToggle(nextState) }} - className={classes.toggleText} + className='inline-flex items-center transition-none' icon={ -
+
} diff --git a/packages/base/ShowMore/src/ShowMore/__snapshots__/test.tsx.snap b/packages/base/ShowMore/src/ShowMore/__snapshots__/test.tsx.snap index e6b1fa004c..a5f31793ca 100644 --- a/packages/base/ShowMore/src/ShowMore/__snapshots__/test.tsx.snap +++ b/packages/base/ShowMore/src/ShowMore/__snapshots__/test.tsx.snap @@ -24,7 +24,7 @@ exports[`ShowMore renders 1`] = `