Update UI of account selection component

Modified CSS styles in account-selector.tsx to enhance user experience. Added 'group' class for better hover effects and formatting for avatars. Also updated styling for account label to prevent overflow and ensure better readability.
This commit is contained in:
giancarlo
2024-04-02 12:33:13 +08:00
parent d24cf8427f
commit d92d224250

View File

@@ -102,7 +102,7 @@ export function AccountSelector({
variant="ghost" variant="ghost"
role="combobox" role="combobox"
aria-expanded={open} aria-expanded={open}
className={cn('w-full shadow', { className={cn('group w-full shadow', {
'justify-between': !collapsed, 'justify-between': !collapsed,
'justify-center': collapsed, 'justify-center': collapsed,
})} })}
@@ -125,7 +125,11 @@ export function AccountSelector({
> >
{(account) => ( {(account) => (
<span className={'flex items-center space-x-2'}> <span className={'flex items-center space-x-2'}>
<Avatar className={'h-6 w-6'}> <Avatar
className={
'group-hover:border-border mr-2 h-6 w-6 border border-transparent'
}
>
<AvatarImage src={account.image ?? undefined} /> <AvatarImage src={account.image ?? undefined} />
<AvatarFallback> <AvatarFallback>
@@ -175,6 +179,7 @@ export function AccountSelector({
<CommandGroup heading={<Trans i18nKey={'teams:yourTeams'} />}> <CommandGroup heading={<Trans i18nKey={'teams:yourTeams'} />}>
{(accounts ?? []).map((account) => ( {(accounts ?? []).map((account) => (
<CommandItem <CommandItem
className={'group'}
key={account.value} key={account.value}
value={account.value ?? ''} value={account.value ?? ''}
onSelect={(currentValue) => { onSelect={(currentValue) => {
@@ -186,7 +191,16 @@ export function AccountSelector({
} }
}} }}
> >
<Avatar className={'mr-2 h-6 w-6'}> <Avatar
className={cn(
'mr-2 h-6 w-6 border border-transparent',
{
['border-border']: value === account.value,
['group-hover:border-border ']:
value !== account.value,
},
)}
>
<AvatarImage src={account.image ?? undefined} /> <AvatarImage src={account.image ?? undefined} />
<AvatarFallback> <AvatarFallback>
@@ -194,7 +208,9 @@ export function AccountSelector({
</AvatarFallback> </AvatarFallback>
</Avatar> </Avatar>
<span>{account.label}</span> <span className={'mr-2 max-w-[165px] truncate'}>
{account.label}
</span>
<Icon item={account.value ?? ''} /> <Icon item={account.value ?? ''} />
</CommandItem> </CommandItem>