Skip to content

Commit

Permalink
fix: add clamptext component for long titles and descriptions per Unl…
Browse files Browse the repository at this point in the history
  • Loading branch information
carddev81 committed Jan 30, 2025
1 parent 95efee7 commit 81b21b5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
23 changes: 13 additions & 10 deletions frontend/src/Components/LibraryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
FlagIcon as FlagIconOutline,
MagnifyingGlassIcon
} from '@heroicons/react/24/outline';
import ClampedText from './ClampedText';

export default function LibraryCard({
library,
Expand Down Expand Up @@ -79,18 +80,20 @@ export default function LibraryCard({
alt={`${library.title} thumbnail`}
/>
</figure>
<h3 className="w-3/4 body my-auto mr-7">{library.title}</h3>
<ClampedText as="h3" className="w-3/4 body my-auto mr-7">
{library.title}
</ClampedText>
</div>
<div className="flex items-center justify-end space-x-2 absolute right-2 top-2 z-100">
{!route.pathname.includes('knowledge-insights') && (
<div onClick={handleSearchClick}>
<ULIComponent
icon={MagnifyingGlassIcon}
iconClassName="!w-5 !h-5"
dataTip={`Search ${library.title}`}
/>
</div>
)}
{!route.pathname.includes('knowledge-insights') && (
<div onClick={handleSearchClick}>
<ULIComponent
icon={MagnifyingGlassIcon}
iconClassName="!w-5 !h-5"
dataTip={`Search ${library.title}`}
/>
</div>
)}
<div onClick={(e) => void handleToggleAction('favorite', e)}>
{!route.pathname.includes('knowledge-insights') && (
<ULIComponent
Expand Down
15 changes: 7 additions & 8 deletions frontend/src/Components/VideoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useToast } from '@/Context/ToastCtx';
import { StarIcon } from '@heroicons/react/24/solid';
import { StarIcon as StarIconOutline } from '@heroicons/react/24/outline';
import { AdminRoles } from '@/useAuth';
import ClampedText from './ClampedText';

export default function VideoCard({
video,
Expand Down Expand Up @@ -86,30 +87,28 @@ export default function VideoCard({
{bookmark}
</div>
)}
<div
className="flex flex-col p-4 gap-2 border-b-2"
>
<div className="flex flex-col p-4 gap-2 border-b-2">
<figure className="w-1/2 mx-auto bg-cover">
<img
src={video?.thumbnail_url ?? ''}
alt={`${video.title} thumbnail`}
/>
</figure>
<h3 className="body text-center h-10 line-clamp-2 my-auto">
<ClampedText as="h3" className="body text-center h-10 my-auto">
{video.title}
</h3>
</ClampedText>
</div>
<div className="p-4 space-y-2">
<p className="body font-bold sm:h-10 sm:line-clamp-2">
{video.channel_title} - {toMinutes(video.duration)}
</p>
<p className="body-small h-[40px] leading-5 line-clamp-2">
<ClampedText as="p" className="body-small h-[40px] leading-5">
{videoIsAvailable(video)
? video?.description
: getVideoErrorMessage(video) ??
`Video currently unavailable.
May be in the process of downloading, Please check back later`}
</p>
May be in the process of downloading, Please check back later`}
</ClampedText>
{AdminRoles.includes(role) &&
(videoIsAvailable(video) ? (
<VisibleHiddenToggle
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/Components/cards/HelpfulLinkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AdminRoles } from '@/useAuth';
import { useToast } from '@/Context/ToastCtx';
import { StarIcon } from '@heroicons/react/24/solid';
import { StarIcon as StarIconOutline } from '@heroicons/react/24/outline';
import ClampedText from '../ClampedText';

export default function HelpfulLinkCard({
link,
Expand Down Expand Up @@ -111,9 +112,12 @@ export default function HelpfulLinkCard({
alt={link.title}
className="h-16 mx-auto object-contain"
/>
<h3 className="body">{link.title}</h3>
<p className="body line-clamp-2 h-10">{link.description}</p>

<ClampedText as="h3" className="w-3/4 body my-auto mr-7">
{link.title}
</ClampedText>
<ClampedText as="p" className="body h-10">
{link.description}
</ClampedText>
{AdminRoles.includes(role) && (
<VisibleHiddenToggle
visible={visible}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/Components/dashboard/TopContentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { OpenContentItem } from '@/common';
import OpenContentCard from '../cards/OpenContentCard';
import ULIComponent from '../ULIComponent';
import { ArrowTopRightOnSquareIcon } from '@heroicons/react/24/outline';
import ClampedText from '../ClampedText';

export default function TopContentList({
heading,
Expand Down Expand Up @@ -32,9 +33,9 @@ export default function TopContentList({
tooltipClassName="h-8 flex items-center"
icon={ArrowTopRightOnSquareIcon}
/>
<h3 className="body font-normal">
<ClampedText as="h3" className="body font-normal">
Explore other content offered
</h3>
</ClampedText>
</div>
)}
</div>
Expand Down

0 comments on commit 81b21b5

Please sign in to comment.