Skip to content

Commit 659801d

Browse files
authored
Transcription hover element (#2053)
* active element styling * reset hovered onclick * align update button center * readd active element border
1 parent 5745f2d commit 659801d

1 file changed

Lines changed: 83 additions & 35 deletions

File tree

components/hearing/Transcriptions.tsx

Lines changed: 83 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { faMagnifyingGlass, faTimes } from "@fortawesome/free-solid-svg-icons"
22
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
3+
import ArrowRightAlt from "@mui/icons-material/ArrowRightAlt"
34
import ShareIcon from "@mui/icons-material/Share"
45
import ShareOutlinedIcon from "@mui/icons-material/ShareOutlined"
56
import { useRouter } from "next/router"
@@ -14,7 +15,6 @@ import {
1415
formatTotalSeconds
1516
} from "./hearing"
1617
import { ShareLinkButton } from "components/buttons"
17-
1818
import { siteUrl } from "components/links"
1919

2020
const ClearButton = styled(FontAwesomeIcon)`
@@ -124,8 +124,16 @@ const TranscriptRow = styled(Row)`
124124
border-bottom-left-radius: 0.75rem;
125125
border-bottom-right-radius: 0.75rem;
126126
}
127+
&:hover {
128+
background-color: #d9dfea;
129+
border-color: #1a3185;
130+
border-style: solid;
131+
border-width: 5px;
132+
}
127133
`
128134

135+
const TranscriptRowActive = styled(Row)``
136+
129137
export const Transcriptions = ({
130138
hearingId,
131139
transcriptData,
@@ -334,6 +342,7 @@ const TranscriptItem = forwardRef(function TranscriptItem(
334342
set currentTime property of <video> element */
335343

336344
setCurTimeVideo(valSeconds)
345+
setIsHovered(false)
337346
}
338347

339348
const isHighlighted = (index: number): boolean => {
@@ -358,34 +367,32 @@ const TranscriptItem = forwardRef(function TranscriptItem(
358367
const [isHovered, setIsHovered] = useState(false)
359368

360369
return (
361-
<TranscriptRow
362-
className={
363-
isHighlighted(index)
364-
? `bg-info border-5 border-secondary border-start`
365-
: `border-5`
366-
}
367-
ref={ref}
368-
>
369-
<TimestampCol>
370-
<Row className={`d-inline`}>
371-
<TimestampButton
372-
onClick={() => {
373-
handleClick(element.start)
374-
}}
375-
className={`bg-transparent border-0 text-nowrap p-1`}
376-
type="button"
377-
value={element.start}
378-
>
379-
{formatMilliseconds(element.start)}
380-
{" - "}
381-
{formatMilliseconds(element.end)}
382-
</TimestampButton>
383-
</Row>
384-
</TimestampCol>
385-
<Col className={`pt-1`}>{highlightText(element.text, searchTerm)}</Col>
386-
<Col xs="1" className={`my-1 px-0`}>
387-
{isHighlighted(index) ? (
388-
<>
370+
<>
371+
{isHighlighted(index) ? (
372+
<TranscriptRowActive
373+
className={`bg-info border-5 border-secondary border-start`}
374+
ref={ref}
375+
>
376+
<TimestampCol>
377+
<Row className={`d-inline`}>
378+
<TimestampButton
379+
onClick={() => {
380+
handleClick(element.start)
381+
}}
382+
className={`bg-transparent border-0 text-nowrap p-1`}
383+
type="button"
384+
value={element.start}
385+
>
386+
{formatMilliseconds(element.start)}
387+
{" - "}
388+
{formatMilliseconds(element.end)}
389+
</TimestampButton>
390+
</Row>
391+
</TimestampCol>
392+
<Col className={`pt-1`}>
393+
{highlightText(element.text, searchTerm)}
394+
</Col>
395+
<Col xs="1" className={`my-1 px-0`}>
389396
<ShareLinkButton
390397
key="copy"
391398
text={siteUrl(
@@ -398,11 +405,52 @@ const TranscriptItem = forwardRef(function TranscriptItem(
398405
>
399406
{isHovered ? <ShareIcon /> : <ShareOutlinedIcon />}
400407
</ShareLinkButton>
401-
</>
402-
) : (
403-
<></>
404-
)}
405-
</Col>
406-
</TranscriptRow>
408+
</Col>
409+
</TranscriptRowActive>
410+
) : (
411+
<TranscriptRow
412+
className={`border-5`}
413+
onMouseEnter={() => setIsHovered(true)}
414+
onMouseLeave={() => setIsHovered(false)}
415+
ref={ref}
416+
>
417+
<TimestampCol>
418+
<Row className={`d-inline`}>
419+
<TimestampButton
420+
onClick={() => {
421+
handleClick(element.start)
422+
}}
423+
className={`bg-transparent border-0 text-nowrap p-1`}
424+
type="button"
425+
value={element.start}
426+
>
427+
{formatMilliseconds(element.start)}
428+
{" - "}
429+
{formatMilliseconds(element.end)}
430+
</TimestampButton>
431+
</Row>
432+
</TimestampCol>
433+
<Col className={`pt-1`}>
434+
{highlightText(element.text, searchTerm)}
435+
</Col>
436+
<Col xs="1" className={`d-flex align-items-center my-1 px-0`}>
437+
<TimestampButton
438+
onClick={() => {
439+
handleClick(element.start)
440+
}}
441+
className={`bg-transparent border-0 p-1 text-nowrap `}
442+
type="button"
443+
value={element.start}
444+
>
445+
{isHovered ? (
446+
<ArrowRightAlt fontSize="large" style={{ color: "#737373" }} />
447+
) : (
448+
<></>
449+
)}
450+
</TimestampButton>
451+
</Col>
452+
</TranscriptRow>
453+
)}
454+
</>
407455
)
408456
})

0 commit comments

Comments
 (0)