Skip to content

Commit af8c179

Browse files
committed
Update for yFiles for HTML 2.6
1 parent b72adf9 commit af8c179

19 files changed

+200
-227
lines changed

.eslintrc.cjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
env: { browser: true, es2020: true },
3+
extends: [
4+
'eslint:recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:react-hooks/recommended',
7+
],
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
10+
plugins: ['react-refresh'],
11+
rules: {
12+
'react-refresh/only-export-components': 'warn',
13+
},
14+
}

.gitignore

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
3-
# dependencies
4-
/node_modules
5-
/.pnp
6-
.pnp.js
7-
8-
# testing
9-
/coverage
10-
11-
# production
12-
/build
13-
14-
# misc
15-
.DS_Store
16-
.env.local
17-
.env.development.local
18-
.env.test.local
19-
.env.production.local
20-
license.json
21-
1+
# Logs
2+
logs
3+
*.log
224
npm-debug.log*
235
yarn-debug.log*
246
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
2514
package-lock.json
2615
yarn.lock
16+
17+
# Editor directories and files
18+
.vscode/*
19+
!.vscode/extensions.json
20+
.idea
21+
.DS_Store
22+
*.suo
23+
*.ntvs*
24+
*.njsproj
25+
*.sln
26+
*.sw?
27+
license.json

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<img src="./src/yfiles-logo.svg" alt="yFiles logo" height="100"/>
1+
<img src="src/assets/yfiles-logo.svg" alt="yFiles logo" height="100"/>
22

33
# yFiles integration for create-react-app
44

5-
This sample application serves as a basic scaffold of how to integrate [yFiles for HTML](https://www.yworks.com/products/yfiles-for-html) in a [React](https://reactjs.org/) application. It was scaffolded with [create-react-app](https://create-react-app.dev/).
5+
This sample application serves as a basic scaffold of how to integrate [yFiles for HTML](https://www.yworks.com/products/yfiles-for-html) in a [React](https://reactjs.org/) application. It was scaffolded with [create vite](https://vitejs.dev//).
66

77
**To run this project, a valid [yFiles for HTML](https://www.yworks.com/products/yfiles-for-html) version is required. You can evaluate yFiles 60 days free of charge on [my.yworks.com](https://my.yworks.com/signup?product=YFILES_HTML_EVAL).**
88

99
## Version Information
1010

11-
- create-react-app v5.0.1
12-
- yFiles for HTML 2.5
11+
- create vite v9.5.1
12+
- yFiles for HTML 2.6
1313

1414
## Getting Started
1515

@@ -25,15 +25,15 @@ Then, extract a yFiles Evaluation package beside it and run
2525
npm install
2626
```
2727

28-
You can serve the application on [http://localhost:3000/](http://localhost:3000/) with
28+
You can serve the application on [http://localhost:5173/](http://localhost:5173/) with
2929

3030
```
3131
npm run start
3232
```
3333

3434
## Under the Hood
3535

36-
This project is a default `create-react-app` application, where yFiles was added as an additional dependency to integrate a basic graph component.
36+
This project is a `create vite` application, where yFiles was added as an additional dependency to integrate a basic graph component.
3737

3838
A step-by-step description of how to integrate yFiles in a React application can be found [here](integration-howto.md).
3939

@@ -43,7 +43,7 @@ This basic yFiles integration can be used as a starting point to test the capabi
4343

4444
You can browse through the demos and look for features that you find interesting for your use case and integrate it in this basic component to build a more sophisticated application.
4545

46-
The yFiles package also contains a more extensive [React integration demo](https://live.yworks.com/demos/toolkit/react/index.html) ([GitHub](https://github.com/yWorks/yfiles-for-html-demos/tree/master/demos/toolkit/react)). This is also available with [TypeScript](https://live.yworks.com/demos/toolkit/react-typescript/index.html) (see [GitHub](https://github.com/yWorks/yfiles-for-html-demos/tree/master/demos/toolkit/react-typescript)).
46+
The yFiles package also contains a more extensive [React integration demo](https://live.yworks.com/demos/toolkit/react/index.html) ([GitHub](https://github.com/yWorks/yfiles-for-html-demos/tree/master/demos/toolkit/react)).
4747

4848
Furthermore, there is an extensive [Developer's Guide](https://docs.yworks.com/yfileshtml/#/dguide/introduction#top) that covers anything from graph creation and styling to automatic layouts and advanced customizations.
4949

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React + TS</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

integration-howto.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ TL;DR Add `yfiles` as a dependency in the `package.json`,
66
[include your license](https://docs.yworks.com/yfileshtml/#/dguide/licensing#_general_concept),
77
and start importing yFiles classes in your project.
88

9-
## Running the CLI
9+
## Create a `create vite` application
1010

11-
Run the create-react-app CLI with `> npx create-react-app yfiles-react-integration-basic` which
12-
scaffolds a basic React application.
11+
At first, create a basic `create vite` app by running `> npm create vite@latest`, e.g., with
12+
the following options:
13+
14+
- `Project name:` yfiles-react-integration-basic
15+
- `Select framework:` React
16+
- `Select variant:` TypeScript
1317

1418
## Add yFiles as a dependency
1519

@@ -20,7 +24,7 @@ Adding yFiles as a dependency is almost as easy as installing an external librar
2024
```
2125
"dependencies": {
2226
...
23-
"yfiles": "../yFiles-for-HTML-Complete-2.5.0.4-Evaluation/lib-dev/yfiles-25.0.4+eval-dev.tgz"
27+
"yfiles": "../yFiles-for-HTML-Complete-2.6-Evaluation/lib-dev/yfiles-26.0.0+eval-dev.tgz"
2428
},
2529
```
2630

@@ -37,19 +41,19 @@ of the box to easily work with the library.
3741

3842
With the yFiles dependency, you can easily create a new React component that contains a yFiles GraphComponent.
3943

40-
1. Create a new `ReactGraphComponent.js` file in `/src/` which instantiates a new yFiles GraphComponent
44+
1. Create a new `ReactGraphComponent.tsx` file in `/src/components` which instantiates a new yFiles GraphComponent
4145
with editing capabilities and a basic sample graph.
4246

4347
Note how the yFiles GraphComponent is added to the DOM by providing a reference to an empty `div`
4448
element in which it is supposed to be created.
4549

46-
See the contents of `/src/ReactGraphComponent.js` in this repository for the full implementation.
50+
See the contents of `/src/components/ReactGraphComponent.tsx` in this repository for the full implementation.
4751

4852
Make sure to configure your license data as described above.
4953

50-
2. Afterwards, just add the new React component to the `App.js`.
54+
2. Afterwards, just add the new React component to the `App.tsx`.
5155

52-
And that's it. Run `npm run start` to serve the application at [http://localhost:3000/](http://localhost:3000/) with a basic yFiles component.
56+
And that's it. Run `npm run dev` to serve the application at [http://localhost:5173/](http://localhost:5173/) with a basic yFiles component.
5357

5458
## Development Mode
5559

package.json

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,30 @@
33
"version": "1.0.0",
44
"author": "yWorks GmbH <[email protected]>",
55
"private": true,
6-
"dependencies": {
7-
"@testing-library/jest-dom": "^5.16.4",
8-
"@testing-library/react": "^13.3.0",
9-
"@testing-library/user-event": "^14.3.0",
10-
"react": "^18.2.0",
11-
"react-dom": "^18.2.0",
12-
"react-scripts": "5.0.1",
13-
"web-vitals": "^2.1.4",
14-
"yfiles": "../yFiles-for-HTML-Complete-2.5.0.4-Evaluation/lib-dev/yfiles-25.0.4+eval-dev.tgz"
15-
},
6+
"type": "module",
167
"scripts": {
17-
"start": "react-scripts start",
18-
"build": "react-scripts build",
19-
"test": "react-scripts test",
20-
"eject": "react-scripts eject",
8+
"dev": "vite",
9+
"build": "tsc && vite build",
10+
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
11+
"preview": "vite preview",
2112
"postinstall": "npm run copy-eval-license",
22-
"copy-eval-license": "node -e \"require('fs').copyFileSync('../yFiles-for-HTML-Complete-2.5.0.4-Evaluation/lib/license.json','./src/license.json')\""
13+
"copy-eval-license": "node -e \"require('fs').copyFileSync('../yFiles-for-HTML-Complete-2.6-Evaluation/lib/license.json','./src/license.json')\""
2314
},
24-
"eslintConfig": {
25-
"extends": [
26-
"react-app",
27-
"react-app/jest"
28-
]
15+
"dependencies": {
16+
"react": "^18.2.0",
17+
"react-dom": "^18.2.0",
18+
"yfiles": "../yFiles-for-HTML-Complete-2.6-Evaluation/lib-dev/yfiles-26.0.0+eval-dev.tgz"
2919
},
30-
"browserslist": {
31-
"production": [
32-
">0.2%",
33-
"not dead",
34-
"not op_mini all"
35-
],
36-
"development": [
37-
"last 1 chrome version",
38-
"last 1 firefox version",
39-
"last 1 safari version"
40-
]
20+
"devDependencies": {
21+
"@types/react": "^18.2.0",
22+
"@types/react-dom": "^18.2.0",
23+
"@typescript-eslint/eslint-plugin": "^5.59.0",
24+
"@typescript-eslint/parser": "^5.59.0",
25+
"@vitejs/plugin-react": "^4.0.0",
26+
"eslint": "^8.38.0",
27+
"eslint-plugin-react-hooks": "^4.6.0",
28+
"eslint-plugin-react-refresh": "^0.3.4",
29+
"typescript": "~5.1.6",
30+
"vite": "^4.3.9"
4131
}
4232
}

public/index.html

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

public/manifest.json

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

src/App.js renamed to src/App.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import React from 'react'
2-
import logo from './yfiles-logo.svg'
1+
import logo from './assets/yfiles-logo.svg'
32
import './App.css'
4-
import ReactGraphComponent from './ReactGraphComponent.js'
3+
import { ReactGraphComponent } from './components/ReactGraphComponent'
54

65
function App() {
76
return (

src/ReactGraphComponent.js

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

0 commit comments

Comments
 (0)