Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRY social icons #644

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Get rid of dangerouslySetInnerHTML in Social image styles with the ex…
…cellent hover-color suggestion from Cursor editor
  • Loading branch information
onnimonni committed Nov 1, 2024
commit f993997eb066d63f1920de70eb58c415a53a54b1
14 changes: 3 additions & 11 deletions components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,12 @@ export function FooterImpl() {
)}
</div>

<style
dangerouslySetInnerHTML={{
__html: socialLinks.map((action) => (
`.social-link-footer-${action.name} {}
.social-link-footer-${action.name}:hover { color: ${action.color}; }
`
)).join('\n')
}}
/>

<div className={styles.social}>
{socialLinks.map((action) => (
<a
className={cs(styles[action.name], `social-link-footer-${action.name}`)}
key={action.name}
style={{ '--hover-color': action.color } as React.CSSProperties}
className={styles[action.name]}
href={action.href}
title={action.title}
target='_blank'
Expand Down
31 changes: 3 additions & 28 deletions components/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,39 +85,14 @@
.social a:hover {
transition: color 50ms ease-out;
}

.toggleDarkMode:hover {
color: #2795e9;
.social a:hover {
color: var(--hover-color);
}

.twitter:hover {
.toggleDarkMode:hover {
color: #2795e9;
}

.mastodon:hover {
color: #5a4be1;
}

.zhihu:hover {
color: #0066ff;
}

.github:hover {
color: #c9510c;
}

.youtube:hover {
color: #ff0000;
}

.linkedin:hover {
color: #0077b5;
}

.newsletter:hover {
color: #777777;
}

.comments {
width: 100%;
margin-top: 2em;
Expand Down