From 70dbd1b32d13d30e15c03ee91b0fab7bfdf429b3 Mon Sep 17 00:00:00 2001
From: Maximilian Hils <git@maximilianhils.com>
Date: Mon, 25 Jul 2016 17:03:50 -0700
Subject: web: refactor ContentLoader

---
 .../components/ContentView/UploadContentButton.jsx | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 web/src/js/components/ContentView/UploadContentButton.jsx

(limited to 'web/src/js/components/ContentView/UploadContentButton.jsx')

diff --git a/web/src/js/components/ContentView/UploadContentButton.jsx b/web/src/js/components/ContentView/UploadContentButton.jsx
new file mode 100644
index 00000000..0652b584
--- /dev/null
+++ b/web/src/js/components/ContentView/UploadContentButton.jsx
@@ -0,0 +1,28 @@
+import { PropTypes } from 'react'
+
+UploadContentButton.propTypes = {
+    uploadContent: PropTypes.func.isRequired,
+}
+
+export default function UploadContentButton({ uploadContent }) {
+
+    let fileInput;
+
+    return (
+        <a className="btn btn-default btn-xs"
+           onClick={() => fileInput.click()}
+           title="Upload a file to replace the content.">
+            <i className="fa fa-upload"/>
+            <input
+                ref={ref => fileInput = ref}
+                className="hidden"
+                type="file"
+                onChange={e => {
+                    if (e.target.files.length > 0) uploadContent(e.target.files[0])
+                }}
+            />
+        </a>
+
+    )
+}
+
-- 
cgit v1.2.3

