Skip to content

Commit

Permalink
fix: long room names displaying (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
romansharapov19 authored Sep 11, 2023
1 parent a3035c5 commit c236ebd
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions packages/web-ui/components/rooms.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';
import Link from 'next/link';
import { useParams } from 'next/navigation';
import { apiClient } from '@/api/apiClient';
Expand All @@ -11,6 +11,11 @@ import { useAuth } from '@clerk/nextjs';
import { Lock } from 'lucide-react';

import { Button } from '@/components/ui/button';
import {
HoverCard,
HoverCardContent,
HoverCardTrigger,
} from '@/components/ui/hover-card';
import { ScrollArea } from '@/components/ui/scroll-area';
import { CreateRoomForm } from '@/components/create-room-form';

Expand Down Expand Up @@ -60,22 +65,29 @@ export function Rooms({ rooms }: RoomsProps) {
<ScrollArea className="flex-1 p-2">
<div className="space-y-1">
{rooms.map((room) => (
<Link key={`${room.id}`} href={`/rooms/${room.id}`}>
<Button
variant="ghost"
size="sm"
className="w-full justify-between"
>
<p
className={`max-w-[140px] overflow-hidden text-clip ${
room.id === params.room ? 'font-bold' : 'font-normal'
}`}
>
{room.name}
</p>
{room.isPrivate && <Lock className="h-4 w-4" />}
</Button>
</Link>
<HoverCard key={room.id}>
<HoverCardTrigger asChild>
<Link href={`/rooms/${room.id}`}>
<Button
variant="ghost"
size="sm"
className="w-full justify-between"
>
<p
className={`w-[140px] truncate text-left ${
room.id === params.room ? 'font-bold' : 'font-normal'
}`}
>
{room.name}
</p>
{room.isPrivate && <Lock className="h-4 w-4" />}
</Button>
</Link>
</HoverCardTrigger>
<HoverCardContent>
<div>{room.name}</div>
</HoverCardContent>
</HoverCard>
))}
</div>
</ScrollArea>
Expand Down

0 comments on commit c236ebd

Please sign in to comment.