Skip to content

Commit a9f0ebb

Browse files
committed
limit testimony committee length
1 parent 5b11899 commit a9f0ebb

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

components/search/testimony/TestimonyHit.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { Hit } from "instantsearch.js"
2-
import { maple } from "components/links"
32
import Link from "next/link"
3+
import { useTranslation } from "next-i18next"
4+
import { Image } from "react-bootstrap"
5+
import { useMediaQuery } from "usehooks-ts"
6+
7+
import { useAuth } from "components/auth"
8+
import { useBill } from "components/db/bills"
49
import { Testimony } from "components/db/testimony"
5-
import { trimContent } from "components/TestimonyCallout/TestimonyCallout"
10+
import { useFlags } from "components/featureFlags"
611
import { formatBillId } from "components/formatting"
7-
import { useBill } from "components/db/bills"
12+
import { maple } from "components/links"
813
import { FollowUserButton } from "components/shared/FollowButton"
9-
import { Image } from "react-bootstrap"
10-
import { useFlags } from "components/featureFlags"
11-
import { useAuth } from "components/auth"
12-
import { useTranslation } from "next-i18next"
14+
import { trimContent } from "components/TestimonyCallout/TestimonyCallout"
1315

1416
export const TestimonyHit = ({ hit }: { hit: Hit<Testimony> }) => {
1517
const url = maple.testimony({ publishedId: hit.id })
@@ -44,6 +46,14 @@ const TestimonyResult = ({ hit }: { hit: Hit<Testimony> }) => {
4446
const { user } = useAuth()
4547
const { followOrg } = useFlags()
4648
const isCurrentUser = user?.uid === hit.authorUid
49+
const isMobile = useMediaQuery("(max-width: 768px)")
50+
51+
function limitStringLength35Char(str: string) {
52+
if (str.length > 35) {
53+
return str.substring(0, 35)
54+
}
55+
return str
56+
}
4757

4858
return (
4959
<div
@@ -104,7 +114,9 @@ const TestimonyResult = ({ hit }: { hit: Hit<Testimony> }) => {
104114
padding: "5px 10px"
105115
}}
106116
>
107-
{committee.name}
117+
{isMobile
118+
? limitStringLength35Char(committee.name)
119+
: committee.name}
108120
</span>
109121
)}
110122
</div>

0 commit comments

Comments
 (0)