-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created TextLinks to replace DisplayLinks and added to announcements
TextLinks component has been created to replace the previous function DisplayLinks, which did not support newlines. TextLinks functionality has been added to announcements in Catalog page and AlertDisplay.
- Loading branch information
Showing
5 changed files
with
53 additions
and
48 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
This file was deleted.
Oops, something went wrong.
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,48 @@ | ||
import React from "react"; | ||
import { Typography } from "@mui/material"; // Assuming you're using MUI for styling | ||
|
||
interface TextLinksProps { | ||
content: string; | ||
} | ||
|
||
const TextLinks: React.FC<TextLinksProps> = ({ content }) => { | ||
const formatTextWithLinks = (text: string) => { | ||
const urlRegex = /(https?:\/\/[^\s]+)/g; | ||
const parts = text.split(urlRegex); | ||
|
||
return ( | ||
<> | ||
{parts.map((part, index) => { | ||
if (urlRegex.test(part)) { | ||
return ( | ||
<a | ||
href={part} | ||
key={index} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
{part} | ||
</a> | ||
); | ||
} else { | ||
return <span key={index}>{part}</span>; | ||
} | ||
})} | ||
</> | ||
); | ||
}; | ||
|
||
return ( | ||
<Typography | ||
variant="body1" | ||
sx={{ | ||
width: "100%", | ||
whiteSpace: "pre-line", | ||
}} | ||
> | ||
{formatTextWithLinks(content)} | ||
</Typography> | ||
); | ||
}; | ||
|
||
export default TextLinks; |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export const PUBLIC_URL = | ||
process.env.REACT_APP_PUBLIC_URL || "http://localhost:3000"; | ||
export const SUPABASE_URL = | ||
process.env.REACT_APP_SUPABASE_URL || "https://base.stuysu.org/"; | ||
process.env.REACT_APP_SUPABASE_URL || "http://localhost:8000"; | ||
export const SUPABASE_ANON_KEY = | ||
process.env.REACT_APP_SUPABASE_ANON_KEY || | ||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE"; |
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