Skip to content

Commit

Permalink
feat(search): Add word break after special characters in search cards (
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr authored Oct 1, 2024
1 parent 1c3e77f commit 45c295e
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@ export const Headline: React.FC<Props> = ({ text, matchIndices, variant }) => {
return (
<>
{text.split("").map((char, index) => (
<Typography
component="span"
variant={variant}
key={`headline-character-${index}`}
sx={(theme) => ({
fontWeight: isHighlighted(index) ? FONT_WEIGHT_BOLD : "regular",
fontSize: theme.typography.body2.fontSize,
})}
>
{char}
</Typography>
<>
<Typography
component="span"
variant={variant}
key={`headline-character-${index}`}
sx={(theme) => ({
fontWeight: isHighlighted(index) ? FONT_WEIGHT_BOLD : "regular",
fontSize: theme.typography.body2.fontSize,
})}
>
{char}
</Typography>
{/* Add wordbreak after special characters */}
{char.match(/\W/) && <wbr />}
</>
))}
</>
);
Expand Down

0 comments on commit 45c295e

Please sign in to comment.