Skip to content

Commit 8e98f8f

Browse files
committed
run prettier on src, examples, and tests
1 parent ba85d3f commit 8e98f8f

File tree

20 files changed

+170
-153
lines changed

20 files changed

+170
-153
lines changed

__tests__/clamp.test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ const max = 100;
44
const min = 10;
55

66
test('Clamps a value within a range', () => {
7-
expect(clamp(50, min, max))
8-
.toBe(50);
7+
expect(clamp(50, min, max)).toBe(50);
98

10-
expect(clamp(110, min, max))
11-
.toBe(max);
9+
expect(clamp(110, min, max)).toBe(max);
1210

13-
expect(clamp(0, min, max))
14-
.toBe(min);
11+
expect(clamp(0, min, max)).toBe(min);
1512
});

__tests__/getParallaxOffsets.test.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,46 @@ const percentMoved = 44;
1313
test('Gets offsets based on percent in view', () => {
1414
expect(getParallaxOffsets(offset, percentMoved, false)).toEqual({
1515
x: {
16-
value: scaleBetween(percentMoved, offset.xMax.value, offset.xMin.value, 0, 100),
16+
value: scaleBetween(
17+
percentMoved,
18+
offset.xMax.value,
19+
offset.xMin.value,
20+
0,
21+
100
22+
),
1723
unit: offset.xMax.unit,
1824
},
1925
y: {
20-
value: scaleBetween(percentMoved, offset.yMax.value, offset.yMin.value, 0, 100),
26+
value: scaleBetween(
27+
percentMoved,
28+
offset.yMax.value,
29+
offset.yMin.value,
30+
0,
31+
100
32+
),
2133
unit: offset.yMax.unit,
2234
},
2335
});
2436

2537
expect(getParallaxOffsets(offset, percentMoved, true)).toEqual({
2638
x: {
27-
value: scaleBetween(percentMoved, offset.xMin.value, offset.xMax.value, 0, 100),
39+
value: scaleBetween(
40+
percentMoved,
41+
offset.xMin.value,
42+
offset.xMax.value,
43+
0,
44+
100
45+
),
2846
unit: offset.xMax.unit,
2947
},
3048
y: {
31-
value: scaleBetween(percentMoved, offset.yMin.value, offset.yMax.value, 0, 100),
49+
value: scaleBetween(
50+
percentMoved,
51+
offset.yMin.value,
52+
offset.yMax.value,
53+
0,
54+
100
55+
),
3256
unit: offset.yMax.unit,
3357
},
3458
});

__tests__/parseValueAndUnit.test.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import parseValueAndUnit from 'utils/parseValueAndUnit';
22

33
test('Parse a string to get the value and unit in either pixels or percent', () => {
4-
expect(parseValueAndUnit('5px'))
5-
.toEqual({ unit: 'px', value: 5 });
6-
expect(parseValueAndUnit('52%'))
7-
.toEqual({ unit: '%', value: 52 });
8-
expect(parseValueAndUnit(13.333))
9-
.toEqual({ unit: '%', value: 13.333 });
10-
expect(parseValueAndUnit('75.8%'))
11-
.toEqual({ unit: '%', value: 75 });
12-
expect(parseValueAndUnit('23.1px'))
13-
.toEqual({ unit: 'px', value: 23 });
14-
expect(() => parseValueAndUnit(false))
15-
.toThrow();
4+
expect(parseValueAndUnit('5px')).toEqual({ unit: 'px', value: 5 });
5+
expect(parseValueAndUnit('52%')).toEqual({ unit: '%', value: 52 });
6+
expect(parseValueAndUnit(13.333)).toEqual({ unit: '%', value: 13.333 });
7+
expect(parseValueAndUnit('75.8%')).toEqual({ unit: '%', value: 75 });
8+
expect(parseValueAndUnit('23.1px')).toEqual({ unit: 'px', value: 23 });
9+
expect(() => parseValueAndUnit(false)).toThrow();
1610
});

__tests__/scaleBetween.test.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ const newMin = 0;
77
const newMax = 100;
88

99
test('Scales a value from a given range to a new range', () => {
10-
expect(scaleBetween(0.4, newMin, newMax, oldMin, oldMax))
11-
.toBe(40);
12-
expect(scaleBetween(0.1, newMin, newMax, oldMin, oldMax))
13-
.toBe(10);
14-
expect(scaleBetween(0.3, newMin, newMax, oldMin, oldMax))
15-
.toBe(30);
16-
expect(scaleBetween(0.333, newMin, newMax, oldMin, oldMax))
17-
.toBeCloseTo(33.3);
10+
expect(scaleBetween(0.4, newMin, newMax, oldMin, oldMax)).toBe(40);
11+
expect(scaleBetween(0.1, newMin, newMax, oldMin, oldMax)).toBe(10);
12+
expect(scaleBetween(0.3, newMin, newMax, oldMin, oldMax)).toBe(30);
13+
expect(scaleBetween(0.333, newMin, newMax, oldMin, oldMax)).toBeCloseTo(
14+
33.3
15+
);
1816
});

examples/parallax-example/components/Intro/Intro.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,13 @@ import hemispheres from '!!raw-loader!./hemispheres.svg';
88
const Intro = () => (
99
<div className={style.root}>
1010
<div className={style.container}>
11-
<Parallax
12-
offsetYMin={-100}
13-
offsetYMax={100}
14-
className={style.ring}
15-
>
11+
<Parallax offsetYMin={-100} offsetYMax={100} className={style.ring}>
1612
<Svg svg={ring} />
1713
</Parallax>
18-
<Parallax
19-
offsetYMin={-50}
20-
offsetYMax={50}
21-
className={style.circle}
22-
>
23-
<div className={style.circleInner}/>
14+
<Parallax offsetYMin={-50} offsetYMax={50} className={style.circle}>
15+
<div className={style.circleInner} />
2416
</Parallax>
25-
<Svg
26-
className={style.hemispheres}
27-
svg={hemispheres}
28-
/>
17+
<Svg className={style.hemispheres} svg={hemispheres} />
2918
</div>
3019
<p className={style.scroll}>Scroll</p>
3120
</div>

examples/parallax-example/components/Marquee/Marquee.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ const Marquee = () => (
1010
<div className={style.root}>
1111
<Svg svg={divider} className={style.divider} />
1212
<div className={style.container}>
13-
<Svg
14-
svg={boxBg}
15-
className={style.boxBg}
16-
/>
13+
<Svg svg={boxBg} className={style.boxBg} />
1714
<Parallax
1815
className={style.text}
1916
offsetYMax={70}

examples/parallax-example/components/Overlap/Overlap.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ const Overlap = () => (
1515
offsetXMin={20}
1616
className={style.circle}
1717
>
18-
<Svg
19-
svg={circle}
20-
/>
18+
<Svg svg={circle} />
2119
</Parallax>
2220
<Parallax
2321
offsetYMax={150}
@@ -26,9 +24,7 @@ const Overlap = () => (
2624
offsetXMin={-20}
2725
className={style.circleRings}
2826
>
29-
<Svg
30-
svg={circleRings}
31-
/>
27+
<Svg svg={circleRings} />
3228
</Parallax>
3329
</div>
3430
</div>

examples/parallax-example/components/ParallaxExample/ParallaxExample.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component } from 'react';
22
import {
3-
Intro,
4-
IntroCopy,
3+
Intro,
4+
IntroCopy,
55
Marquee,
66
TriangleGrid,
77
Overlap,
@@ -15,7 +15,6 @@ import noisePattern from '!!raw-loader!../shared/noise-pattern.svg';
1515
import dotPattern from '!!raw-loader!../shared/dot-pattern.svg';
1616

1717
export default class ParallaxExample extends Component {
18-
1918
render() {
2019
return (
2120
<div className={style.root}>
@@ -34,5 +33,4 @@ export default class ParallaxExample extends Component {
3433
</div>
3534
);
3635
}
37-
3836
}

examples/parallax-example/components/ShapeField/ShapeField.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React, { Component } from 'react';
22
import { Parallax } from 'react-scroll-parallax';
3-
import {
4-
Svg,
5-
} from 'components';
3+
import { Svg } from 'components';
64

75
import style from './ShapeField.scss';
86

@@ -12,18 +10,19 @@ import cluster01Rect from '!!raw-loader!./cluster-01-rect.svg';
1210

1311
import cluster02Hemi from '!!raw-loader!./cluster-02-hemi.svg';
1412
import cluster02TriangleBig from '!!raw-loader!./cluster-02-triangle-big.svg';
15-
import cluster02TriangleSmall from '!!raw-loader!./cluster-02-triangle-small.svg';
13+
import cluster02TriangleSmall
14+
from '!!raw-loader!./cluster-02-triangle-small.svg';
1615

1716
import cluster03TriangleTop from '!!raw-loader!./cluster-03-triangle-top.svg';
18-
import cluster03TriangleBottom from '!!raw-loader!./cluster-03-triangle-bottom.svg';
17+
import cluster03TriangleBottom
18+
from '!!raw-loader!./cluster-03-triangle-bottom.svg';
1919
import cluster03TriangleBig from '!!raw-loader!./cluster-03-triangle-big.svg';
2020

2121
import cluster04Triangle from '!!raw-loader!./cluster-04-triangle.svg';
2222
import cluster04Square from '!!raw-loader!./cluster-04-square.svg';
2323
import cluster04HemiRight from '!!raw-loader!./cluster-04-hemi-right.svg';
2424

2525
export default class ShapeField extends Component {
26-
2726
render() {
2827
return (
2928
<div className={style.root}>
@@ -48,10 +47,7 @@ export default class ShapeField extends Component {
4847
</div>
4948

5049
<div className={style.shapeCluster02}>
51-
<Svg
52-
svg={cluster02Hemi}
53-
className="hemi"
54-
/>
50+
<Svg svg={cluster02Hemi} className="hemi" />
5551
<Parallax
5652
offsetYMax={30}
5753
offsetYMin={-30}
@@ -93,10 +89,7 @@ export default class ShapeField extends Component {
9389
</div>
9490

9591
<div className={style.shapeCluster04}>
96-
<Svg
97-
svg={cluster04Square}
98-
className="square"
99-
/>
92+
<Svg svg={cluster04Square} className="square" />
10093
<Parallax
10194
offsetYMax={60}
10295
offsetYMin={-60}
@@ -116,5 +109,4 @@ export default class ShapeField extends Component {
116109
</div>
117110
);
118111
}
119-
120112
}

examples/parallax-example/components/Svg/Svg.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import style from './Svg.scss';
44

55
export default function Svg(props) {
66
const Element = props.el;
7-
const className = `svg-container ${style.root}` + (props.className ? ` ${props.className}` : '');
7+
const className =
8+
`svg-container ${style.root}` +
9+
(props.className ? ` ${props.className}` : '');
810

911
return (
1012
<Element

examples/parallax-example/components/TriangleGrid/TriangleGrid.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,31 @@ import angleTop from '!!raw-loader!../shared/angle-dark-top.svg';
88

99
const TriangleGrid = () => (
1010
<div className={style.root}>
11-
<Svg
12-
svg={angleTop}
13-
className={style.angleTop}
14-
/>
11+
<Svg svg={angleTop} className={style.angleTop} />
1512
<article className={style.copy}>
1613
<p>
1714
<code>npm i react-scroll-parallax</code>
1815
</p>
1916
<p>
20-
<a className="btn" href="https://github.com/jscottsmith/react-scroll-parallax">View on GitHub</a>
17+
<a
18+
className="btn"
19+
href="https://github.com/jscottsmith/react-scroll-parallax"
20+
>
21+
View on GitHub
22+
</a>
2123
</p>
2224
</article>
2325
<div className={style.container}>
24-
<Parallax
25-
offsetYMax={25}
26-
offsetYMin={-25}
27-
>
28-
<Svg
29-
svg={gridPurple}
30-
className={style.trianglesPurple}
31-
/>
26+
<Parallax offsetYMax={25} offsetYMin={-25}>
27+
<Svg svg={gridPurple} className={style.trianglesPurple} />
3228
</Parallax>
3329
<Parallax
3430
offsetYMax={50}
3531
offsetYMin={-50}
3632
offsetXMax={13}
3733
offsetXMin={-13}
3834
>
39-
<Svg
40-
svg={gridWhite}
41-
className={style.trianglesWhite}
42-
/>
35+
<Svg svg={gridWhite} className={style.trianglesWhite} />
4336
</Parallax>
4437
</div>
4538
</div>

examples/parallax-example/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ const app = express();
1313
app.use('/static', express.static(path.resolve(__dirname, './dist')));
1414

1515
app.get('*', (req, res) => {
16-
const html = fs.readFileSync(path.resolve(__dirname, './index.html')).toString();
16+
const html = fs
17+
.readFileSync(path.resolve(__dirname, './index.html'))
18+
.toString();
1719
const markup = ReactServer.renderToString(<ParallaxExample />);
1820

1921
res.send(html.replace('$react', markup));

0 commit comments

Comments
 (0)