-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TICKET 26 Hyperlink in Question and Option (#56)
* Hyperlink * Hyperlink * Revert "Hyperlink" This reverts commit 6f935e8. * hyperlinks options only * text links things * final!' * formatting --------- Co-authored-by: Danish Farooq <[email protected]> Co-authored-by: David Stephenson <[email protected]>
- Loading branch information
1 parent
f35e3e8
commit 662b994
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
frontend/src/components/VideoCall/VideoFrontend/components/PollsWindow/TextWithHyperlink.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
|
||
export default function TextWithHyperlink(props: { | ||
text: string; | ||
className: string; | ||
selected: boolean; | ||
}) { | ||
const urlRegex = /(https?:\/\/[^\s]+)/gi; | ||
const match = props.text.match(urlRegex); | ||
|
||
if (match && match.length > 0) { | ||
return ( | ||
<div style={{ display: 'flex', alignItems: 'center' }}> | ||
<p className={props.className} style={{ marginRight: '8px', wordBreak: 'break-all' }}> | ||
{props.text} | ||
</p> | ||
<a href={match[0]} target='_blank' rel='noopener noreferrer'> | ||
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' width='18'> | ||
<path | ||
fill={props.selected ? '#fff' : '#314e89'} | ||
d='M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32h82.7L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3V192c0 17.7 14.3 32 32 32s32-14.3 32-32V32c0-17.7-14.3-32-32-32H320zM80 32C35.8 32 0 67.8 0 112V432c0 44.2 35.8 80 80 80H400c44.2 0 80-35.8 80-80V320c0-17.7-14.3-32-32-32s-32 14.3-32 32V432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V112c0-8.8 7.2-16 16-16H192c17.7 0 32-14.3 32-32s-14.3-32-32-32H80z' | ||
/> | ||
</svg> | ||
</a> | ||
</div> | ||
); | ||
} | ||
|
||
return <p className={props.className}>{props.text}</p>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters