Skip to content

Commit

Permalink
[FX-5687] Migrate PageFooter to TailwindCSS
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslan-sed committed Sep 30, 2024
1 parent b42a5dd commit 7d6d366
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 75 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-seahorses-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@toptal/picasso-page': patch
---

- migrate `PageFooter` to TailwindCSS
33 changes: 15 additions & 18 deletions packages/base/Page/src/PageFooter/PageFooter.tsx
Original file line number Diff line number Diff line change
@@ -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<HTMLElement> {
/** Content for copyright. You can override default if needed. */
Expand All @@ -16,37 +14,36 @@ export interface Props extends BaseProps, HTMLAttributes<HTMLElement> {
rightContent?: ReactNode
}

const useStyles = makeStyles<Theme>(styles, {
name: 'PicassoPageFooter',
})

export const PageFooter = forwardRef<HTMLElement, Props>(function PageFooter(
props,
ref
) {
const { className, style, rightContent, copyrightContent, ...rest } = props
const classes = useStyles()
const { width, fullWidth } = useContext<PageContextProps>(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 (
<footer
{...rest}
ref={ref}
className={cx(classes.root, className)}
className={twMerge('bg-[#262d3d] w-full', className)}
style={style}
>
<div className={contentClassnames}>
<div className={classes.left}>{copyrightContent}</div>
<div className='flex items-center justify-center mt-4'>
{copyrightContent}
</div>

<div className={classes.right}>{rightContent}</div>
<div className='flex items-center justify-center mt-4 xs:max-lg:-order-1 xs:max-md:flex-col'>
{rightContent}
</div>
</div>
</footer>
)
Expand Down
67 changes: 10 additions & 57 deletions packages/base/Page/src/PageFooter/styles.ts
Original file line number Diff line number Diff line change
@@ -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]'
}

0 comments on commit 7d6d366

Please sign in to comment.