From 4d642e312ed728ad51c454d1e2a0b7bb350fc174 Mon Sep 17 00:00:00 2001
From: Piotr Russ <mail@pruss.it>
Date: Sun, 6 Dec 2020 23:49:13 +0100
Subject: first creator page

---
 client/src/admin/jsx/layout/LangSwitch.jsx | 42 ++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 client/src/admin/jsx/layout/LangSwitch.jsx

(limited to 'client/src/admin/jsx/layout/LangSwitch.jsx')

diff --git a/client/src/admin/jsx/layout/LangSwitch.jsx b/client/src/admin/jsx/layout/LangSwitch.jsx
new file mode 100644
index 0000000..684d432
--- /dev/null
+++ b/client/src/admin/jsx/layout/LangSwitch.jsx
@@ -0,0 +1,42 @@
+import React from 'react';
+import { WithHover } from '../../hocs';
+import { languages } from '../../data/translations.js'
+
+const LangSwitch = ({ lang, setLang, opened, setOpened}) => {
+  const handleSetLang = (key) => {
+    setLang(key);
+    setOpened(false);
+  };
+
+  return (
+    <div className="lang-switch">
+      <WithHover message="click-to-change-language">
+        <span
+          className={`lang-switch__main-item${opened === 'lang' ? ' lang-switch__main-item--active' : ''}`}
+          onClick={() => setOpened(opened !== 'lang' ? 'lang' : false)}
+        >
+          {lang}
+        </span>
+        {
+          opened === 'lang' && (
+            <div className="lang-switch__list">
+              {
+                languages.map(key => key !== lang && (
+                  <span
+                    className="lang-switch__item"
+                    key={key}
+                    onClick={() => handleSetLang(key)}
+                  >
+                    {key}
+                  </span>
+                ))
+              }
+            </div>
+          )
+        }
+      </WithHover>
+    </div>
+  );
+};
+
+export default LangSwitch;
-- 
cgit v1.2.3

