Skip to content

Commit b710186

Browse files
author
Ahmad Awais ⚡️
authored
feat: Brand color hover on links images & testUpdate (nodejs#221)
* style: Brand color hover on links * refactor: Consistent anchor link styles * revert: Formatting * fix: No margin left on first author * refactor: Index is more descriptive * style: Hover scale * refactor: Tests should update snapshots * fix: Tests with Updated Jest Snapshots * refactor: Jest snapshots
1 parent abd7bf5 commit b710186

6 files changed

Lines changed: 70 additions & 12 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@
4646
"format": "prettier --write '**/*.{ts,tsx,js}'",
4747
"format-check": "prettier --check '**/*.{ts,tsx,js}'",
4848
"jest": "jest",
49-
"snapshot": "jest --updateSnapshot",
49+
"jestUpdate": "jest --updateSnapshot",
5050
"test": "yarn format-check && yarn tslint && yarn jest",
51+
"testUpdate": "yarn format-check && yarn tslint && yarn jestUpdate",
5152
"tslint": "tslint --project ./tsconfig.json",
5253
"serve": "yarn run build && clear && gatsby serve"
5354
},

src/components/author.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ const list = css`
77

88
const link = css`
99
margin-left: 0.5rem;
10+
11+
&:hover img {
12+
transform: scale(1.1);
13+
}
1014
`;
1115

1216
const img = css`
@@ -15,22 +19,28 @@ const img = css`
1519
margin-top: 5px;
1620
border-radius: 100%;
1721
border: 1px solid var(--brand-light);
22+
transition: all 0.2s ease-in-out;
1823
`;
1924

2025
type Props = {
26+
index: Number;
2127
username: string;
2228
size: string;
2329
};
2430

