chore: fix preferences count bubble size & position

This commit is contained in:
Aman Harwara
2023-09-11 18:36:11 +05:30
parent 51c095efa9
commit 7ca2fa8eab
5 changed files with 36 additions and 21 deletions

View File

@@ -0,0 +1,28 @@
import { classNames } from '@standardnotes/snjs'
type Props = {
count: string | number | undefined
position: 'left' | 'right'
className?: string
}
const CountBubble = ({ count, position, className }: Props) => {
if (!count) {
return null
}
return (
<div
className={classNames(
'flex aspect-square h-5 w-5 items-center justify-center rounded-full border border-info-contrast bg-info text-[0.75rem] font-bold text-info-contrast md:h-4 md:w-4 md:text-[0.5rem]',
'absolute bottom-full translate-y-3 md:translate-y-2',
position === 'left' ? 'right-full md:translate-x-2' : 'left-full -translate-x-3 md:-translate-x-2',
className,
)}
>
{count}
</div>
)
}
export default CountBubble

View File

@@ -2,6 +2,7 @@ import Icon from '@/Components/Icon/Icon'
import { FunctionComponent } from 'react'
import { IconType, classNames } from '@standardnotes/snjs'
import { ErrorCircle } from '@/Components/UIElements/ErrorCircle'
import CountBubble from './CountBubble'
interface Props {
iconType: IconType
@@ -31,11 +32,7 @@ const PreferencesMenuItem: FunctionComponent<Props> = ({
>
<div className="relative mr-1">
<Icon className={classNames('text-base', selected ? 'text-info' : 'text-neutral')} type={iconType} />
{bubbleCount ? (
<div className="absolute bottom-full right-full flex aspect-square h-4 w-4 translate-x-2 translate-y-2 items-center justify-center rounded-full border border-info-contrast bg-info text-[0.5rem] font-bold text-info-contrast">
{bubbleCount}
</div>
) : null}
<CountBubble position="left" count={bubbleCount} />
</div>
<div className="min-w-1" />
{label}