Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to LitElement to simplify the code #58

Open
kenchris opened this issue Sep 18, 2018 · 4 comments
Open

Move to LitElement to simplify the code #58

kenchris opened this issue Sep 18, 2018 · 4 comments

Comments

@kenchris
Copy link
Contributor

kenchris commented Sep 18, 2018

I have tested the below and it works fine. You can move piece by piece.

diff --git a/sensor-tester/src/create-page.js b/sensor-tester/src/create-page.js
new file mode 100644
index 0000000..727783c
--- /dev/null
+++ b/sensor-tester/src/create-page.js
@@ -0,0 +1,16 @@
+import {LitElement, html, property} from '@polymer/lit-element';
+
+export const createPage = (options) => {
+  return class extends LitElement {
+    render() {
+      return html`
+        <sensor-tests-page
+          tests=${options.src}
+          sensortype=${options.sensorType}
+          referenceframe=${options.sensorType || "screen"}
+          frequency=${options.frequency || 90}>
+        </sensor-tests-page>
+      `;
+    }
+  }
+}
\ No newline at end of file
diff --git a/sensor-tester/src/sensor-tester.html b/sensor-tester/src/sensor-tester.html
index 07257b3..ab04c2e 100644
--- a/sensor-tester/src/sensor-tester.html
+++ b/sensor-tester/src/sensor-tester.html
@@ -13,7 +13,6 @@
 <link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html">
 
 <link rel="lazy-import" href="accelerometer-page.html">
-<link rel="lazy-import" href="accelerometer-screen-page.html">
 <link rel="lazy-import" href="linearaccelerationsensor-page.html">
 <link rel="lazy-import" href="linearaccelerationsensor-screen-page.html">
 <link rel="lazy-import" href="gyroscope-page.html">
@@ -22,6 +21,15 @@
 <link rel="lazy-import" href="ambientlightsensor-page.html">
 <link rel="lazy-import" href="magnetometer-page.html">
 
+<script type="module">
+  import { createPage } from "create-page.js"
+
+  customElements.define('accelerometer-screen-page', createPage({
+    src: "src/tests/accelerometer-screen.json",
+    sensorType: "Accelerometer"
+  }));
+</script>
+
 <dom-module id="sensor-tester">
   <template>
     <style>
@rakuco
Copy link

rakuco commented Sep 18, 2018

@kaixinjxq

@kenchris
Copy link
Contributor Author

You probably don't want to create the pages (which involves loading json etc) before the router requests it

@kenchris
Copy link
Contributor Author

Btw, I might be able to work on some of this tomorrow - there is a lot of things that could be improved

@kenchris
Copy link
Contributor Author

#60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants