Skip to content

Commit

Permalink
feat: add lit-element project (#507)
Browse files Browse the repository at this point in the history
Demonstrate that bpmn-visualization can be integrated in a Web Component.
Built with Vite.

Use patch-package to patch mxGraph and make it correctly handles `ShadowRoot`.
  • Loading branch information
tbouffard authored Jun 13, 2023
1 parent 71d2bd1 commit 319b07b
Show file tree
Hide file tree
Showing 16 changed files with 1,256 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check-projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
project:
- javascript-vanilla-with-webpack
- typescript-angular
- typescript-lit-element
- typescript-vanilla-with-parcel
- typescript-vanilla-with-rollup
- typescript-vanilla-with-vitejs
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Custom BPMN Theme features will be progressively added to `bpmn-visualization`.
Show how to integrate `bpmn-visualization` in project, using various kind of frameworks, build tools and bundlers:
- [JavaScript + Webpack](projects/javascript-vanilla-with-webpack/README.md) - integration in a vanilla JavaScript Webpack project
- [TypeScript + Angular](projects/typescript-angular/README.md) - integration in a TypeScript Angular project
- [TypeScript + Lit Element](projects/typescript-lit-element/README.md) - integration in a TypeScript Lit-Element project
- [TypeScript + Parcel](projects/typescript-vanilla-with-parcel/README.md) - integration in a vanilla TypeScript Parcel project
- [TypeScript + Rollup](projects/typescript-vanilla-with-rollup/README.md) - integration in a vanilla TypeScript Rollup project
- [TypeScript + Vite](projects/typescript-vanilla-with-vitejs/README.md) - integration in a vanilla TypeScript Vite project
Expand Down
25 changes: 25 additions & 0 deletions projects/typescript-lit-element/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
package-lock.json
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
1 change: 1 addition & 0 deletions projects/typescript-lit-element/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=true
24 changes: 24 additions & 0 deletions projects/typescript-lit-element/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Integrate `bpmn-visualization` in a lit-element TypeScript project built with Vite

To run locally:

1. `npm install`
2. `npm start`
3. [localhost app](http://localhost:5173)

You will see the following diagram:

![BPMN diagram in the home page](docs/home.png)

The code calling `bpmn-visualization` to render the BPMN diagram is available in [index.ts](src/index.ts).

If you want to bundle the application, run `npm run build` and then run `npm run preview` to access to a preview of the
bundle application with http://localhost:4173.

## Specific mxGraph patch to make it work

To workaround bug [#2738](https://github.com/process-analytics/bpmn-visualization-js/issues/2738) "[BUG] Failed to execute 'getComputedStyle' when using lit",
`mxGraph` is patched using [patch-package](https://www.npmjs.com/package/patch-package) as the root cause of the bug is an issue in the `mxGraph` code.

The patch has been created by modifying manually `node_modules/mxgraph/javascript/dist/build.js`
and then running: `npx patch-package mxgraph`
Binary file added projects/typescript-lit-element/docs/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions projects/typescript-lit-element/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions projects/typescript-lit-element/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>bpmn-visualization TypeScript Integration with lit-element</title>
<script type="module" src="/src/index.ts"></script>
</head>
<body>
<h1 class="title">bpmn-visualization TypeScript Integration with lit-element</h1>
<bpmn-diag></bpmn-diag>
<footer></footer>
</body>
</html>
Loading

0 comments on commit 319b07b

Please sign in to comment.