react-image-gallery 1.2.12 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +42 -19
- package/.github/workflows/eslint.yml +56 -0
- package/README.md +161 -158
- package/babel.config.js +3 -0
- package/build/image-gallery.js +1 -1
- package/jest.config.js +16 -0
- package/package.json +20 -16
- package/src/{ImageGallery.js → components/ImageGallery.jsx} +423 -360
- package/src/components/ImageGallery.test.jsx +22 -0
- package/src/{Item.js → components/Item.jsx} +18 -22
- package/src/{SVG.js → components/SVG.jsx} +12 -18
- package/src/{SwipeWrapper.js → components/SwipeWrapper.jsx} +8 -16
- package/src/{controls/Fullscreen.js → components/controls/Fullscreen.jsx} +6 -10
- package/src/{controls/LeftNav.js → components/controls/LeftNav.jsx} +5 -9
- package/src/{controls/PlayPause.js → components/controls/PlayPause.jsx} +6 -10
- package/src/{controls/RightNav.js → components/controls/RightNav.jsx} +5 -9
- package/webpack.build.js +61 -62
- package/webpack.config.js +18 -15
- package/.babelrc +0 -1
- package/.notes +0 -2
- package/tests/ImageGallery.test.js +0 -15
- package/tests/__snapshots__/ImageGallery.test.js.snap +0 -3
- package/tests/setupTestFramework.js +0 -4
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
|
|
4
|
+
import ImageGallery from "./ImageGallery";
|
|
5
|
+
|
|
6
|
+
describe("<ImageGallery />", () => {
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
items: [
|
|
9
|
+
{
|
|
10
|
+
original: "test.png",
|
|
11
|
+
thumbnail: "test_thumb.png",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
it("renders slides", () => {
|
|
17
|
+
render(<ImageGallery {...defaultProps} />);
|
|
18
|
+
const elements = screen.getAllByLabelText("Go to Slide 1");
|
|
19
|
+
// expect a thumbnail and slide label
|
|
20
|
+
expect(elements.length).toBe(2);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { bool, func, string } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { bool, func, string } from "prop-types";
|
|
3
3
|
|
|
4
4
|
const defaultProps = {
|
|
5
|
-
description:
|
|
6
|
-
fullscreen:
|
|
5
|
+
description: "",
|
|
6
|
+
fullscreen: "",
|
|
7
7
|
isFullscreen: false,
|
|
8
|
-
originalAlt:
|
|
9
|
-
originalHeight:
|
|
10
|
-
originalWidth:
|
|
11
|
-
originalTitle:
|
|
12
|
-
sizes:
|
|
13
|
-
srcSet:
|
|
14
|
-
loading:
|
|
8
|
+
originalAlt: "",
|
|
9
|
+
originalHeight: "",
|
|
10
|
+
originalWidth: "",
|
|
11
|
+
originalTitle: "",
|
|
12
|
+
sizes: "",
|
|
13
|
+
srcSet: "",
|
|
14
|
+
loading: "eager",
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const Item = React.memo((props) => {
|
|
@@ -29,8 +29,8 @@ const Item = React.memo((props) => {
|
|
|
29
29
|
sizes,
|
|
30
30
|
srcSet,
|
|
31
31
|
loading,
|
|
32
|
-
} = {...defaultProps, ...props};
|
|
33
|
-
const itemSrc = isFullscreen ?
|
|
32
|
+
} = { ...defaultProps, ...props };
|
|
33
|
+
const itemSrc = isFullscreen ? fullscreen || original : original;
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
36
|
<React.Fragment>
|
|
@@ -43,22 +43,18 @@ const Item = React.memo((props) => {
|
|
|
43
43
|
width={originalWidth}
|
|
44
44
|
sizes={sizes}
|
|
45
45
|
title={originalTitle}
|
|
46
|
-
onLoad={event => handleImageLoaded(event, original)}
|
|
46
|
+
onLoad={(event) => handleImageLoaded(event, original)}
|
|
47
47
|
onError={onImageError}
|
|
48
48
|
loading={loading}
|
|
49
49
|
/>
|
|
50
|
-
{
|
|
51
|
-
description
|
|
52
|
-
|
|
53
|
-
{description}
|
|
54
|
-
</span>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
50
|
+
{description && (
|
|
51
|
+
<span className="image-gallery-description">{description}</span>
|
|
52
|
+
)}
|
|
57
53
|
</React.Fragment>
|
|
58
54
|
);
|
|
59
55
|
});
|
|
60
56
|
|
|
61
|
-
Item.displayName =
|
|
57
|
+
Item.displayName = "Item";
|
|
62
58
|
|
|
63
59
|
Item.propTypes = {
|
|
64
60
|
description: string,
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { number, oneOf, string } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { number, oneOf, string } from "prop-types";
|
|
3
3
|
|
|
4
4
|
const left = <polyline points="15 18 9 12 15 6" />;
|
|
5
5
|
const right = <polyline points="9 18 15 12 9 6" />;
|
|
6
|
-
const maximize =
|
|
7
|
-
|
|
6
|
+
const maximize = (
|
|
7
|
+
<path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" />
|
|
8
|
+
);
|
|
9
|
+
const minimize = (
|
|
10
|
+
<path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3" />
|
|
11
|
+
);
|
|
8
12
|
const play = <polygon points="5 3 19 12 5 21 5 3" />;
|
|
9
13
|
const pause = (
|
|
10
14
|
<React.Fragment>
|
|
@@ -24,15 +28,11 @@ const iconMapper = {
|
|
|
24
28
|
|
|
25
29
|
const defaultProps = {
|
|
26
30
|
strokeWidth: 1,
|
|
27
|
-
viewBox:
|
|
31
|
+
viewBox: "0 0 24 24",
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
const SVG = (props) => {
|
|
31
|
-
const {
|
|
32
|
-
strokeWidth,
|
|
33
|
-
viewBox,
|
|
34
|
-
icon,
|
|
35
|
-
} = {...defaultProps, ...props};
|
|
35
|
+
const { strokeWidth, viewBox, icon } = { ...defaultProps, ...props };
|
|
36
36
|
return (
|
|
37
37
|
<svg
|
|
38
38
|
className="image-gallery-svg"
|
|
@@ -52,14 +52,8 @@ const SVG = (props) => {
|
|
|
52
52
|
SVG.propTypes = {
|
|
53
53
|
strokeWidth: number,
|
|
54
54
|
viewBox: string,
|
|
55
|
-
icon: oneOf([
|
|
56
|
-
|
|
57
|
-
'right',
|
|
58
|
-
'maximize',
|
|
59
|
-
'minimize',
|
|
60
|
-
'play',
|
|
61
|
-
'pause',
|
|
62
|
-
]).isRequired,
|
|
55
|
+
icon: oneOf(["left", "right", "maximize", "minimize", "play", "pause"])
|
|
56
|
+
.isRequired,
|
|
63
57
|
};
|
|
64
58
|
|
|
65
59
|
export default SVG;
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
node,
|
|
5
|
-
number,
|
|
6
|
-
func,
|
|
7
|
-
} from 'prop-types';
|
|
8
|
-
import { useSwipeable } from 'react-swipeable';
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { string, node, number, func } from "prop-types";
|
|
3
|
+
import { useSwipeable } from "react-swipeable";
|
|
9
4
|
|
|
10
5
|
const defaultProps = {
|
|
11
|
-
className:
|
|
6
|
+
className: "",
|
|
12
7
|
delta: 0,
|
|
13
8
|
onSwiping: () => {},
|
|
14
9
|
onSwiped: () => {},
|
|
15
10
|
};
|
|
16
11
|
|
|
17
12
|
const SwipeWrapper = (props) => {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
onSwiping,
|
|
23
|
-
onSwiped,
|
|
24
|
-
} = {...defaultProps, ...props};
|
|
13
|
+
const { children, className, delta, onSwiping, onSwiped } = {
|
|
14
|
+
...defaultProps,
|
|
15
|
+
...props,
|
|
16
|
+
};
|
|
25
17
|
const swipeHandlers = useSwipeable({
|
|
26
18
|
delta,
|
|
27
19
|
onSwiping,
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { bool, func } from
|
|
3
|
-
import SVG from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { bool, func } from "prop-types";
|
|
3
|
+
import SVG from "src/components/SVG";
|
|
4
4
|
|
|
5
|
-
const Fullscreen = React.memo(({
|
|
6
|
-
isFullscreen,
|
|
7
|
-
onClick,
|
|
8
|
-
}) => {
|
|
5
|
+
const Fullscreen = React.memo(({ isFullscreen, onClick }) => {
|
|
9
6
|
return (
|
|
10
7
|
<button
|
|
11
8
|
type="button"
|
|
@@ -13,17 +10,16 @@ const Fullscreen = React.memo(({
|
|
|
13
10
|
onClick={onClick}
|
|
14
11
|
aria-label="Open Fullscreen"
|
|
15
12
|
>
|
|
16
|
-
<SVG strokeWidth={2} icon={isFullscreen ?
|
|
13
|
+
<SVG strokeWidth={2} icon={isFullscreen ? "minimize" : "maximize"} />
|
|
17
14
|
</button>
|
|
18
15
|
);
|
|
19
16
|
});
|
|
20
17
|
|
|
21
|
-
Fullscreen.displayName =
|
|
18
|
+
Fullscreen.displayName = "Fullscreen";
|
|
22
19
|
|
|
23
20
|
Fullscreen.propTypes = {
|
|
24
21
|
isFullscreen: bool.isRequired,
|
|
25
22
|
onClick: func.isRequired,
|
|
26
23
|
};
|
|
27
24
|
|
|
28
|
-
|
|
29
25
|
export default Fullscreen;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { bool, func } from
|
|
3
|
-
import SVG from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { bool, func } from "prop-types";
|
|
3
|
+
import SVG from "src/components/SVG";
|
|
4
4
|
|
|
5
|
-
const LeftNav = React.memo(({
|
|
6
|
-
disabled,
|
|
7
|
-
onClick,
|
|
8
|
-
}) => {
|
|
5
|
+
const LeftNav = React.memo(({ disabled, onClick }) => {
|
|
9
6
|
return (
|
|
10
7
|
<button
|
|
11
8
|
type="button"
|
|
@@ -19,12 +16,11 @@ const LeftNav = React.memo(({
|
|
|
19
16
|
);
|
|
20
17
|
});
|
|
21
18
|
|
|
22
|
-
LeftNav.displayName =
|
|
19
|
+
LeftNav.displayName = "LeftNav";
|
|
23
20
|
|
|
24
21
|
LeftNav.propTypes = {
|
|
25
22
|
disabled: bool.isRequired,
|
|
26
23
|
onClick: func.isRequired,
|
|
27
24
|
};
|
|
28
25
|
|
|
29
|
-
|
|
30
26
|
export default LeftNav;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { bool, func } from
|
|
3
|
-
import SVG from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { bool, func } from "prop-types";
|
|
3
|
+
import SVG from "src/components/SVG";
|
|
4
4
|
|
|
5
|
-
const PlayPause = React.memo(({
|
|
6
|
-
isPlaying,
|
|
7
|
-
onClick,
|
|
8
|
-
}) => {
|
|
5
|
+
const PlayPause = React.memo(({ isPlaying, onClick }) => {
|
|
9
6
|
return (
|
|
10
7
|
<button
|
|
11
8
|
type="button"
|
|
@@ -13,17 +10,16 @@ const PlayPause = React.memo(({
|
|
|
13
10
|
onClick={onClick}
|
|
14
11
|
aria-label="Play or Pause Slideshow"
|
|
15
12
|
>
|
|
16
|
-
<SVG strokeWidth={2} icon={isPlaying ?
|
|
13
|
+
<SVG strokeWidth={2} icon={isPlaying ? "pause" : "play"} />
|
|
17
14
|
</button>
|
|
18
15
|
);
|
|
19
16
|
});
|
|
20
17
|
|
|
21
|
-
PlayPause.displayName =
|
|
18
|
+
PlayPause.displayName = "PlayPause";
|
|
22
19
|
|
|
23
20
|
PlayPause.propTypes = {
|
|
24
21
|
isPlaying: bool.isRequired,
|
|
25
22
|
onClick: func.isRequired,
|
|
26
23
|
};
|
|
27
24
|
|
|
28
|
-
|
|
29
25
|
export default PlayPause;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { bool, func } from
|
|
3
|
-
import SVG from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { bool, func } from "prop-types";
|
|
3
|
+
import SVG from "src/components/SVG";
|
|
4
4
|
|
|
5
|
-
const RightNav = React.memo(({
|
|
6
|
-
disabled,
|
|
7
|
-
onClick,
|
|
8
|
-
}) => {
|
|
5
|
+
const RightNav = React.memo(({ disabled, onClick }) => {
|
|
9
6
|
return (
|
|
10
7
|
<button
|
|
11
8
|
type="button"
|
|
@@ -19,12 +16,11 @@ const RightNav = React.memo(({
|
|
|
19
16
|
);
|
|
20
17
|
});
|
|
21
18
|
|
|
22
|
-
RightNav.displayName =
|
|
19
|
+
RightNav.displayName = "RightNav";
|
|
23
20
|
|
|
24
21
|
RightNav.propTypes = {
|
|
25
22
|
disabled: bool.isRequired,
|
|
26
23
|
onClick: func.isRequired,
|
|
27
24
|
};
|
|
28
25
|
|
|
29
|
-
|
|
30
26
|
export default RightNav;
|
package/webpack.build.js
CHANGED
|
@@ -1,57 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const RemovePlugin = require('remove-files-webpack-plugin');
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
3
|
+
const RemovePlugin = require("remove-files-webpack-plugin");
|
|
5
4
|
|
|
6
5
|
const config = {
|
|
7
|
-
mode:
|
|
6
|
+
mode: "production",
|
|
8
7
|
};
|
|
9
8
|
|
|
10
9
|
const jsOutput = Object.assign({}, config, {
|
|
11
|
-
entry: [
|
|
10
|
+
entry: ["./src/components/ImageGallery.jsx"],
|
|
12
11
|
output: {
|
|
13
|
-
path: path.resolve(__dirname,
|
|
14
|
-
filename:
|
|
15
|
-
library:
|
|
16
|
-
globalObject:
|
|
17
|
-
libraryTarget:
|
|
12
|
+
path: path.resolve(__dirname, "build"),
|
|
13
|
+
filename: "image-gallery.js",
|
|
14
|
+
library: "ImageGallery",
|
|
15
|
+
globalObject: "this",
|
|
16
|
+
libraryTarget: "umd",
|
|
18
17
|
},
|
|
19
18
|
resolve: {
|
|
20
19
|
alias: {
|
|
21
|
-
src: path.resolve(__dirname,
|
|
20
|
+
src: path.resolve(__dirname, "src/"),
|
|
22
21
|
},
|
|
23
|
-
extensions: [
|
|
22
|
+
extensions: [".js", ".jsx"],
|
|
24
23
|
},
|
|
25
24
|
module: {
|
|
26
25
|
rules: [
|
|
27
26
|
{
|
|
28
|
-
test: /\.js$/,
|
|
27
|
+
test: /\.(js|jsx)$/,
|
|
29
28
|
exclude: /node_modules/,
|
|
30
|
-
loader:
|
|
31
|
-
}
|
|
32
|
-
]
|
|
29
|
+
loader: "babel-loader",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
33
32
|
},
|
|
34
33
|
externals: {
|
|
35
34
|
// Don't bundle react or react-dom
|
|
36
35
|
react: {
|
|
37
|
-
commonjs:
|
|
38
|
-
commonjs2:
|
|
39
|
-
amd:
|
|
40
|
-
root:
|
|
36
|
+
commonjs: "react",
|
|
37
|
+
commonjs2: "react",
|
|
38
|
+
amd: "react",
|
|
39
|
+
root: "React",
|
|
41
40
|
},
|
|
42
|
-
|
|
43
|
-
commonjs:
|
|
44
|
-
commonjs2:
|
|
45
|
-
amd:
|
|
46
|
-
root:
|
|
41
|
+
"react-dom": {
|
|
42
|
+
commonjs: "react-dom",
|
|
43
|
+
commonjs2: "react-dom",
|
|
44
|
+
amd: "react-dom",
|
|
45
|
+
root: "ReactDOM",
|
|
47
46
|
},
|
|
48
47
|
},
|
|
49
48
|
});
|
|
50
49
|
|
|
51
50
|
const cssOutput = Object.assign({}, config, {
|
|
52
|
-
entry:
|
|
51
|
+
entry: "./styles/scss/image-gallery.scss",
|
|
53
52
|
output: {
|
|
54
|
-
path: path.resolve(__dirname,
|
|
53
|
+
path: path.resolve(__dirname, "styles/css"),
|
|
55
54
|
},
|
|
56
55
|
module: {
|
|
57
56
|
rules: [
|
|
@@ -60,16 +59,16 @@ const cssOutput = Object.assign({}, config, {
|
|
|
60
59
|
use: [
|
|
61
60
|
MiniCssExtractPlugin.loader,
|
|
62
61
|
// Translates CSS into CommonJS
|
|
63
|
-
|
|
62
|
+
"css-loader",
|
|
64
63
|
// Compiles Sass to CSS
|
|
65
|
-
|
|
64
|
+
"sass-loader",
|
|
66
65
|
],
|
|
67
|
-
}
|
|
68
|
-
]
|
|
66
|
+
},
|
|
67
|
+
],
|
|
69
68
|
},
|
|
70
69
|
plugins: [
|
|
71
70
|
new MiniCssExtractPlugin({
|
|
72
|
-
filename:
|
|
71
|
+
filename: "image-gallery.css",
|
|
73
72
|
}),
|
|
74
73
|
new RemovePlugin({
|
|
75
74
|
/**
|
|
@@ -78,36 +77,36 @@ const cssOutput = Object.assign({}, config, {
|
|
|
78
77
|
after: {
|
|
79
78
|
test: [
|
|
80
79
|
{
|
|
81
|
-
folder:
|
|
80
|
+
folder: "styles/css",
|
|
82
81
|
method: (absoluteItemPath) => {
|
|
83
|
-
return new RegExp(/\.js$/,
|
|
82
|
+
return new RegExp(/\.js$/, "m").test(absoluteItemPath);
|
|
84
83
|
},
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
}
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
88
87
|
}),
|
|
89
88
|
],
|
|
90
89
|
});
|
|
91
90
|
|
|
92
91
|
const jsDemoOutput = Object.assign({}, config, {
|
|
93
|
-
entry: [
|
|
92
|
+
entry: ["./example/App.jsx"],
|
|
94
93
|
output: {
|
|
95
|
-
path: path.resolve(__dirname,
|
|
96
|
-
filename:
|
|
94
|
+
path: path.resolve(__dirname, "demo"),
|
|
95
|
+
filename: "demo.mini.js",
|
|
97
96
|
},
|
|
98
97
|
resolve: {
|
|
99
98
|
alias: {
|
|
100
|
-
src: path.resolve(__dirname,
|
|
99
|
+
src: path.resolve(__dirname, "src/"),
|
|
101
100
|
},
|
|
102
|
-
extensions: [
|
|
101
|
+
extensions: [".js", ".jsx"],
|
|
103
102
|
},
|
|
104
103
|
module: {
|
|
105
104
|
rules: [
|
|
106
105
|
{
|
|
107
|
-
test: /\.js$/,
|
|
108
|
-
loader:
|
|
109
|
-
}
|
|
110
|
-
]
|
|
106
|
+
test: /\.(js|jsx)$/,
|
|
107
|
+
loader: "babel-loader",
|
|
108
|
+
},
|
|
109
|
+
],
|
|
111
110
|
},
|
|
112
111
|
plugins: [
|
|
113
112
|
new RemovePlugin({
|
|
@@ -117,21 +116,21 @@ const jsDemoOutput = Object.assign({}, config, {
|
|
|
117
116
|
after: {
|
|
118
117
|
test: [
|
|
119
118
|
{
|
|
120
|
-
folder:
|
|
119
|
+
folder: "demo",
|
|
121
120
|
method: (absoluteItemPath) => {
|
|
122
121
|
return new RegExp(/\.txt$/).test(absoluteItemPath);
|
|
123
122
|
},
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
}
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
127
126
|
}),
|
|
128
127
|
],
|
|
129
128
|
});
|
|
130
129
|
|
|
131
130
|
const cssDemoOutput = Object.assign({}, config, {
|
|
132
|
-
entry: [
|
|
131
|
+
entry: ["./styles/scss/image-gallery.scss", "./example/App.css"],
|
|
133
132
|
output: {
|
|
134
|
-
path: path.resolve(__dirname,
|
|
133
|
+
path: path.resolve(__dirname, "demo"),
|
|
135
134
|
},
|
|
136
135
|
module: {
|
|
137
136
|
rules: [
|
|
@@ -140,16 +139,16 @@ const cssDemoOutput = Object.assign({}, config, {
|
|
|
140
139
|
use: [
|
|
141
140
|
MiniCssExtractPlugin.loader,
|
|
142
141
|
// Translates CSS into CommonJS
|
|
143
|
-
|
|
142
|
+
"css-loader",
|
|
144
143
|
// Compiles Sass to CSS
|
|
145
|
-
|
|
144
|
+
"sass-loader",
|
|
146
145
|
],
|
|
147
|
-
}
|
|
148
|
-
]
|
|
146
|
+
},
|
|
147
|
+
],
|
|
149
148
|
},
|
|
150
149
|
plugins: [
|
|
151
150
|
new MiniCssExtractPlugin({
|
|
152
|
-
filename:
|
|
151
|
+
filename: "demo.mini.css",
|
|
153
152
|
}),
|
|
154
153
|
new RemovePlugin({
|
|
155
154
|
/**
|
|
@@ -158,13 +157,13 @@ const cssDemoOutput = Object.assign({}, config, {
|
|
|
158
157
|
after: {
|
|
159
158
|
test: [
|
|
160
159
|
{
|
|
161
|
-
folder:
|
|
160
|
+
folder: "demo",
|
|
162
161
|
method: (absoluteItemPath) => {
|
|
163
162
|
return new RegExp(/\.js$/).test(absoluteItemPath);
|
|
164
163
|
},
|
|
165
|
-
}
|
|
166
|
-
]
|
|
167
|
-
}
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
},
|
|
168
167
|
}),
|
|
169
168
|
],
|
|
170
169
|
});
|
package/webpack.config.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
4
3
|
|
|
5
4
|
module.exports = {
|
|
6
|
-
entry: [
|
|
5
|
+
entry: [
|
|
6
|
+
"./example/App.jsx",
|
|
7
|
+
"./example/App.css",
|
|
8
|
+
"./styles/scss/image-gallery.scss",
|
|
9
|
+
],
|
|
7
10
|
output: {
|
|
8
|
-
path: path.resolve(__dirname,
|
|
9
|
-
filename:
|
|
10
|
-
publicPath:
|
|
11
|
+
path: path.resolve(__dirname, "example"),
|
|
12
|
+
filename: "example.js",
|
|
13
|
+
publicPath: "/dist/",
|
|
11
14
|
},
|
|
12
15
|
resolve: {
|
|
13
|
-
extensions: [
|
|
16
|
+
extensions: [".js", ".jsx"],
|
|
14
17
|
alias: {
|
|
15
|
-
src: path.resolve(__dirname,
|
|
18
|
+
src: path.resolve(__dirname, "src/"),
|
|
16
19
|
},
|
|
17
20
|
},
|
|
18
21
|
module: {
|
|
19
22
|
rules: [
|
|
20
23
|
{
|
|
21
24
|
test: /\.(js|jsx)$/,
|
|
22
|
-
loader:
|
|
25
|
+
loader: "babel-loader",
|
|
23
26
|
},
|
|
24
27
|
{
|
|
25
28
|
test: /\.(css|scss)$/i,
|
|
@@ -31,19 +34,19 @@ module.exports = {
|
|
|
31
34
|
// Compiles Sass to CSS
|
|
32
35
|
"sass-loader",
|
|
33
36
|
],
|
|
34
|
-
}
|
|
35
|
-
]
|
|
37
|
+
},
|
|
38
|
+
],
|
|
36
39
|
},
|
|
37
40
|
plugins: [
|
|
38
41
|
new MiniCssExtractPlugin({
|
|
39
|
-
filename:
|
|
42
|
+
filename: "image-gallery.css",
|
|
40
43
|
}),
|
|
41
44
|
],
|
|
42
45
|
devServer: {
|
|
43
|
-
host:
|
|
46
|
+
host: "0.0.0.0",
|
|
44
47
|
port: 8001,
|
|
45
48
|
historyApiFallback: {
|
|
46
|
-
rewrites: [{ from: /\//, to:
|
|
49
|
+
rewrites: [{ from: /\//, to: "/example/index.html" }],
|
|
47
50
|
},
|
|
48
51
|
},
|
|
49
52
|
};
|
package/.babelrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "presets": ["@babel/preset-env", "@babel/preset-react"] }
|
package/.notes
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
|
|
4
|
-
import ImageGallery from '../src/ImageGallery';
|
|
5
|
-
|
|
6
|
-
describe('<ImageGallery />', () => {
|
|
7
|
-
const defaultProps = {
|
|
8
|
-
items: [],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
it('matches snapshot', () => {
|
|
12
|
-
const component = shallow(<ImageGallery {...defaultProps} />);
|
|
13
|
-
expect(component).toMatchSnapshot();
|
|
14
|
-
});
|
|
15
|
-
});
|