Skip to content

Commit 27d34f5

Browse files
committed
adjusts component naming scheme and context shape, fixes webpack configurations and dependency lists
- removes modal key from ModalContext - renames withModalContext to withModal - renames useModalContext to useModal - adds source map to development bundle - adds inline source map to production bundle - removes react from production bundle - removes react and react-dom from dependencies - adds react and react-dom as devDependencies and peerDependencies
1 parent 79df096 commit 27d34f5

File tree

12 files changed

+94
-43
lines changed

12 files changed

+94
-43
lines changed

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,14 @@ $ yarn add @trbl/react-scroll-info
2020
import React from 'react';
2121
import { ScrollInfoProvider, withScrollInfo, useScrollInfo } from '@trbl/react-scroll-info';
2222

23-
const MyComponent = withScrollInfo(() => <div>My Component</div>);
24-
const MyOtherComponent = () => <div>{useScrollInfo()}</div>;
23+
const WithScrollInfo = withScrollInfo(({ scrollInfo }) => <div>{scrollInfo}</div>);
24+
const UseScrollInfo = () => <div>{useScrollInfo()}</div>;
2525

2626
const App = () => {
2727
return (
2828
<ScrollInfoProvider>
29-
<MyComponent>
30-
...
31-
</MyComponent>
32-
<MyOtherComponent>
33-
...
34-
</MyOtherComponent>
29+
<WithScrollInfo />
30+
<UseScrollInfo />
3531
</ScrollInfoProvider>
3632
)
3733
}

demo/App.demo.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React from 'react';
22
import { ScrollInfoProvider } from '../src'; // swap '../src' for '../dist/build.bundle' to demo production build
3-
import ScrollInfoDemo from './ScrollInfo.demo';
3+
// import WithScrollInfo from './WithScrollInfo.demo';
4+
import UseScrollInfo from './UseScrollInfo.demo';
45

56
const AppDemo = () => (
67
<ScrollInfoProvider>
7-
<ScrollInfoDemo />
8+
{/* <WithScrollInfo /> */}
9+
<UseScrollInfo />
810
<div
911
id="spacer"
1012
style={{ height: '16000px', width: '10000px' }}

demo/UseScrollInfo.demo.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import React from 'react';
2+
import { useScrollInfo } from '../src'; // swap '../src' for '../dist/build.bundle' to demo production build
3+
4+
const UseScrollInfo = () => {
5+
const {
6+
x,
7+
y,
8+
xDifference,
9+
yDifference,
10+
xDirection,
11+
yDirection,
12+
xPercentage,
13+
yPercentage,
14+
totalPercentage,
15+
eventsFired,
16+
} = useScrollInfo();
17+
18+
return (
19+
<div style={{ position: 'fixed' }}>
20+
<code>
21+
<pre>
22+
{'scrollInfo: {'}
23+
<br />
24+
&emsp;
25+
{`x: ${x},`}
26+
<br />
27+
&emsp;
28+
{`y: ${y},`}
29+
<br />
30+
&emsp;
31+
{`xDifference: ${xDifference},`}
32+
<br />
33+
&emsp;
34+
{`yDifference: ${yDifference},`}
35+
<br />
36+
&emsp;
37+
{`xDirection: ${xDirection},`}
38+
<br />
39+
&emsp;
40+
{`yDirection: ${yDirection},`}
41+
<br />
42+
&emsp;
43+
{`xPercentage: ${xPercentage},`}
44+
<br />
45+
&emsp;
46+
{`yPercentage: ${yPercentage},`}
47+
<br />
48+
&emsp;
49+
{`totalPercentage: ${totalPercentage},`}
50+
<br />
51+
&emsp;
52+
{`eventsFired: ${eventsFired},`}
53+
<br />
54+
{'}'}
55+
</pre>
56+
</code>
57+
</div>
58+
);
59+
};
60+
61+
export default UseScrollInfo;
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import {
4-
// useScrollInfo,
5-
withScrollInfo,
6-
} from '../src'; // swap '../src' for '../dist/build.bundle' to demo production build
3+
import { withScrollInfo } from '../src'; // swap '../src' for '../dist/build.bundle' to demo production build
74

8-
const ScrollInfoDemo = (props) => {
5+
const WithScrollInfo = (props) => {
96
const {
107
scrollInfo: {
118
x,
@@ -19,7 +16,7 @@ const ScrollInfoDemo = (props) => {
1916
totalPercentage,
2017
eventsFired,
2118
},
22-
} = props; // to demo hook, change to `useScrollInfo()` and remove `withScrollInfo` HOC
19+
} = props;
2320

2421
return (
2522
<div style={{ position: 'fixed' }}>
@@ -64,7 +61,7 @@ const ScrollInfoDemo = (props) => {
6461
);
6562
};
6663

67-
ScrollInfoDemo.propTypes = {
64+
WithScrollInfo.propTypes = {
6865
scrollInfo: PropTypes.shape({
6966
x: PropTypes.number,
7067
y: PropTypes.number,
@@ -87,4 +84,4 @@ ScrollInfoDemo.propTypes = {
8784
}).isRequired,
8885
};
8986

90-
export default withScrollInfo(ScrollInfoDemo);
87+
export default withScrollInfo(WithScrollInfo);

dist/build.bundle.js

Lines changed: 2 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/build.bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)