- Make sure you go through the getting started guide first.
- Have some knowledge of Typescript and Svelte.
We are going to add new weblet called demo .
-
Add new folder called demo at
src/elements/demo. -
Add Demo.wc.svelte at
src/elements/demo/Demo.wc.svelte.// Demo.wc.svelte /* Write whatever svelte code u need here */
-
Add index.ts at
src/elements/demo/index.ts.// index.ts import "./Demo.wc.svelte";
-
Developing weblet by importing
Demo.wc.svelteintoApp.svelte.<!-- App.svelte --> <script lang="ts"> import Demo from "./elements/demo/Demo.wc.svelte"; </script> <Demo />
-
Build
Demo.wc.svelte.yarn build
Find the output in the
.build/directory.
Assume we need to include vm weblet in its own index.html file.
Notes:
- You will need to include
base.wc.js&profiles.wc.jsfor every component to work. - Also, You will need to inject the required libraries grid3_client and ts-rmb-http-client in
window.configsObject.
The index.html file should be like the following.
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>VM Weblet Example</title>
<style>
* {
box-sizing: border-box;
}
</style>
<!-- window.configs should include the required libs -->
<script src="/path/to/libs/to/inject"></script>
<!-- include the components -->
<script src="/path/to/base.wc.js"></script>
<script src="/path/to/profiles.wc.js"></script>
<script defer src="/path/to/vm.wc.js"></script>
</head>
<body>
<!-- Base, Profile and your desired weblet -->
<tf-base></tf-base>
<tf-profiles></tf-profiles>
<tf-vm></tf-vm>
</body>
</html>- Deploy the weblet in the playground app by appending the weblet to the elements list in
playground/src/App.vue - Create new tab in the sideNav by appending the weblet list with new class of
Webletinplayground/src/views/Editor.vue