From add6619a07626b0914852eeca8a7c30a3587af58 Mon Sep 17 00:00:00 2001
From: Cliff Li <lic@student.ethz.ch>
Date: Sat, 10 Mar 2018 14:29:00 +0100
Subject: [PATCH] Refactor for default props (and fix spread operator)

---
 .babelrc                            |  3 +++
 package.json                        |  3 +++
 src/components/Button.js            | 10 +++++++---
 src/views/studydocs/studydocList.js |  2 +-
 4 files changed, 14 insertions(+), 4 deletions(-)
 create mode 100644 .babelrc

diff --git a/.babelrc b/.babelrc
new file mode 100644
index 00000000..99670bfe
--- /dev/null
+++ b/.babelrc
@@ -0,0 +1,3 @@
+{
+  "plugins": ["transform-object-rest-spread"]
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index e07200be..6df23b38 100644
--- a/package.json
+++ b/package.json
@@ -33,5 +33,8 @@
     "uglifyjs-webpack-plugin": "^1.0.1",
     "webpack": "^3.8.1",
     "webpack-dev-server": "^2.9.3"
+  },
+  "devDependencies": {
+    "babel-plugin-transform-object-rest-spread": "^6.26.0"
   }
 }
diff --git a/src/components/Button.js b/src/components/Button.js
index 8ba66db3..1ecc58ac 100644
--- a/src/components/Button.js
+++ b/src/components/Button.js
@@ -1,9 +1,13 @@
 import m from "mithril";
 import { Button } from "polythene-mithril";
-import "polythene-css"
+import "polythene-css";
 
-const ButtonComponent = () => {
-    return Button;
+const defaultProps = {
+    element: 'button',
+}
+
+const ButtonComponent = props => {
+    return m(Button, {...defaultProps, ...props});
 }
 
 export default ButtonComponent;
\ No newline at end of file
diff --git a/src/views/studydocs/studydocList.js b/src/views/studydocs/studydocList.js
index 19294621..5bf02bcf 100644
--- a/src/views/studydocs/studydocList.js
+++ b/src/views/studydocs/studydocList.js
@@ -38,7 +38,7 @@ export default class studydocList {
         },
       }, [
         m('input', { type: 'text', oninput: m.withAttr('value', (value) => { this.search = value; }) }, ''),
-        m(Button, { label: 'Search', type: 'submit' }),
+        Button({ label: 'Search' }),
       ]),
       m('button', { onclick: () => m.route.set('/studydocuments/new') }, 'add new'),
       m('table', [
-- 
GitLab