Skip to content

Commit 4619ddf

Browse files
refactor(website): Refactor ErrorBox anchor styling (#4144)
Resolves #3025 ## Summary - simplify ErrorBox by removing runtime link styling - apply bold and underline styling to links in alerts via global CSS - <img width="1072" alt="image" src="https://github.com/user-attachments/assets/92d4f5b2-daac-45d3-b0ad-5d21aa4c9b53" /> 🚀 Preview: Add `preview` label to enable
1 parent 8fa63b6 commit 4619ddf

2 files changed

Lines changed: 5 additions & 13 deletions

File tree

website/src/components/common/ErrorBox.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,13 @@ interface Props {
1212
const ErrorBox: React.FC<Props> = ({ title, children, level = 'error' }) => {
1313
const alertClass = `my-8 alert ${level === 'error' ? 'alert-error' : 'alert-warning'}`;
1414

15-
const ContentWithStyledLinks: React.FC<{ children: React.ReactNode }> = ({ children }) => {
16-
return React.Children.map(children, (child) => {
17-
if (React.isValidElement(child) && child.type === 'a') {
18-
return React.cloneElement(child as React.ReactElement, {
19-
className:
20-
`font-bold underline ${((child.props as Record<string, unknown>).className as string | undefined) ?? ''}`.trim(),
21-
});
22-
}
23-
return child;
24-
});
25-
};
26-
2715
return (
2816
<div className={alertClass}>
2917
{level === 'error' && <DangerousTwoToneIcon />}
3018
{level === 'warning' && <WarningTwoToneIcon />}
3119
<div className='grid-flow-row'>
3220
{title !== undefined && <p className='text-lg font-bold'>{title}</p>}
33-
<ContentWithStyledLinks>{children}</ContentWithStyledLinks>
21+
{children}
3422
</div>
3523
</div>
3624
);

website/src/styles/base.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ a {
1212
}
1313
}
1414

15+
.alert a {
16+
@apply font-bold underline;
17+
}
18+
1519
.fillColor {
1620
background-color: theme('colors.main');
1721
}

0 commit comments

Comments
 (0)