From 7d6d3667ce989e61193ed5e15ebd4cadcd38bd5c Mon Sep 17 00:00:00 2001 From: Ruslan Sedziukh Date: Mon, 30 Sep 2024 16:41:48 +0300 Subject: [PATCH] [FX-5687] Migrate PageFooter to TailwindCSS --- .changeset/witty-seahorses-approve.md | 5 ++ .../base/Page/src/PageFooter/PageFooter.tsx | 33 +++++---- packages/base/Page/src/PageFooter/styles.ts | 67 +++---------------- 3 files changed, 30 insertions(+), 75 deletions(-) create mode 100644 .changeset/witty-seahorses-approve.md diff --git a/.changeset/witty-seahorses-approve.md b/.changeset/witty-seahorses-approve.md new file mode 100644 index 0000000000..a0bc2f8bde --- /dev/null +++ b/.changeset/witty-seahorses-approve.md @@ -0,0 +1,5 @@ +--- +'@toptal/picasso-page': patch +--- + +- migrate `PageFooter` to TailwindCSS diff --git a/packages/base/Page/src/PageFooter/PageFooter.tsx b/packages/base/Page/src/PageFooter/PageFooter.tsx index 2cc26f06b0..abd3759f70 100644 --- a/packages/base/Page/src/PageFooter/PageFooter.tsx +++ b/packages/base/Page/src/PageFooter/PageFooter.tsx @@ -1,13 +1,11 @@ import type { ReactNode, HTMLAttributes } from 'react' import React, { useContext, forwardRef } from 'react' -import type { Theme } from '@material-ui/core/styles' -import { makeStyles } from '@material-ui/core/styles' -import cx from 'classnames' import type { BaseProps } from '@toptal/picasso-shared' +import { twJoin, twMerge } from '@toptal/picasso-tailwind-merge' import { PageContext } from '../Page' import type { PageContextProps } from '../Page/types' -import styles from './styles' +import { getMaxWidthClass } from './styles' export interface Props extends BaseProps, HTMLAttributes { /** Content for copyright. You can override default if needed. */ @@ -16,37 +14,36 @@ export interface Props extends BaseProps, HTMLAttributes { rightContent?: ReactNode } -const useStyles = makeStyles(styles, { - name: 'PicassoPageFooter', -}) - export const PageFooter = forwardRef(function PageFooter( props, ref ) { const { className, style, rightContent, copyrightContent, ...rest } = props - const classes = useStyles() const { width, fullWidth } = useContext(PageContext) - const contentClassnames = cx( - { - [classes.fullWidth]: fullWidth || width === 'full', - [classes.wide]: width === 'wide', - }, - classes.content + const contentClassnames = twJoin( + getMaxWidthClass({ width, fullWidth }), + 'box-border', + 'flex justify-between xs:max-lg:flex-col', + 'text-white text-md leading-[1em]', + 'mx-auto pt-2 pb-6 px-[1em] xl:px-[2em]' ) return ( ) diff --git a/packages/base/Page/src/PageFooter/styles.ts b/packages/base/Page/src/PageFooter/styles.ts index de49d8bef3..7ba572616b 100644 --- a/packages/base/Page/src/PageFooter/styles.ts +++ b/packages/base/Page/src/PageFooter/styles.ts @@ -1,60 +1,13 @@ -import type { Theme } from '@material-ui/core/styles' -import { createStyles } from '@material-ui/core/styles' +import type { PageContextProps } from '../Page/types' -export default ({ palette, screens, layout }: Theme) => - createStyles({ - root: { - backgroundColor: palette.grey.darker, - width: '100%', - }, - content: { - boxSizing: 'border-box', - display: 'flex', - justifyContent: 'space-between', - margin: '0 auto', - paddingTop: '0.5rem', - paddingBottom: '1.5rem', - paddingLeft: layout.contentMobilePaddingHorizontal, - paddingRight: layout.contentMobilePaddingHorizontal, - maxWidth: layout.contentWidth, - color: palette.common.white, - fontSize: '0.875rem', - lineHeight: '1em', +export const getMaxWidthClass = ({ fullWidth, width }: PageContextProps) => { + if (fullWidth || width === 'full') { + return 'max-w-full' + } - [screens('xs', 'sm', 'md')]: { - flexDirection: 'column', - }, + if (width === 'wide') { + return 'max-w-[90em]' + } - [screens('md', 'lg', 'xl')]: { - paddingLeft: layout.contentPaddingHorizontal, - paddingRight: layout.contentPaddingHorizontal, - }, - }, - centered: {}, - wide: { - maxWidth: layout.contentWidthWide, - }, - fullWidth: { - maxWidth: '100%', - }, - left: { - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - marginTop: '1rem', - }, - right: { - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - marginTop: '1rem', - - [screens('xs', 'sm', 'md')]: { - order: -1, - }, - - [screens('xs', 'sm')]: { - flexDirection: 'column', - }, - }, - }) + return 'max-w-[75em]' +}