Przeglądaj źródła

add tag label component

itizawa 7 lat temu
rodzic
commit
215451e581
1 zmienionych plików z 41 dodań i 0 usunięć
  1. 41 0
      src/client/js/components/Page/TagLabel.jsx

+ 41 - 0
src/client/js/components/Page/TagLabel.jsx

@@ -0,0 +1,41 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+
+export default class TagLabel extends React.Component {
+
+  render() {
+    const tags = [];
+    const tagListstyle = {
+      borderRadius: '5px',
+      marginLeft: '5px',
+      fontSize: '12px',
+      height: '20px',
+      padding: '0px 10px',
+    };
+
+    if (this.props.currentPageTags.length === 0) {
+      return (
+        <div style={tagListstyle}>
+        tag is not set
+        </div>
+      );
+    }
+
+    for (let i = 0; i < this.props.currentPageTags.length; i++) {
+      tags.push(
+        <div style={tagListstyle} key={i.toString()} className="label label-info">{this.props.currentPageTags[i]}</div>,
+      );
+    }
+
+    return (
+      <div>
+        {tags}
+      </div>
+    );
+  }
+
+}
+
+TagLabel.propTypes = {
+  currentPageTags: PropTypes.array.isRequired,
+};