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 9f1e138
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 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,13 +9,8 @@ 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',
})

export interface Props extends BaseProps, HTMLAttributes<HTMLDivElement> {
/** User full name to display */
name: string
Expand All @@ -42,8 +34,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 +42,7 @@ export const PageTopBarMenu = forwardRef<HTMLDivElement, Props>(
const metaContent =
typeof meta === 'string' ? (
<Typography
className={classes.truncateText}
className='m-w-[11.5rem] whitespace-nowrap overflow-hidden overflow-ellipsis'
invert={!isCompactLayout && !invert}
size='xsmall'
data-private={dataPrivate}
Expand All @@ -70,9 +60,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: 'font-[400] m-w-[11.5rem] whitespace-nowrap overflow-hidden overflow-ellipsis',
}}
name={name}
avatar={avatar}
Expand All @@ -98,7 +93,7 @@ export const PageTopBarMenu = forwardRef<HTMLDivElement, Props>(
center
size='xxsmall'
classes={{
name: cx('!font-[400]', classes.truncateText),
name: 'font-[400] m-w-[11.5rem] whitespace-nowrap overflow-hidden overflow-ellipsis',
}}
name={name}
data-private={dataPrivate}
Expand All @@ -112,8 +107,11 @@ export const PageTopBarMenu = forwardRef<HTMLDivElement, Props>(
<Dropdown
{...rest}
ref={ref}
className={cx(classes.root, className)}
classes={{ content: classes.content }}
className={className}
classes={{
content:
'max-h-[calc(100vh-var(--header-height,3.5rem))] width-[15em] xs:max-md:w-[100vw]',
}}
style={style}
content={content}
offset={{ top: isCompactLayout ? 0.8 : 'xsmall' }}
Expand Down

0 comments on commit 9f1e138

Please sign in to comment.