mirror of
https://github.com/narrrl/holy-flavor-rater.git
synced 2026-11-04 17:07:01 +01:00
redesign community page
This commit is contained in:
1 parent
0e9ea23d98
commit
0bed331c4e
2 files changed
+354
-165
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useTheme, alpha } from '@mui/material';
|
||||
|
||||
interface RichTextProps {
|
||||
text: string;
|
||||
}
|
||||
|
||||
const RichText: React.FC<RichTextProps> = ({ text }) => {
|
||||
const theme = useTheme();
|
||||
|
||||
if (!text) return null;
|
||||
|
||||
const parts = text.split(/(@\w+)/g);
|
||||
return (
|
||||
<span>
|
||||
{parts.map((part, i) => {
|
||||
if (part.startsWith('@')) {
|
||||
const username = part.substring(1);
|
||||
return (
|
||||
<Link
|
||||
key={i}
|
||||
to={`/profile/${username}`}
|
||||
style={{
|
||||
color: theme.palette.primary.main,
|
||||
textDecoration: 'none',
|
||||
fontWeight: 'bold',
|
||||
backgroundColor: alpha(theme.palette.primary.main, 0.1),
|
||||
padding: '0 4px',
|
||||
borderRadius: '4px'
|
||||
}}
|
||||
>
|
||||
{part}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
return part;
|
||||
})}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
export default RichText;
|
||||
Reference in new issue
Block a user