Skip to content

Commit

Permalink
Update README w.r.t. bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
dokempf committed Sep 24, 2024
1 parent 321ea88 commit 6315e3e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,15 @@ npm run dev

## Usage

You can create a bundle with the following commands:
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Svelte Component</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" type="text/css" crossorigin href="bundle.css">
<script src="bundle.js"></script>
</head>
<body>
<easydb-detail-view uuid="e95dcb74-77f6-4794-b468-506da8b7a3a1"/>
</body>
</html>
npm run easydb -- --instance-url=https://heidicon.ub.uni-heidelberg.de
npm run bundle
```

This will generate `bundle.{js,css}` in the `bundle/` directory. You can look at the provided
`index.html` for an example of how to integrate into your HTML page.

## Issues

If you find any issues with using this component, please open an issue.
Expand Down
21 changes: 20 additions & 1 deletion bundle/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,28 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Svelte Component</title>

<!-- Import the generated bundle -->
<script src="bundle.js"></script>

<!-- Ensure that our CSS is loaded into the shadow DOM of our component -->
<script>
customElements.whenDefined("easydb-detail-view").then(() => {
setTimeout(() => {
let ele = document.getElementById("my-easydb");
console.log(ele);
var link = document.createElement("link");
link.setAttribute("rel", "stylesheet");
link.setAttribute(
"href",
"bundle.css"
);
ele.shadowRoot.appendChild(link);
}, 0);
});
</script>
</head>
<body>
<easydb-detail-view uuid="e95dcb74-77f6-4794-b468-506da8b7a3a1"/>
<easydb-detail-view id="my-easydb" uuid="e95dcb74-77f6-4794-b468-506da8b7a3a1"/>
</body>
</html>

0 comments on commit 6315e3e

Please sign in to comment.