Skip to content

Commit

Permalink
[FX-5602] Migrate PageTopBarMenu to TailwindCSS
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslan-sed committed Sep 25, 2024
1 parent a0bf9c5 commit 6ac6fbe
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 56 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-vans-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@toptal/picasso-page': patch
---

- migrate `PageTopBarMenu` to TailwindCSS
36 changes: 20 additions & 16 deletions packages/base/Page/src/PageTopBarMenu/PageTopBarMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* eslint-disable complexity */
import type { ReactNode, HTMLAttributes } from 'react'
import React, { useContext, forwardRef } from 'react'
import cx from 'classnames'
import type { Theme } from '@material-ui/core/styles'
import { makeStyles } from '@material-ui/core/styles'
import type { BaseProps } from '@toptal/picasso-shared'
import { useBreakpoint } from '@toptal/picasso-utils'
import { UserBadge } from '@toptal/picasso-user-badge'
Expand All @@ -12,12 +9,10 @@ import { Typography } from '@toptal/picasso-typography'
import { DropdownCompound as Dropdown } from '@toptal/picasso-dropdown'
import { twJoin } from '@toptal/picasso-tailwind-merge'

import styles from './styles'
import { PageTopBarContext } from '../PageTopBar'

const useStyles = makeStyles<Theme>(styles, {
name: 'PicassoTopBarMenu',
})
const truncateText =
'max-w-[11.5rem] whitespace-nowrap overflow-hidden overflow-ellipsis'

export interface Props extends BaseProps, HTMLAttributes<HTMLDivElement> {
/** User full name to display */
Expand All @@ -42,8 +37,6 @@ export const PageTopBarMenu = forwardRef<HTMLDivElement, Props>(
'data-private': dataPrivate,
...rest
} = props
const classes = useStyles()

const { variant } = useContext(PageTopBarContext)
const invert = variant === 'light'

Expand All @@ -52,7 +45,7 @@ export const PageTopBarMenu = forwardRef<HTMLDivElement, Props>(
const metaContent =
typeof meta === 'string' ? (
<Typography
className={classes.truncateText}
className={truncateText}
invert={!isCompactLayout && !invert}
size='xsmall'
data-private={dataPrivate}
Expand All @@ -70,9 +63,14 @@ export const PageTopBarMenu = forwardRef<HTMLDivElement, Props>(
size='xxsmall'
data-private={dataPrivate}
classes={{
root: classes.contentUserBadge,
avatar: classes.avatar,
name: cx('!font-[400]', classes.truncateText),
root: twJoin(
'xs:max-lg::p-2',
'xs:max-lg:[z-index:1]',
'xs:max-lg::bg-white',
'xs:max-lg::relative'
),
avatar: 'text-[0.9rem]',
name: twJoin('font-[400]', truncateText),
}}
name={name}
avatar={avatar}
Expand All @@ -98,7 +96,7 @@ export const PageTopBarMenu = forwardRef<HTMLDivElement, Props>(
center
size='xxsmall'
classes={{
name: cx('!font-[400]', classes.truncateText),
name: twJoin('font-[400]', truncateText),
}}
name={name}
data-private={dataPrivate}
Expand All @@ -112,8 +110,14 @@ export const PageTopBarMenu = forwardRef<HTMLDivElement, Props>(
<Dropdown
{...rest}
ref={ref}
className={cx(classes.root, className)}
classes={{ content: classes.content }}
className={className}
classes={{
content: twJoin(
// viewport minus header height
'max-h-[calc(100vh-var(--header-height,3.5rem))]',
'w-[15em] xs:max-md:w-[100vw]'
),
}}
style={style}
content={content}
offset={{ top: isCompactLayout ? 0.8 : 'xsmall' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports[`PageTopBarMenu renders 1`] = `
class="items-center flex"
>
<h4
class="m-0 text-md text-white font-semibold inline !font-[400] PicassoTopBarMenu-truncateText"
class="m-0 text-md text-white inline font-[400] max-w whitespace-nowrap overflow-hidden overflow-ellipsis"
>
Jacqueline Roque
</h4>
Expand Down
39 changes: 0 additions & 39 deletions packages/base/Page/src/PageTopBarMenu/styles.ts

This file was deleted.

0 comments on commit 6ac6fbe

Please sign in to comment.