Skip to content

Commit 3423f03

Browse files
committed
Define the logos and colors only in one place, remove color duplication from from the css
1 parent f993997 commit 3423f03

File tree

4 files changed

+39
-91
lines changed

4 files changed

+39
-91
lines changed

components/Footer.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IoMoonSharp, IoSunnyOutline } from 'react-icons/io5'
44

55
import * as config from '@/lib/config'
66
import { useDarkMode } from '@/lib/use-dark-mode'
7-
import { socialLinks } from './PageSocial'
7+
import { PageSocialButtons } from './PageSocial'
88

99
import styles from './styles.module.css'
1010

@@ -48,20 +48,7 @@ export function FooterImpl() {
4848
</div>
4949

5050
<div className={styles.social}>
51-
{socialLinks.map((action) => (
52-
<a
53-
key={action.name}
54-
style={{ '--hover-color': action.color } as React.CSSProperties}
55-
className={styles[action.name]}
56-
href={action.href}
57-
title={action.title}
58-
target='_blank'
59-
rel='noopener noreferrer'
60-
>
61-
{action.icon({ size: 16 })}
62-
</a>
63-
))}
64-
51+
<PageSocialButtons />
6552
</div>
6653
</footer>
6754
)

components/PageSocial.module.css

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
color: var(--fg-color);
77
}
88

9+
.socialLink:hover {
10+
color: var(--hover-color);
11+
}
12+
13+
.pageSocial .actionBgPane {
14+
background: var(--hover-color);
15+
}
16+
17+
.pageSocial .socialLink:hover {
18+
color: var(--fg-color);
19+
border-color: var(--hover-color);;
20+
}
21+
922
.action {
1023
position: relative;
1124
border-radius: 50%;
@@ -72,62 +85,6 @@
7285
fill: var(--fg-color);
7386
}
7487

75-
.facebook .actionBgPane {
76-
background: #3b5998;
77-
}
78-
.facebook:hover {
79-
border-color: #3b5998;
80-
}
81-
82-
.twitter .actionBgPane {
83-
background: #2795e9;
84-
}
85-
.twitter:hover {
86-
border-color: #2795e9;
87-
}
88-
89-
.linkedin .actionBgPane {
90-
background: #0077b5;
91-
}
92-
.linkedin:hover {
93-
border-color: #0077b5;
94-
}
95-
96-
.github .actionBgPane {
97-
background: #c9510c;
98-
}
99-
.github:hover {
100-
border-color: #c9510c;
101-
}
102-
103-
.youtube .actionBgPane {
104-
background: #ff0000;
105-
}
106-
.youtube:hover {
107-
border-color: #ff0000;
108-
}
109-
110-
.medium .actionBgPane {
111-
background: #00ab6c;
112-
}
113-
.medium:hover {
114-
border-color: #00ab6c;
115-
}
116-
117-
.newsletter .actionBgPane {
118-
background: #777777;
119-
}
120-
.newsletter:hover {
121-
border-color: #777777;
122-
}
123-
124-
.email .actionBgPane {
125-
background: #777;
126-
}
127-
.email:hover {
128-
border-color: #777;
129-
}
130-
13188
@media only screen and (max-width: 768px) {
13289
.links {
13390
position: relative;

components/PageSocial.tsx

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,23 @@ export const socialLinks: SocialLink[] = [
7676
config.bugtracker && {
7777
name: 'bugtracker',
7878
href: `${config.bugtracker}`,
79-
title: `Bugtracker`,
79+
title: 'Bugtracker',
8080
color: "#e24329",
8181
icon: IoIosBug
8282
}
8383
].filter(Boolean)
8484

85-
function generateCssFrag(prefix: string) {
86-
return socialLinks.map((action) => (
87-
`.social-link-${prefix}-${action.name} {}
88-
.social-link-${prefix}-${action.name}:hover {
89-
background: ${action.color};
90-
color: white;
91-
}
92-
`
93-
)).join('\n');
94-
}
95-
9685
export function PageSocial(prefix: string) {
9786
return (
9887
<>
99-
<style
100-
dangerouslySetInnerHTML={{ __html: generateCssFrag("side") }}
101-
/>
10288
<div className={styles.pageSocial}>
10389
{socialLinks.map((action) => (
10490
<>
10591
<a
106-
className={cs(styles.action, styles[action.name], `social-link-side-${action.name}`)}
107-
href={action.href}
10892
key={action.name}
93+
style={{ '--hover-color': action.color } as React.CSSProperties}
94+
className={cs(styles.action, styles[action.name], styles.socialLink)}
95+
href={action.href}
10996
title={action.title}
11097
target='_blank'
11198
rel='noopener noreferrer'
@@ -122,3 +109,23 @@ export function PageSocial(prefix: string) {
122109
</>
123110
)
124111
}
112+
113+
export function PageSocialButtons() {
114+
return (
115+
<>
116+
{socialLinks.map((action) => (
117+
<a
118+
key={action.name}
119+
style={{ '--hover-color': action.color } as React.CSSProperties}
120+
className={cs(styles[action.name], styles.socialLink)}
121+
href={action.href}
122+
title={action.title}
123+
target='_blank'
124+
rel='noopener noreferrer'
125+
>
126+
{action.icon({ size: 32 })}
127+
</a>
128+
))}
129+
</>
130+
)
131+
}

components/styles.module.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@
8585
.social a:hover {
8686
transition: color 50ms ease-out;
8787
}
88-
.social a:hover {
89-
color: var(--hover-color);
90-
}
9188

9289
.toggleDarkMode:hover {
9390
color: #2795e9;

0 commit comments

Comments
 (0)