Skip to content

Commit d986949

Browse files
BeniChenisagirk
authored andcommitted
chore,refactor: Upgrade to Emotion 10; adapt in header & pagination (nodejs#172)
* chore: Update deps per emotion 10 * refactor: Adapt emotion in the styles of header & pagination * chore: Add back emotion dep to avoid unmet peer dependency
1 parent e7574b8 commit d986949

6 files changed

Lines changed: 248 additions & 157 deletions

File tree

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
"author": "Adam Miller <[email protected]>",
66
"private": true,
77
"dependencies": {
8+
"@emotion/core": "^10.0.7",
89
"@types/react-helmet": "^5.0.7",
910
"dotenv": "^6.0.0",
10-
"emotion": "^9.2.12",
11-
"emotion-server": "^9.2.12",
11+
"emotion": "^10.0.7",
12+
"emotion-server": "^10.0.7",
1213
"gatsby": "^2.0.0",
1314
"gatsby-plugin-canonical-urls": "^2.0.10",
1415
"gatsby-plugin-catch-links": "^2.0.9",
15-
"gatsby-plugin-emotion": "^2.0.5",
16+
"gatsby-plugin-emotion": "^4.0.4",
1617
"gatsby-plugin-manifest": "^2.0.2",
1718
"gatsby-plugin-offline": "^2.0.5",
1819
"gatsby-plugin-react-helmet": "^3.0.0",
@@ -27,7 +28,7 @@
2728
"prismjs": "^1.15.0",
2829
"react": "^16.8.0",
2930
"react-dom": "^16.8.0",
30-
"react-emotion": "^9.2.12",
31+
"react-emotion": "^10.0.0",
3132
"react-helmet": "^5.2.0",
3233
"tslint": "^5.11.0",
3334
"typescript": "^3.1.1"

src/components/header.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import { Link } from 'gatsby';
22
import React from 'react';
3-
import { css } from 'emotion';
3+
import { css, SerializedStyles } from '@emotion/core';
44
import logo from '../images/logo.svg';
55

6+
const ulStyles: SerializedStyles = css`
7+
@media (max-width: 380px) {
8+
padding: 0;
9+
}
10+
margin: 0 auto;
11+
padding: 0 4.8rem;
12+
display: flex;
13+
align-items: center;
14+
list-style: none;
15+
`;
16+
617
const Header = () => (
718
<nav className="nav">
8-
<ul
9-
css={css`
10-
@media (max-width: 380px) {
11-
padding: 0;
12-
}
13-
margin: 0 auto;
14-
padding: 0 4.8rem;
15-
display: flex;
16-
align-items: center;
17-
list-style: none;
18-
`}
19-
>
19+
<ul css={ulStyles}>
2020
<li>
2121
<Link to="/" style={{ display: 'block' }}>
2222
<img src={logo} alt="Node.js" className="nav__logo" />

src/components/pagination.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import { Link } from 'gatsby';
22
import React from 'react';
3+
import { css, SerializedStyles } from '@emotion/core';
34
import { PaginationInfo } from '../types';
45

56
type Props = {
67
previous?: PaginationInfo;
78
next?: PaginationInfo;
89
}
910

11+
const ulStyles: SerializedStyles = css`
12+
display: flex;
13+
flex-wrap: wrap;
14+
justify-content: space-between;
15+
list-style: none;
16+
padding: 30px;
17+
`;
18+
1019
const Pagination = ({ previous, next }: Props) => (
11-
<ul
12-
style={{
13-
display: `flex`,
14-
flexWrap: `wrap`,
15-
justifyContent: `space-between`,
16-
listStyle: `none`,
17-
padding: '30px',
18-
}}
19-
>
20+
<ul css={ulStyles}>
2021
<li>
2122
{previous && previous.title && (
2223
<Link to={`/${previous.slug}`} rel="prev">

test/components/__snapshots__/header.test.tsx.snap

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@ exports[`Tests for Header component renders correctly 1`] = `
55
className="nav"
66
>
77
<ul
8-
css="css-k9ksbg"
8+
css={
9+
Object {
10+
"map": undefined,
11+
"name": "xzcnt4",
12+
"next": undefined,
13+
"styles": "
14+
@media (max-width: 380px) {
15+
padding: 0;
16+
}
17+
margin: 0 auto;
18+
padding: 0 4.8rem;
19+
display: flex;
20+
align-items: center;
21+
list-style: none;
22+
",
23+
}
24+
}
925
>
1026
<li>
1127
<a

test/components/__snapshots__/pagination.test.tsx.snap

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
exports[`Pagination component only renders links to pages that has a title 1`] = `
44
<ul
5-
style={
5+
css={
66
Object {
7-
"display": "flex",
8-
"flexWrap": "wrap",
9-
"justifyContent": "space-between",
10-
"listStyle": "none",
11-
"padding": "30px",
7+
"map": undefined,
8+
"name": "4bjqmt",
9+
"next": undefined,
10+
"styles": "
11+
display: flex;
12+
flex-wrap: wrap;
13+
justify-content: space-between;
14+
list-style: none;
15+
padding: 30px;
16+
",
1217
}
1318
}
1419
>
@@ -26,13 +31,18 @@ exports[`Pagination component only renders links to pages that has a title 1`] =
2631

2732
exports[`Pagination component renders correctly when there is no next page 1`] = `
2833
<ul
29-
style={
34+
css={
3035
Object {
31-
"display": "flex",
32-
"flexWrap": "wrap",
33-
"justifyContent": "space-between",
34-
"listStyle": "none",
35-
"padding": "30px",
36+
"map": undefined,
37+
"name": "4bjqmt",
38+
"next": undefined,
39+
"styles": "
40+
display: flex;
41+
flex-wrap: wrap;
42+
justify-content: space-between;
43+
list-style: none;
44+
padding: 30px;
45+
",
3646
}
3747
}
3848
>
@@ -50,13 +60,18 @@ exports[`Pagination component renders correctly when there is no next page 1`] =
5060

5161
exports[`Pagination component renders correctly when there is no previous page 1`] = `
5262
<ul
53-
style={
63+
css={
5464
Object {
55-
"display": "flex",
56-
"flexWrap": "wrap",
57-
"justifyContent": "space-between",
58-
"listStyle": "none",
59-
"padding": "30px",
65+
"map": undefined,
66+
"name": "4bjqmt",
67+
"next": undefined,
68+
"styles": "
69+
display: flex;
70+
flex-wrap: wrap;
71+
justify-content: space-between;
72+
list-style: none;
73+
padding: 30px;
74+
",
6075
}
6176
}
6277
>
@@ -74,13 +89,18 @@ exports[`Pagination component renders correctly when there is no previous page 1
7489

7590
exports[`Pagination component renders links to the next and previous page 1`] = `
7691
<ul
77-
style={
92+
css={
7893
Object {
79-
"display": "flex",
80-
"flexWrap": "wrap",
81-
"justifyContent": "space-between",
82-
"listStyle": "none",
83-
"padding": "30px",
94+
"map": undefined,
95+
"name": "4bjqmt",
96+
"next": undefined,
97+
"styles": "
98+
display: flex;
99+
flex-wrap: wrap;
100+
justify-content: space-between;
101+
list-style: none;
102+
padding: 30px;
103+
",
84104
}
85105
}
86106
>

0 commit comments

Comments
 (0)