Skip to content

Commit 4f3c1b9

Browse files
Truncate long org names and user menu improvements (#333)
* fix: truncate text in user menu * fix: truncate overflowing text in sidebar orgname dropdown * feat: improved role and org arrangement in user menu * fix: misc tweaks --------- Co-authored-by: rohan-chaturvedi <rohan.chaturvedi@protonmail.com>
1 parent 347dbf9 commit 4f3c1b9

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

frontend/components/UserMenu.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,25 @@ export default function UserMenu() {
3939
leaveFrom="transform opacity-100 scale-100"
4040
leaveTo="transform opacity-0 scale-95"
4141
>
42-
<Menu.Items className="absolute z-10 -right-2 top-12 mt-2 w-56 origin-bottom-left divide-y divide-neutral-500/20 rounded-md bg-neutral-200 dark:bg-neutral-800 shadow-lg ring-1 ring-inset ring-neutral-500/40 focus:outline-none">
42+
<Menu.Items className="absolute z-20 -right-2 top-12 mt-2 w-72 origin-bottom-left divide-y divide-neutral-500/20 rounded-md bg-neutral-200 dark:bg-neutral-800 shadow-lg ring-1 ring-inset ring-neutral-500/40 focus:outline-none">
4343
<Menu.Item>
44-
<div className="py-4 flex items-start gap-2 p-2 ">
44+
<div className="py-4 flex items-start gap-2 p-2">
4545
<div className="py-1.5">
4646
<Avatar imagePath={session?.user?.image!} size="md" />
4747
</div>
48-
<div className="flex flex-col gap-2">
49-
<div className="flex flex-col">
50-
<span className="text-xs font-medium text-zinc-900 dark:text-zinc-100 truncate w-40">
48+
<div className="flex flex-col flex-grow min-w-0">
49+
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
50+
<span className="text-sm font-medium text-zinc-900 dark:text-zinc-100">
5151
{session?.user?.name}
5252
</span>
53-
<span className="text-neutral-500 text-2xs truncate w-40">
54-
{session?.user?.email}
55-
</span>
5653
</div>
57-
54+
<span className="text-neutral-500 text-2xs truncate">{session?.user?.email}</span>
5855
{activeOrganisation && (
59-
<div className="flex items-center gap-2 text-2xs">
60-
<RoleLabel role={activeOrganisation?.role!} />
61-
<span>at {activeOrganisation?.name}</span>
56+
<div className="flex items-center gap-1 text-2xs pt-1">
57+
{activeOrganisation && <RoleLabel role={activeOrganisation?.role!} />} @{' '}
58+
<span className="text-zinc-900 dark:text-zinc-100 truncate">
59+
{activeOrganisation?.name}
60+
</span>
6261
</div>
6362
)}
6463
</div>

frontend/components/layout/Sidebar.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from 'react-icons/fa'
1717
import { organisationContext } from '@/contexts/organisationContext'
1818
import { Fragment, useContext } from 'react'
19-
import { ApiOrganisationMemberRoleChoices, OrganisationType } from '@/apollo/graphql'
19+
import { OrganisationType } from '@/apollo/graphql'
2020
import { Menu, Transition } from '@headlessui/react'
2121
import { Button } from '../common/Button'
2222
import { PlanLabel } from '../settings/organisation/PlanLabel'
@@ -59,14 +59,14 @@ const Sidebar = () => {
5959

6060
const OrgsMenu = () => {
6161
return (
62-
<Menu as="div" className="relative inline-block text-left ">
62+
<Menu as="div" className="relative inline-block text-left w-full">
6363
{({ open }) => (
6464
<>
6565
<Menu.Button
6666
as="div"
6767
className="p-2 text-neutral-500 cursor-pointer flex items-center justify-between w-full group bg-neutral-500/10 ring-1 ring-inset ring-neutral-400/10 rounded-lg"
6868
>
69-
<div className="flex flex-col gap-0.5">
69+
<div className="flex flex-col gap-0.5 min-w-0">
7070
<div>
7171
<PlanLabel plan={activeOrganisation?.plan!} />
7272
</div>
@@ -76,7 +76,7 @@ const Sidebar = () => {
7676
</div>
7777
<FaChevronDown
7878
className={clsx(
79-
'transition ease opacity-0 group-hover:opacity-100 text-zinc-800 dark:text-zinc-100',
79+
'transition ease opacity-0 group-hover:opacity-100 text-zinc-800 dark:text-zinc-100 flex-shrink-0 ml-2',
8080
open ? 'rotate-180 opacity-100' : 'rotate-0'
8181
)}
8282
/>
@@ -101,19 +101,19 @@ const Sidebar = () => {
101101
title={`Switch to ${org.name}`}
102102
className={`${
103103
active
104-
? 'hover:text-zinc-900 dark:hover:text-zinc-100 hover:bg-neutral-100 dark:hover:bg-neutral-700'
104+
? 'hover:text-zinc-900 dark:hover:text-zinc-100 hover:bg-neutral-100 dark:hover:bg-neutral-700'
105105
: 'text-zinc-700 dark:text-zinc-300 dark:hover:text-emerald-500'
106106
} group flex w-full gap-2 items-center justify-between px-2 py-2 border-b border-neutral-500/20`}
107107
>
108-
<div className="flex flex-col gap-0.5 w-full">
108+
<div className="flex flex-col gap-0.5 min-w-0 flex-grow">
109109
<div>
110110
<PlanLabel plan={org?.plan!} />
111111
</div>
112-
<span className="truncate w-[80%] text-left font-medium text-base">
112+
<span className="truncate text-left font-medium text-base">
113113
{org.name}
114114
</span>
115115
</div>
116-
<FaExchangeAlt />
116+
<FaExchangeAlt className="flex-shrink-0" />
117117
</div>
118118
</Link>
119119
)}

frontend/components/users/RoleLabel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const RoleLabel = (props: { role: string }) => {
1515
return (
1616
<span
1717
className={clsx(
18-
'px-2 py-1 rounded-full ring-1 ring-inset uppercase text-2xs font-medium tracking-wide',
18+
'px-2 py-0.5 rounded-full ring-1 ring-inset uppercase text-2xs font-medium tracking-wide',
1919
roleStyle()
2020
)}
2121
>

0 commit comments

Comments
 (0)