Skip to content

Commit 1b7099d

Browse files
authored
Truncate bill summary to 1000 chars and add modal for longer summaries (#2084)
1 parent 9c867cb commit 1b7099d

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

components/bill/Summary.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,14 @@ export const ViewMessage = styled.div`
104104
}
105105
`
106106

107+
const BALLOT_SUMMARY_CHAR_LIMIT = 1000
108+
107109
export const Summary = ({
108110
bill,
109111
className
110112
}: BillProps & { className?: string }) => {
111113
const [showBillDetails, setShowBillDetails] = useState(false)
114+
const [showFullSummary, setShowFullSummary] = useState(false)
112115
const handleShowBillDetails = () => setShowBillDetails(true)
113116
const handleHideBillDetails = () => setShowBillDetails(false)
114117
const billText = bill?.content?.DocumentText
@@ -221,7 +224,36 @@ export const Summary = ({
221224
)}
222225
{bill.summary !== undefined && isBallotMeasure ? (
223226
<BallotSummaryRow className={`mx-1 mb-3`}>
224-
{bill.summary}
227+
{bill.summary.length > BALLOT_SUMMARY_CHAR_LIMIT ? (
228+
<>
229+
{bill.summary.slice(0, BALLOT_SUMMARY_CHAR_LIMIT)}{" "}
230+
<StyledButton
231+
variant="link"
232+
onClick={() => setShowFullSummary(true)}
233+
>
234+
{t("bill.view_full_summary")}
235+
</StyledButton>
236+
<Modal
237+
show={showFullSummary}
238+
onHide={() => setShowFullSummary(false)}
239+
size="lg"
240+
>
241+
<Modal.Header
242+
closeButton
243+
onClick={() => setShowFullSummary(false)}
244+
>
245+
<Modal.Title>{bill?.id}</Modal.Title>
246+
</Modal.Header>
247+
<Modal.Body className="bg-white">
248+
<FormattedBillDetails>
249+
{bill.summary}
250+
</FormattedBillDetails>
251+
</Modal.Body>
252+
</Modal>
253+
</>
254+
) : (
255+
bill.summary
256+
)}
225257
</BallotSummaryRow>
226258
) : (
227259
<Row className="mx-1 mb-3">{bill.summary}</Row>

public/locales/en/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"smart_tag": "AI Smart Tag",
6666
"status_and_history": "Status & History",
6767
"status_history": "Status History",
68-
"view_bill": "View Bill Text"
68+
"view_bill": "View Bill Text",
69+
"view_full_summary": "View Full Summary"
6970
},
7071
"bill_updates": "Bill Updates",
7172
"browse_bills": "browse bills",

0 commit comments

Comments
 (0)