mc-react-header 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,131 +1,131 @@
1
- import "./Navbar.css";
2
-
3
- import Logo from "./assets/mcloud_logo.png";
4
-
5
- import "font-awesome/css/font-awesome.min.css";
6
- import React from "react";
7
-
8
- const mainSections = {
9
- learn: { name: "LEARN", link: "https://www.materialscloud.org/learn" },
10
- work: { name: "WORK", link: "https://www.materialscloud.org/work" },
11
- discover: {
12
- name: "DISCOVER",
13
- link: "https://www.materialscloud.org/discover",
14
- },
15
- explore: { name: "EXPLORE", link: "https://www.materialscloud.org/explore" },
16
- archive: { name: "ARCHIVE", link: "https://www.materialscloud.org/archive" },
17
- };
18
-
19
- const dropdownSections = {
20
- policies: {
21
- name: "Policies",
22
- link: "https://www.materialscloud.org/policies",
23
- },
24
- dmp: {
25
- name: "Data Management Plan",
26
- link: "https://www.materialscloud.org/dmp",
27
- },
28
- terms: {
29
- name: "Terms of Use",
30
- link: "https://www.materialscloud.org/termssummary",
31
- },
32
- infrastructure: {
33
- name: "Infrastructure",
34
- link: "https://www.materialscloud.org/infrastructure",
35
- },
36
- team: { name: "Team & Contact", link: "https://www.materialscloud.org/team" },
37
- partners: {
38
- name: "Partners",
39
- link: "https://www.materialscloud.org/home#partners",
40
- },
41
- restapi: {
42
- name: "Connect your REST API",
43
- link: "https://www.materialscloud.org/explore/connect",
44
- },
45
- };
46
-
47
- class DropdownMenu extends React.Component {
48
- constructor(props) {
49
- super(props);
50
- this.state = { dropdownOpen: false };
51
- this.toggleDropdown = this.toggleDropdown.bind(this);
52
- this.setWrapperRef = this.setWrapperRef.bind(this);
53
- this.handleClickOutside = this.handleClickOutside.bind(this);
54
- }
55
-
56
- componentDidMount() {
57
- document.addEventListener("mousedown", this.handleClickOutside);
58
- }
59
-
60
- componentWillUnmount() {
61
- document.removeEventListener("mousedown", this.handleClickOutside);
62
- }
63
-
64
- setWrapperRef(node) {
65
- this.wrapperRef = node;
66
- }
67
-
68
- handleClickOutside(event) {
69
- if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {
70
- if (this.state.dropdownOpen) {
71
- this.setState({ dropdownOpen: false });
72
- }
73
- }
74
- }
75
-
76
- toggleDropdown() {
77
- this.setState({ dropdownOpen: !this.state.dropdownOpen });
78
- }
79
- render() {
80
- let dropdownContentClass = "dropdown-content";
81
- if (this.state.dropdownOpen) {
82
- dropdownContentClass += " dropdown-open";
83
- }
84
- return (
85
- <div ref={this.setWrapperRef} className="more-dropdown">
86
- <a className="more-btn" onClick={this.toggleDropdown}>
87
- More <i className="fa fa-caret-down"></i>
88
- </a>
89
- <div className={dropdownContentClass}>
90
- {Object.keys(dropdownSections).map((element, i) => {
91
- let cname = "";
92
- if (element == this.props.activeSection) cname = "active";
93
- return (
94
- <a
95
- key={i}
96
- className={cname}
97
- href={dropdownSections[element].link}
98
- >
99
- {dropdownSections[element].name}
100
- </a>
101
- );
102
- })}
103
- </div>
104
- </div>
105
- );
106
- }
107
- }
108
-
109
- class Navbar extends React.Component {
110
- render() {
111
- return (
112
- <div className="mc-navbar">
113
- <a className="mc-navbrand" href="https://www.materialscloud.org/home">
114
- <img src={Logo} height="50" alt="MC logo" />
115
- </a>
116
- {Object.keys(mainSections).map((key, i) => {
117
- let cname = "mc-navlink";
118
- if (key == this.props.activeSection) cname += " active";
119
- return (
120
- <a key={i} className={cname} href={mainSections[key].link}>
121
- {mainSections[key].name}
122
- </a>
123
- );
124
- })}
125
- <DropdownMenu activeSection={this.props.activeSection} />
126
- </div>
127
- );
128
- }
129
- }
130
-
131
- export default Navbar;
1
+ import "./Navbar.css";
2
+
3
+ import Logo from "./assets/mcloud_logo.png";
4
+
5
+ import "font-awesome/css/font-awesome.min.css";
6
+ import React from "react";
7
+
8
+ const mainSections = {
9
+ learn: { name: "LEARN", link: "https://www.materialscloud.org/learn" },
10
+ work: { name: "WORK", link: "https://www.materialscloud.org/work" },
11
+ discover: {
12
+ name: "DISCOVER",
13
+ link: "https://www.materialscloud.org/discover",
14
+ },
15
+ explore: { name: "EXPLORE", link: "https://www.materialscloud.org/explore" },
16
+ archive: { name: "ARCHIVE", link: "https://www.materialscloud.org/archive" },
17
+ };
18
+
19
+ const dropdownSections = {
20
+ policies: {
21
+ name: "Policies",
22
+ link: "https://www.materialscloud.org/policies",
23
+ },
24
+ dmp: {
25
+ name: "Data Management Plan",
26
+ link: "https://www.materialscloud.org/dmp",
27
+ },
28
+ terms: {
29
+ name: "Terms of Use",
30
+ link: "https://www.materialscloud.org/termssummary",
31
+ },
32
+ infrastructure: {
33
+ name: "Infrastructure",
34
+ link: "https://www.materialscloud.org/infrastructure",
35
+ },
36
+ team: { name: "Team & Contact", link: "https://www.materialscloud.org/team" },
37
+ partners: {
38
+ name: "Partners",
39
+ link: "https://www.materialscloud.org/home#partners",
40
+ },
41
+ restapi: {
42
+ name: "Connect your REST API",
43
+ link: "https://www.materialscloud.org/explore/connect",
44
+ },
45
+ };
46
+
47
+ class DropdownMenu extends React.Component {
48
+ constructor(props) {
49
+ super(props);
50
+ this.state = { dropdownOpen: false };
51
+ this.toggleDropdown = this.toggleDropdown.bind(this);
52
+ this.setWrapperRef = this.setWrapperRef.bind(this);
53
+ this.handleClickOutside = this.handleClickOutside.bind(this);
54
+ }
55
+
56
+ componentDidMount() {
57
+ document.addEventListener("mousedown", this.handleClickOutside);
58
+ }
59
+
60
+ componentWillUnmount() {
61
+ document.removeEventListener("mousedown", this.handleClickOutside);
62
+ }
63
+
64
+ setWrapperRef(node) {
65
+ this.wrapperRef = node;
66
+ }
67
+
68
+ handleClickOutside(event) {
69
+ if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {
70
+ if (this.state.dropdownOpen) {
71
+ this.setState({ dropdownOpen: false });
72
+ }
73
+ }
74
+ }
75
+
76
+ toggleDropdown() {
77
+ this.setState({ dropdownOpen: !this.state.dropdownOpen });
78
+ }
79
+ render() {
80
+ let dropdownContentClass = "dropdown-content";
81
+ if (this.state.dropdownOpen) {
82
+ dropdownContentClass += " dropdown-open";
83
+ }
84
+ return (
85
+ <div ref={this.setWrapperRef} className="more-dropdown">
86
+ <a className="more-btn" onClick={this.toggleDropdown}>
87
+ More <i className="fa fa-caret-down"></i>
88
+ </a>
89
+ <div className={dropdownContentClass}>
90
+ {Object.keys(dropdownSections).map((element, i) => {
91
+ let cname = "";
92
+ if (element == this.props.activeSection) cname = "active";
93
+ return (
94
+ <a
95
+ key={i}
96
+ className={cname}
97
+ href={dropdownSections[element].link}
98
+ >
99
+ {dropdownSections[element].name}
100
+ </a>
101
+ );
102
+ })}
103
+ </div>
104
+ </div>
105
+ );
106
+ }
107
+ }
108
+
109
+ class Navbar extends React.Component {
110
+ render() {
111
+ return (
112
+ <div className="mc-navbar">
113
+ <a className="mc-navbrand" href="https://www.materialscloud.org/home">
114
+ <img src={Logo} height="50" alt="MC logo" />
115
+ </a>
116
+ {Object.keys(mainSections).map((key, i) => {
117
+ let cname = "mc-navlink";
118
+ if (key == this.props.activeSection) cname += " active";
119
+ return (
120
+ <a key={i} className={cname} href={mainSections[key].link}>
121
+ {mainSections[key].name}
122
+ </a>
123
+ );
124
+ })}
125
+ <DropdownMenu activeSection={this.props.activeSection} />
126
+ </div>
127
+ );
128
+ }
129
+ }
130
+
131
+ export default Navbar;
@@ -1,15 +1,14 @@
1
- .main-container {
2
- background-color: #f0f6f9;
3
- height: 100%;
4
- padding-bottom: 10px;
5
- }
6
-
7
- .content-container {
8
- background-color: white;
9
- margin: 5px;
10
- margin-top: 30px;
11
- margin-bottom: 10px;
12
- padding: 2px;
13
- padding-bottom: 20px;
14
- border-radius: 2px;
15
- }
1
+ .main-container {
2
+ background-color: #f0f6f9;
3
+ min-height: 100vh;
4
+ }
5
+
6
+ .content-container {
7
+ background-color: white;
8
+ margin: 5px;
9
+ margin-top: 30px;
10
+ margin-bottom: 10px;
11
+ padding: 2px;
12
+ padding-bottom: 20px;
13
+ border-radius: 2px;
14
+ }
@@ -1,25 +1,25 @@
1
- import React from "react";
2
- import "./index.css";
3
-
4
- import Navbar from "./Navbar";
5
- import Breadcrumbs from "./Breadcrumbs";
6
-
7
- class MaterialsCloudHeader extends React.Component {
8
- constructor(props) {
9
- super(props);
10
- }
11
-
12
- render() {
13
- return (
14
- <div className="main-container">
15
- <Navbar activeSection={this.props.activeSection} />
16
- <div className="content-container">
17
- <Breadcrumbs breadcrumbsPath={this.props.breadcrumbsPath} />
18
- {this.props.children}
19
- </div>
20
- </div>
21
- );
22
- }
23
- }
24
-
25
- export default MaterialsCloudHeader;
1
+ import React from "react";
2
+ import "./index.css";
3
+
4
+ import Navbar from "./Navbar";
5
+ import Breadcrumbs from "./Breadcrumbs";
6
+
7
+ class MaterialsCloudHeader extends React.Component {
8
+ constructor(props) {
9
+ super(props);
10
+ }
11
+
12
+ render() {
13
+ return (
14
+ <div className="main-container">
15
+ <Navbar activeSection={this.props.activeSection} />
16
+ <div className="content-container">
17
+ <Breadcrumbs breadcrumbsPath={this.props.breadcrumbsPath} />
18
+ {this.props.children}
19
+ </div>
20
+ </div>
21
+ );
22
+ }
23
+ }
24
+
25
+ export default MaterialsCloudHeader;