Skip to content

Commit c0c99f5

Browse files
committed
chore: switch to vite and vitest for examples and tests
1 parent a1571ab commit c0c99f5

20 files changed

+2056
-7363
lines changed

.eslintrc

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
1-
name: Release
1+
name: Test & Release
22
on:
33
push:
4-
branches:
5-
- master
6-
- next
4+
75
jobs:
6+
test:
7+
name: Unit tests
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
with:
13+
fetch-depth: 0
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: 'lts/*'
18+
- uses: pnpm/action-setup@v2.2.4
19+
with:
20+
version: latest
21+
- name: Install dependencies
22+
run: pnpm i
23+
- name: Run unit tests
24+
run: pnpm run test
825
release:
926
name: Release
27+
needs: test
28+
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next'
1029
runs-on: ubuntu-latest
1130
steps:
1231
- name: Checkout

.github/workflows/test.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Pranesh Ravi
3+
Copyright (c) 2023 Bart Riepe
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

examples/index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
6+
<title>React Diff Viewer</title>
7+
<meta name="author" content="Bart Riepe" />
8+
<meta name="description" content="A simple and beautiful text diff viewer for React" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
10+
<meta name="theme-color" content="#11171C" />
11+
12+
<meta content="https://i.ibb.co/585KcMw/diff-viewer-v3.png" property="og:image"/>
13+
<meta content="React Diff Viewer" property="og:site_name" />
14+
<meta content="object" property="og:type" />
15+
<meta content="React Diff Viewer" property="og:title" />
16+
<meta content="https://github.com/aeolun/react-diff-viewer-continued" property="og:url" />
17+
<meta content="A simple and beautiful text diff viewer for React" property="og:description" />
18+
</head>
19+
<body>
20+
<div id="app"></div>
21+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/prism.min.js"></script>
22+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/components/prism-json.min.js"></script>
23+
<script type="module" src="./src/index.tsx"></script>
24+
</body>
25+
</html>

examples/src/index.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import logo from '../../logo.png';
66
import cn from 'classnames';
77
import {render} from "react-dom";
88

9-
const oldJs = require('./diff/javascript/old.rjs').default;
10-
const newJs = require('./diff/javascript/new.rjs').default;
9+
import oldJs from './diff/javascript/old.rjs?raw';
10+
import newJs from './diff/javascript/new.rjs?raw';
1111

12-
const oldYaml = require('./diff/massive/old.yaml').default;
13-
const newYaml = require('./diff/massive/new.yaml').default;
12+
import oldYaml from './diff/massive/old.yaml?raw';
13+
import newYaml from './diff/massive/new.yaml?raw';
1414

15-
const oldJson = require('./diff/json/old.json');
16-
const newJson = require('./diff/json/new.json');
15+
import oldJson from './diff/json/old.json';
16+
import newJson from './diff/json/new.json';
1717

1818
interface ExampleState {
1919
splitView?: boolean;
@@ -75,11 +75,11 @@ class Example extends Component<{}, ExampleState> {
7575
};
7676

7777
public render(): JSX.Element {
78-
let oldValue = '', newValue = '';
79-
if (this.state.dataType == 'json') {
78+
let oldValue: string | object = ''
79+
let newValue: string | object = '';
80+
if (this.state.dataType === 'json') {
8081
oldValue = oldJson
8182
newValue = newJson
82-
8383
} else if (this.state.dataType === 'javascript') {
8484
oldValue = oldJs
8585
newValue = newJs
@@ -107,6 +107,9 @@ class Example extends Component<{}, ExampleState> {
107107
Featuring split view, inline view, word diff, line highlight and
108108
more.
109109
</p>
110+
<p>
111+
This documentation is for the `next` release branch, e.g. v4.x
112+
</p>
110113
<div className="cta">
111114
<a href="https://github.com/aeolun/react-diff-viewer-continued#install">
112115
<button type="button" className="btn btn-primary btn-lg">

examples/src/style.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ body.light {
169169
color: #eee;
170170
}
171171

172+
.select {
173+
select {
174+
border-radius: 50px;
175+
padding: 4px 12px;
176+
border: 2px solid #125dec;
177+
background: white;
178+
}
179+
}
180+
172181
.react-diff-viewer-example {
173182
a {
174183
color: #125dec;

examples/vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { defineConfig } from 'vite'
2+
3+
export default defineConfig({
4+
})

jest.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)