Skip to content

Commit c9bd3aa

Browse files
committed
put non-essential functionality for lecture in separate file
1 parent ad5e8c8 commit c9bd3aa

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

subjects/08-Render-Props/lecture.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import ReactDOM from "react-dom";
33
import PropTypes from "prop-types";
4+
import getHeaderStyle from './utils/getHeaderStyle';
45

56
document.body.style.background = `
67
linear-gradient(135deg,
@@ -11,24 +12,7 @@ document.body.style.background = `
1112
)
1213
`;
1314

14-
const getHeaderStyle = y => {
15-
const pin = y >= 100;
16-
const top = -y / 2;
17-
return {
18-
textTransform: "uppercase",
19-
textAlign: "center",
20-
width: "100%",
21-
margin: 0,
22-
position: "fixed",
23-
top: pin ? "0px" : `${top + 50}px`,
24-
textShadow: pin
25-
? `0px ${(y - 100) / 5}px ${Math.min(
26-
(y - 100) / 10,
27-
20
28-
)}px rgba(0, 0, 0, 0.5)`
29-
: "none"
30-
};
31-
};
15+
3216

3317
class App extends React.Component {
3418
state = { y: 0 };
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default function(y) {
2+
const pin = y >= 100;
3+
const top = -y / 2;
4+
return {
5+
textTransform: "uppercase",
6+
textAlign: "center",
7+
width: "100%",
8+
margin: 0,
9+
position: "fixed",
10+
top: pin ? "0px" : `${top + 50}px`,
11+
textShadow: pin
12+
? `0px ${(y - 100) / 5}px ${Math.min(
13+
(y - 100) / 10,
14+
20
15+
)}px rgba(0, 0, 0, 0.5)`
16+
: "none"
17+
};
18+
};

0 commit comments

Comments
 (0)