Setup Lightning

Published: November 04, 2020
Edited: November 06, 2020

Create a Lightning build

git clone https://github.com/rdkcentral/Lightning.git
cd Lightning
npm i

You can find the distributable in dist/lightning-wpe.js.

Usage

Create a file src/MyApp.js:

import Lightning from 'wpe-lightning'
export default class MyApp extends Lightning.Application {
    static _template() {
        return {
            Text: {text: {text: "hello world"}}
        }
    }
}

Add an index.html file:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <script src="./lightning-web.js"></script>
</head>
<body>
    <script type="module">
        import MyApp from "./src/MyApp.js";
        
        window.onload = function() {
            const options = {stage: {w: 1920, h: 1080, clearColor: 0xFF000000}}
            const app = new MyApp(options);
            document.body.appendChild(app.stage.getCanvas());
        }
    </script>
</body>
</html>

For more settings please check Stage Configuration

PHP Code Snippets Powered By : XYZScripts.com