react-diff-viewer-continued 3.2.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.
@@ -0,0 +1,77 @@
1
+ import { Interpolation } from 'emotion';
2
+ export interface ReactDiffViewerStyles {
3
+ diffContainer?: string;
4
+ diffRemoved?: string;
5
+ diffAdded?: string;
6
+ line?: string;
7
+ highlightedGutter?: string;
8
+ contentText?: string;
9
+ gutter?: string;
10
+ highlightedLine?: string;
11
+ lineNumber?: string;
12
+ marker?: string;
13
+ wordDiff?: string;
14
+ wordAdded?: string;
15
+ wordRemoved?: string;
16
+ codeFoldGutter?: string;
17
+ emptyGutter?: string;
18
+ emptyLine?: string;
19
+ codeFold?: string;
20
+ titleBlock?: string;
21
+ content?: string;
22
+ splitView?: string;
23
+ [key: string]: string | undefined;
24
+ }
25
+ export interface ReactDiffViewerStylesVariables {
26
+ diffViewerBackground?: string;
27
+ diffViewerTitleBackground?: string;
28
+ diffViewerColor?: string;
29
+ diffViewerTitleColor?: string;
30
+ diffViewerTitleBorderColor?: string;
31
+ addedBackground?: string;
32
+ addedColor?: string;
33
+ removedBackground?: string;
34
+ removedColor?: string;
35
+ wordAddedBackground?: string;
36
+ wordRemovedBackground?: string;
37
+ addedGutterBackground?: string;
38
+ removedGutterBackground?: string;
39
+ gutterBackground?: string;
40
+ gutterBackgroundDark?: string;
41
+ highlightBackground?: string;
42
+ highlightGutterBackground?: string;
43
+ codeFoldGutterBackground?: string;
44
+ codeFoldBackground?: string;
45
+ emptyLineBackground?: string;
46
+ gutterColor?: string;
47
+ addedGutterColor?: string;
48
+ removedGutterColor?: string;
49
+ codeFoldContentColor?: string;
50
+ }
51
+ export interface ReactDiffViewerStylesOverride {
52
+ variables?: {
53
+ dark?: ReactDiffViewerStylesVariables;
54
+ light?: ReactDiffViewerStylesVariables;
55
+ };
56
+ diffContainer?: Interpolation;
57
+ diffRemoved?: Interpolation;
58
+ diffAdded?: Interpolation;
59
+ marker?: Interpolation;
60
+ emptyGutter?: Interpolation;
61
+ highlightedLine?: Interpolation;
62
+ lineNumber?: Interpolation;
63
+ highlightedGutter?: Interpolation;
64
+ contentText?: Interpolation;
65
+ gutter?: Interpolation;
66
+ line?: Interpolation;
67
+ wordDiff?: Interpolation;
68
+ wordAdded?: Interpolation;
69
+ wordRemoved?: Interpolation;
70
+ codeFoldGutter?: Interpolation;
71
+ emptyLine?: Interpolation;
72
+ content?: Interpolation;
73
+ titleBlock?: Interpolation;
74
+ splitView?: Interpolation;
75
+ }
76
+ declare const _default: (styleOverride: ReactDiffViewerStylesOverride, useDarkTheme?: boolean) => ReactDiffViewerStyles;
77
+ export default _default;
package/lib/styles.js ADDED
@@ -0,0 +1,276 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const emotion_1 = require("emotion");
15
+ // eslint-disable-next-line import/no-anonymous-default-export
16
+ exports.default = (styleOverride, useDarkTheme = false) => {
17
+ const { variables: overrideVariables = {} } = styleOverride, styles = __rest(styleOverride, ["variables"]);
18
+ const themeVariables = {
19
+ light: Object.assign({
20
+ diffViewerBackground: '#fff',
21
+ diffViewerColor: '#212529',
22
+ addedBackground: '#e6ffed',
23
+ addedColor: '#24292e',
24
+ removedBackground: '#ffeef0',
25
+ removedColor: '#24292e',
26
+ wordAddedBackground: '#acf2bd',
27
+ wordRemovedBackground: '#fdb8c0',
28
+ addedGutterBackground: '#cdffd8',
29
+ removedGutterBackground: '#ffdce0',
30
+ gutterBackground: '#f7f7f7',
31
+ gutterBackgroundDark: '#f3f1f1',
32
+ highlightBackground: '#fffbdd',
33
+ highlightGutterBackground: '#fff5b1',
34
+ codeFoldGutterBackground: '#dbedff',
35
+ codeFoldBackground: '#f1f8ff',
36
+ emptyLineBackground: '#fafbfc',
37
+ gutterColor: '#212529',
38
+ addedGutterColor: '#212529',
39
+ removedGutterColor: '#212529',
40
+ codeFoldContentColor: '#212529',
41
+ diffViewerTitleBackground: '#fafbfc',
42
+ diffViewerTitleColor: '#212529',
43
+ diffViewerTitleBorderColor: '#eee',
44
+ }, (overrideVariables.light || {})),
45
+ dark: Object.assign({
46
+ diffViewerBackground: '#2e303c',
47
+ diffViewerColor: '#FFF',
48
+ addedBackground: '#044B53',
49
+ addedColor: 'white',
50
+ removedBackground: '#632F34',
51
+ removedColor: 'white',
52
+ wordAddedBackground: '#055d67',
53
+ wordRemovedBackground: '#7d383f',
54
+ addedGutterBackground: '#034148',
55
+ removedGutterBackground: '#632b30',
56
+ gutterBackground: '#2c2f3a',
57
+ gutterBackgroundDark: '#262933',
58
+ highlightBackground: '#2a3967',
59
+ highlightGutterBackground: '#2d4077',
60
+ codeFoldGutterBackground: '#21232b',
61
+ codeFoldBackground: '#262831',
62
+ emptyLineBackground: '#363946',
63
+ gutterColor: '#666c87',
64
+ addedGutterColor: '#8c8c8c',
65
+ removedGutterColor: '#8c8c8c',
66
+ codeFoldContentColor: '#656a8b',
67
+ diffViewerTitleBackground: '#2f323e',
68
+ diffViewerTitleColor: '#555a7b',
69
+ diffViewerTitleBorderColor: '#353846',
70
+ }, (overrideVariables.dark || {})),
71
+ };
72
+ const variables = useDarkTheme ? themeVariables.dark : themeVariables.light;
73
+ const content = (0, emotion_1.css)({
74
+ width: '100%',
75
+ label: 'content',
76
+ });
77
+ const splitView = (0, emotion_1.css)({
78
+ [`.${content}`]: {
79
+ width: '50%',
80
+ },
81
+ label: 'split-view',
82
+ });
83
+ const diffContainer = (0, emotion_1.css)({
84
+ width: '100%',
85
+ background: variables.diffViewerBackground,
86
+ pre: {
87
+ margin: 0,
88
+ whiteSpace: 'pre-wrap',
89
+ lineHeight: '25px',
90
+ },
91
+ label: 'diff-container',
92
+ borderCollapse: 'collapse',
93
+ });
94
+ const codeFoldContent = (0, emotion_1.css)({
95
+ color: variables.codeFoldContentColor,
96
+ label: 'code-fold-content',
97
+ });
98
+ const contentText = (0, emotion_1.css)({
99
+ color: variables.diffViewerColor,
100
+ label: 'content-text',
101
+ });
102
+ const titleBlock = (0, emotion_1.css)({
103
+ background: variables.diffViewerTitleBackground,
104
+ padding: 10,
105
+ borderBottom: `1px solid ${variables.diffViewerTitleBorderColor}`,
106
+ label: 'title-block',
107
+ ':last-child': {
108
+ borderLeft: `1px solid ${variables.diffViewerTitleBorderColor}`,
109
+ },
110
+ [`.${contentText}`]: {
111
+ color: variables.diffViewerTitleColor,
112
+ },
113
+ });
114
+ const lineNumber = (0, emotion_1.css)({
115
+ color: variables.gutterColor,
116
+ label: 'line-number',
117
+ });
118
+ const diffRemoved = (0, emotion_1.css)({
119
+ background: variables.removedBackground,
120
+ color: variables.removedColor,
121
+ pre: {
122
+ color: variables.removedColor,
123
+ },
124
+ [`.${lineNumber}`]: {
125
+ color: variables.removedGutterColor,
126
+ },
127
+ label: 'diff-removed',
128
+ });
129
+ const diffAdded = (0, emotion_1.css)({
130
+ background: variables.addedBackground,
131
+ color: variables.addedColor,
132
+ pre: {
133
+ color: variables.addedColor,
134
+ },
135
+ [`.${lineNumber}`]: {
136
+ color: variables.addedGutterColor,
137
+ },
138
+ label: 'diff-added',
139
+ });
140
+ const wordDiff = (0, emotion_1.css)({
141
+ padding: 2,
142
+ display: 'inline-flex',
143
+ borderRadius: 1,
144
+ label: 'word-diff',
145
+ });
146
+ const wordAdded = (0, emotion_1.css)({
147
+ background: variables.wordAddedBackground,
148
+ label: 'word-added',
149
+ });
150
+ const wordRemoved = (0, emotion_1.css)({
151
+ background: variables.wordRemovedBackground,
152
+ label: 'word-removed',
153
+ });
154
+ const codeFoldGutter = (0, emotion_1.css)({
155
+ backgroundColor: variables.codeFoldGutterBackground,
156
+ label: 'code-fold-gutter',
157
+ });
158
+ const codeFold = (0, emotion_1.css)({
159
+ backgroundColor: variables.codeFoldBackground,
160
+ height: 40,
161
+ fontSize: 14,
162
+ fontWeight: 700,
163
+ label: 'code-fold',
164
+ a: {
165
+ textDecoration: 'underline !important',
166
+ cursor: 'pointer',
167
+ pre: {
168
+ display: 'inline',
169
+ },
170
+ },
171
+ });
172
+ const emptyLine = (0, emotion_1.css)({
173
+ backgroundColor: variables.emptyLineBackground,
174
+ label: 'empty-line',
175
+ });
176
+ const marker = (0, emotion_1.css)({
177
+ width: 25,
178
+ paddingLeft: 10,
179
+ paddingRight: 10,
180
+ userSelect: 'none',
181
+ label: 'marker',
182
+ [`&.${diffAdded}`]: {
183
+ pre: {
184
+ color: variables.addedColor,
185
+ },
186
+ },
187
+ [`&.${diffRemoved}`]: {
188
+ pre: {
189
+ color: variables.removedColor,
190
+ },
191
+ },
192
+ });
193
+ const highlightedLine = (0, emotion_1.css)({
194
+ background: variables.highlightBackground,
195
+ label: 'highlighted-line',
196
+ [`.${wordAdded}, .${wordRemoved}`]: {
197
+ backgroundColor: 'initial',
198
+ },
199
+ });
200
+ const highlightedGutter = (0, emotion_1.css)({
201
+ label: 'highlighted-gutter',
202
+ });
203
+ const gutter = (0, emotion_1.css)({
204
+ userSelect: 'none',
205
+ minWidth: 50,
206
+ padding: '0 10px',
207
+ whiteSpace: 'nowrap',
208
+ label: 'gutter',
209
+ textAlign: 'right',
210
+ background: variables.gutterBackground,
211
+ '&:hover': {
212
+ cursor: 'pointer',
213
+ background: variables.gutterBackgroundDark,
214
+ pre: {
215
+ opacity: 1,
216
+ },
217
+ },
218
+ pre: {
219
+ opacity: 0.5,
220
+ },
221
+ [`&.${diffAdded}`]: {
222
+ background: variables.addedGutterBackground,
223
+ },
224
+ [`&.${diffRemoved}`]: {
225
+ background: variables.removedGutterBackground,
226
+ },
227
+ [`&.${highlightedGutter}`]: {
228
+ background: variables.highlightGutterBackground,
229
+ '&:hover': {
230
+ background: variables.highlightGutterBackground,
231
+ },
232
+ },
233
+ });
234
+ const emptyGutter = (0, emotion_1.css)({
235
+ '&:hover': {
236
+ background: variables.gutterBackground,
237
+ cursor: 'initial',
238
+ },
239
+ label: 'empty-gutter',
240
+ });
241
+ const line = (0, emotion_1.css)({
242
+ verticalAlign: 'baseline',
243
+ label: 'line',
244
+ });
245
+ const defaultStyles = {
246
+ diffContainer,
247
+ diffRemoved,
248
+ diffAdded,
249
+ splitView,
250
+ marker,
251
+ highlightedGutter,
252
+ highlightedLine,
253
+ gutter,
254
+ line,
255
+ wordDiff,
256
+ wordAdded,
257
+ wordRemoved,
258
+ codeFoldGutter,
259
+ codeFold,
260
+ emptyGutter,
261
+ emptyLine,
262
+ lineNumber,
263
+ contentText,
264
+ content,
265
+ codeFoldContent,
266
+ titleBlock,
267
+ };
268
+ const computerOverrideStyles = Object.keys(styles).reduce((acc, key) => (Object.assign(Object.assign({}, acc), {
269
+ [key]: (0, emotion_1.css)(styles[key]),
270
+ })), {});
271
+ return Object.keys(defaultStyles).reduce((acc, key) => (Object.assign(Object.assign({}, acc), {
272
+ [key]: computerOverrideStyles[key]
273
+ ? (0, emotion_1.cx)(defaultStyles[key], computerOverrideStyles[key])
274
+ : defaultStyles[key],
275
+ })), {});
276
+ };
Binary file
package/logo.png ADDED
Binary file
package/logo.png~ ADDED
Binary file
package/logo_dark.png ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "react-diff-viewer-continued",
3
+ "version": "3.2.0",
4
+ "private": false,
5
+ "description": "Continuation of a simple and beautiful text diff viewer component made with diff and React",
6
+ "keywords": [
7
+ "review",
8
+ "code-review",
9
+ "diff",
10
+ "diff-viewer",
11
+ "github",
12
+ "react",
13
+ "react-component",
14
+ "ui"
15
+ ],
16
+ "repository": "git@github.com:aeolun/react-diff-viewer-continued.git",
17
+ "license": "MIT",
18
+ "authors": [
19
+ "Pranesh Ravi<praneshpranesh@gmail.com>",
20
+ "Bart Riepe <bart@serial-experiments.com>"
21
+ ],
22
+ "main": "lib/index",
23
+ "typings": "lib/index",
24
+ "scripts": {
25
+ "build": "tsc --outDir lib/",
26
+ "build:examples": "webpack --progress",
27
+ "build:watch": "tsc --outDir lib/ -w",
28
+ "publish:examples": "NODE_ENV=production pnpm run build:examples && gh-pages -d examples/dist -r $GITHUB_REPO_URL",
29
+ "publish:examples:local": "NODE_ENV=production pnpm run build:examples && gh-pages -d examples/dist",
30
+ "start:examples": "webpack-dev-server --open --hot",
31
+ "test": "jest ./test/**",
32
+ "test:watch": "jest",
33
+ "lint": "eslint src/ test/",
34
+ "lint:fix": "eslint --fix src/ test/",
35
+ "prettier": "prettier --write ."
36
+ },
37
+ "dependencies": {
38
+ "@babel/core": "^7.18.6",
39
+ "@babel/preset-env": "^7.18.6",
40
+ "@babel/preset-react": "^7.18.6",
41
+ "@babel/preset-typescript": "^7.18.6",
42
+ "classnames": "^2.3.1",
43
+ "diff": "^5.1.0",
44
+ "emotion": "^10.0.27",
45
+ "jest": "^28.1.2",
46
+ "jest-environment-jsdom": "^28.1.2",
47
+ "memoize-one": "^6.0.0",
48
+ "prettier": "^2.7.1",
49
+ "prop-types": "^15.8.1",
50
+ "sass": "^1.53.0"
51
+ },
52
+ "devDependencies": {
53
+ "@semantic-release/changelog": "6.0.1",
54
+ "@semantic-release/git": "10.0.1",
55
+ "@testing-library/react": "^12.1.5",
56
+ "@types/diff": "^5.0.2",
57
+ "@types/expect": "^1.20.3",
58
+ "@types/memoize-one": "^4.1.1",
59
+ "@types/mocha": "^5.2.5",
60
+ "@types/node": "^12.0.12",
61
+ "@types/prop-types": "15.7.5",
62
+ "@types/react": "^16.4.14",
63
+ "@types/react-dom": "^16.0.8",
64
+ "@types/webpack": "^4.4.13",
65
+ "@typescript-eslint/eslint-plugin": "^5.30.5",
66
+ "@typescript-eslint/parser": "^5.30.5",
67
+ "css-loader": "^6.7.1",
68
+ "eslint": "^8.19.0",
69
+ "eslint-config-airbnb": "^19.0.4",
70
+ "eslint-plugin-import": "^2.26.0",
71
+ "eslint-plugin-jsx-a11y": "^6.6.0",
72
+ "eslint-plugin-react": "^7.30.1",
73
+ "eslint-plugin-react-hooks": "^4.6.0",
74
+ "expect": "^28.1.1",
75
+ "file-loader": "^6.2.0",
76
+ "gh-pages": "^4.0.0",
77
+ "html-webpack-plugin": "^5.5.0",
78
+ "mini-css-extract-plugin": "^2.6.1",
79
+ "mocha": "^10.0.0",
80
+ "raw-loader": "^4.0.2",
81
+ "react": "^17.0.2",
82
+ "react-dom": "^17.0.2",
83
+ "sass-loader": "^13.0.2",
84
+ "semantic-release": "^19.0.3",
85
+ "spy": "^1.0.0",
86
+ "ts-loader": "^9.3.1",
87
+ "ts-node": "^10.8.2",
88
+ "typescript": "^4.7.4",
89
+ "webpack": "^5.73.0",
90
+ "webpack-cli": "^4.10.0",
91
+ "webpack-dev-server": "^4.9.3"
92
+ },
93
+ "peerDependencies": {
94
+ "react": "^15.3.0 || ^16.0.0 || ^17.0.0",
95
+ "react-dom": "^15.3.0 || ^16.0.0 || ^17.0.0"
96
+ },
97
+ "engines": {
98
+ "node": ">= 8"
99
+ }
100
+ }
@@ -0,0 +1,10 @@
1
+ #!/bin/sh
2
+
3
+ if [ -n "$TRAVIS_TAG" ]; then
4
+ echo "Publishing examples to Github pages...."
5
+ git config --global user.email "travis@travis-ci.org"
6
+ git config --global user.name "Travis CI"
7
+ yarn publish:examples
8
+ else
9
+ echo "Skipping examples deployment..."
10
+ fi
@@ -0,0 +1,18 @@
1
+ module.exports = {
2
+ branches: ["master"],
3
+ plugins: [
4
+ "@semantic-release/commit-analyzer",
5
+ "@semantic-release/release-notes-generator",
6
+ "@semantic-release/npm",
7
+ "@semantic-release/changelog",
8
+ "@semantic-release/github",
9
+ "@semantic-release/npm",
10
+ [
11
+ "@semantic-release/git",
12
+ {
13
+ message: "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
14
+ assets: ["CHANGELOG.md", "package.json", "package-lock.json", "pnpm-lock.yaml", "npm-shrinkwrap.json"],
15
+ },
16
+ ],
17
+ ],
18
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "experimentalDecorators": true,
4
+ "jsx": "react",
5
+ "module": "es6",
6
+ "moduleResolution": "node",
7
+ "allowSyntheticDefaultImports": true,
8
+ "noImplicitAny": true,
9
+ "target": "es5",
10
+ "downlevelIteration": true,
11
+ "lib": ["es2017", "dom"]
12
+ },
13
+ "exclude": ["node_modules"]
14
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "experimentalDecorators": true,
4
+ "jsx": "react",
5
+ "module": "commonjs",
6
+ "moduleResolution": "node",
7
+ "noImplicitAny": true,
8
+ "target": "es2015",
9
+ "declaration": true,
10
+ "downlevelIteration": true,
11
+ "lib": ["es2017", "dom"],
12
+ "types": ["jest", "node"]
13
+ },
14
+ "include": ["./src/*"],
15
+ "exclude": ["node_modules"]
16
+ }
@@ -0,0 +1,60 @@
1
+ const path = require('path');
2
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
3
+ const Css = require('mini-css-extract-plugin');
4
+
5
+ module.exports = {
6
+ entry: {
7
+ main: './examples/src/index.tsx',
8
+ },
9
+ mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
10
+ resolve: {
11
+ extensions: ['.jsx', '.tsx', '.ts', '.scss', '.css', '.js'],
12
+ },
13
+ output: {
14
+ path: path.resolve(__dirname, 'examples/dist'),
15
+ filename: '[name].js',
16
+ },
17
+ devServer: {
18
+ static: {
19
+ directory: path.resolve(__dirname, 'examples/dist'),
20
+ },
21
+ port: 8000,
22
+ hot: true,
23
+ },
24
+ module: {
25
+ rules: [
26
+ {
27
+ test: /\.tsx?$/,
28
+ use: [
29
+ {
30
+ loader: 'ts-loader',
31
+ options: {
32
+ configFile: 'tsconfig.examples.json',
33
+ },
34
+ },
35
+ ],
36
+ exclude: /node_modules/,
37
+ },
38
+ {
39
+ test: /\.s?css$/,
40
+ use: [Css.loader, 'css-loader', 'sass-loader'],
41
+ },
42
+ {
43
+ test: /\.xml|.rjs|.java/,
44
+ use: 'raw-loader',
45
+ },
46
+ {
47
+ test: /\.svg|.png/,
48
+ use: 'file-loader',
49
+ },
50
+ ],
51
+ },
52
+ plugins: [
53
+ new HtmlWebpackPlugin({
54
+ template: './examples/src/index.ejs',
55
+ }),
56
+ new Css({
57
+ filename: 'main.css',
58
+ }),
59
+ ],
60
+ };