25-
const Author = ({ username, size = '64' }: Props) => {
31+
const Author = ({ index, username, size = '64' }: Props) => {
2632
if (!username) {
2733
return null;
2834
}
2935

36+
// Clean up username and build links.
3037
username = username.trim();
3138
const githubLink = `https://github.com/${username}`;
3239
const githubImgLink = `https://github.com/${username}.png?size=${size}`;
3340

41+
// If it's the first author then no margin left.
42+
const mleft = index === 0 ? { marginLeft: 0 } : {};
43+
3444
return (
3545
<li css={list}>
3646
<a
@@ -40,6 +50,7 @@ const Author = ({ username, size = '64' }: Props) => {
4050
key={username}
4151
target="_blank"
4252
rel="noopener noreferrer"
53+
style={mleft}
4354
>
4455
<img
4556
css={img}

src/components/authors-list.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const list = css`
1111
text-transform: uppercase;
1212
padding-left: 0;
1313
14+
li:first-child a {
15+
margin-left: 0 !important;
16+
}
17+
1418
h5 {
1519
display: flex;
1620
flex-wrap: wrap;
@@ -34,7 +38,10 @@ const AuthorsList = ({ authors }: Props) => {
3438
<ul css={list}>
3539
<h5>Contributors</h5>
3640
{authors.map(
37-
author => author && <Author username={author} key={author} size="60" />
41+
(author, i) =>
42+
author && (
43+
<Author index={i} username={author} key={author} size="60" />
44+
)
3845
)}
3946
</ul>
4047
);

src/components/layout.css

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,13 @@ main {
418418
color: var(--gray9);
419419
font-weight: 600;
420420
text-decoration: underline;
421+
text-decoration-color: var(--gray4);
422+
transition: all ease-out 0.2s;
423+
}
424+
425+
.article-reader a:hover {
426+
color: var(--brand-light);
427+
text-decoration: none;
421428
}
422429

423430
.article-reader h1,
@@ -549,8 +556,14 @@ details,
549556
}
550557
.toc a {
551558
font-family: var(--sans-serif);
559+
text-decoration: underline;
560+
text-decoration-color: var(--gray4);
561+
transition: all ease-out 0.2s;
562+
}
563+
564+
.toc a:hover {
565+
color: var(--brand-light);
552566
text-decoration: none;
553-
border-bottom: 1px dotted var(--gray3);
554567
}
555568

556569
.toc li p {
@@ -583,4 +596,4 @@ details,
583596
.sticky-sentinel--bottom {
584597
height: 40px;
585598
bottom: 0;
586-
}
599+
}

test/components/__snapshots__/author.test.tsx.snap

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,20 @@ exports[`Author component renders correctly 1`] = `
1717
css={
1818
Object {
1919
"map": undefined,
20-
"name": "tubh1u",
20+
"name": "1uax1e8",
2121
"next": undefined,
2222
"styles": "
2323
margin-left: 0.5rem;
24+
25+
&:hover img {
26+
transform: scale(1.1);
27+
}
2428
",
2529
}
2630
}
2731
href="https://github.com/test-author"
2832
rel="noopener noreferrer"
33+
style={Object {}}
2934
target="_blank"
3035
title="test-author"
3136
>
@@ -35,14 +40,15 @@ exports[`Author component renders correctly 1`] = `
3540
css={
3641
Object {
3742
"map": undefined,
38-
"name": "nm77gf",
43+
"name": "bq2cf",
3944
"next": undefined,
4045
"styles": "
4146
height: 30px;
4247
width: 30px;
4348
margin-top: 5px;
4449
border-radius: 100%;
4550
border: 1px solid var(--brand-light);
51+
transition: all 0.2s ease-in-out;
4652
",
4753
}
4854
}

test/components/__snapshots__/authors-list.test.tsx.snap

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`AuthorsList component renders correctly 1`] = `
55
css={
66
Object {
77
"map": undefined,
8-
"name": "irphdi",
8+
"name": "1bgkbt8",
99
"next": undefined,
1010
"styles": "
1111
display: flex;
@@ -16,6 +16,10 @@ exports[`AuthorsList component renders correctly 1`] = `
1616
text-transform: uppercase;
1717
padding-left: 0;
1818
19+
li:first-child a {
20+
margin-left: 0 !important;
21+
}
22+
1923
h5 {
2024
display: flex;
2125
flex-wrap: wrap;
@@ -47,15 +51,24 @@ exports[`AuthorsList component renders correctly 1`] = `
4751
css={
4852
Object {
4953
"map": undefined,
50-
"name": "tubh1u",
54+
"name": "1uax1e8",
5155
"next": undefined,
5256
"styles": "
5357
margin-left: 0.5rem;
58+
59+
&:hover img {
60+
transform: scale(1.1);
61+
}
5462
",
5563
}
5664
}
5765
href="https://github.com/test-author"
5866
rel="noopener noreferrer"
67+
style={
68+
Object {
69+
"marginLeft": 0,
70+
}
71+
}
5972
target="_blank"
6073
title="test-author"
6174
>
@@ -65,14 +78,15 @@ exports[`AuthorsList component renders correctly 1`] = `
6578
css={
6679
Object {
6780
"map": undefined,
68-
"name": "nm77gf",
81+
"name": "bq2cf",
6982
"next": undefined,
7083
"styles": "
7184
height: 30px;
7285
width: 30px;
7386
margin-top: 5px;
7487
border-radius: 100%;
7588
border: 1px solid var(--brand-light);
89+
transition: all 0.2s ease-in-out;
7690
",
7791
}
7892
}
@@ -96,15 +110,20 @@ exports[`AuthorsList component renders correctly 1`] = `
96110
css={
97111
Object {
98112
"map": undefined,
99-
"name": "tubh1u",
113+
"name": "1uax1e8",
100114
"next": undefined,
101115
"styles": "
102116
margin-left: 0.5rem;
117+
118+
&:hover img {
119+
transform: scale(1.1);
120+
}
103121
",
104122
}
105123
}
106124
href="https://github.com/another-test-author"
107125
rel="noopener noreferrer"
126+
style={Object {}}
108127
target="_blank"
109128
title="another-test-author"
110129
>
@@ -114,14 +133,15 @@ exports[`AuthorsList component renders correctly 1`] = `
114133
css={
115134
Object {
116135
"map": undefined,
117-
"name": "nm77gf",
136+
"name": "bq2cf",
118137
"next": undefined,
119138
"styles": "
120139
height: 30px;
121140
width: 30px;
122141
margin-top: 5px;
123142
border-radius: 100%;
124143
border: 1px solid var(--brand-light);
144+
transition: all 0.2s ease-in-out;
125145
",
126146
}
127147
}

0 commit comments

Comments
 (0)