From e5bf1e930a5b6ba0b3300b02daf792d65d795202 Mon Sep 17 00:00:00 2001
From: Jason <jason.daurus@gmail.com>
Date: Tue, 14 Jun 2016 23:52:00 +0800
Subject: [web] FlowView and ContentView

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

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

diff --git a/web/src/js/components/ContentView/ViewSelector.jsx b/web/src/js/components/ContentView/ViewSelector.jsx
new file mode 100644
index 00000000..df3a5b83
--- /dev/null
+++ b/web/src/js/components/ContentView/ViewSelector.jsx
@@ -0,0 +1,28 @@
+import React, { PropTypes } from 'react'
+import classnames from 'classnames'
+import views, { ViewAuto } from './ContentViews'
+
+ViewSelector.propTypes = {
+    active: PropTypes.func.isRequired,
+    message: PropTypes.object.isRequired,
+    onSelectView: PropTypes.func.isRequired,
+}
+
+export default function ViewSelector({ active, message, onSelectView }) {
+    return (
+        <div className="view-selector btn-group btn-group-xs">
+            {views.map(View => (
+                <button
+                    key={View.name}
+                    onClick={() => onSelectView(View)}
+                    className={classnames('btn btn-default', { active: View === active })}>
+                    {View === ViewAuto ? (
+                        `auto: ${ViewAuto.findView(message).name.toLowerCase().replace('view', '')}`
+                    ) : (
+                        View.name.toLowerCase().replace('view', '')
+                    )}
+                </button>
+            ))}
+        </div>
+    )
+}
-- 
cgit v1.2.3

