|
1 | 1 | import { Hit } from "instantsearch.js"
|
2 |
| -import { maple } from "components/links" |
3 | 2 | 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" |
4 | 9 | import { Testimony } from "components/db/testimony"
|
5 |
| -import { trimContent } from "components/TestimonyCallout/TestimonyCallout" |
| 10 | +import { useFlags } from "components/featureFlags" |
6 | 11 | import { formatBillId } from "components/formatting"
|
7 |
| -import { useBill } from "components/db/bills" |
| 12 | +import { maple } from "components/links" |
8 | 13 | 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" |
13 | 15 |
|
14 | 16 | export const TestimonyHit = ({ hit }: { hit: Hit<Testimony> }) => {
|
15 | 17 | const url = maple.testimony({ publishedId: hit.id })
|
@@ -44,6 +46,14 @@ const TestimonyResult = ({ hit }: { hit: Hit<Testimony> }) => {
|
44 | 46 | const { user } = useAuth()
|
45 | 47 | const { followOrg } = useFlags()
|
46 | 48 | 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 | + } |
47 | 57 |
|
48 | 58 | return (
|
49 | 59 | <div
|
@@ -104,7 +114,9 @@ const TestimonyResult = ({ hit }: { hit: Hit<Testimony> }) => {
|
104 | 114 | padding: "5px 10px"
|
105 | 115 | }}
|
106 | 116 | >
|
107 |
| - {committee.name} |
| 117 | + {isMobile |
| 118 | + ? limitStringLength35Char(committee.name) |
| 119 | + : committee.name} |
108 | 120 | </span>
|
109 | 121 | )}
|
110 | 122 | </div>
|
|
0 commit comments