mc-react-header 0.2.1 → 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.
- package/.github/workflows/release_and_publish.yml +41 -0
- package/README.md +21 -78
- package/dist/Breadcrumbs.css +101 -101
- package/dist/Breadcrumbs.js +6 -6
- package/dist/Navbar.css +129 -129
- package/dist/Navbar.js +16 -16
- package/dist/index.css +14 -15
- package/dist/index.js +8 -8
- package/package.json +57 -56
- package/public/index.html +43 -43
- package/public/manifest.json +25 -25
- package/public/robots.txt +3 -3
- package/src/App.css +38 -38
- package/src/App.js +23 -23
- package/src/App.test.js +14 -14
- package/src/MaterialsCloudHeader/Breadcrumbs.css +101 -101
- package/src/MaterialsCloudHeader/Breadcrumbs.js +19 -19
- package/src/MaterialsCloudHeader/Navbar.css +129 -129
- package/src/MaterialsCloudHeader/Navbar.js +131 -131
- package/src/MaterialsCloudHeader/index.css +14 -15
- package/src/MaterialsCloudHeader/index.js +25 -25
- package/src/index.css +13 -13
- package/src/index.js +18 -18
- package/src/reportWebVitals.js +13 -13
- package/src/setupTests.js +5 -5
|
@@ -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:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
margin:
|
|
10
|
-
margin-
|
|
11
|
-
|
|
12
|
-
padding:
|
|
13
|
-
|
|
14
|
-
|
|
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;
|
package/src/index.css
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
body {
|
|
2
|
-
margin: 0;
|
|
3
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
-
sans-serif;
|
|
6
|
-
-webkit-font-smoothing: antialiased;
|
|
7
|
-
-moz-osx-font-smoothing: grayscale;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
code {
|
|
11
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
12
|
-
monospace;
|
|
13
|
-
}
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
+
sans-serif;
|
|
6
|
+
-webkit-font-smoothing: antialiased;
|
|
7
|
+
-moz-osx-font-smoothing: grayscale;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
code {
|
|
11
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
12
|
+
monospace;
|
|
13
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ReactDOM from "react-dom/client";
|
|
3
|
-
import "./index.css";
|
|
4
|
-
import App from "./App";
|
|
5
|
-
import reportWebVitals from "./reportWebVitals";
|
|
6
|
-
|
|
7
|
-
const root = ReactDOM.createRoot(document.getElementById("root"));
|
|
8
|
-
document.body.style = "background: white;";
|
|
9
|
-
root.render(
|
|
10
|
-
<React.StrictMode>
|
|
11
|
-
<App />
|
|
12
|
-
</React.StrictMode>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
// If you want to start measuring performance in your app, pass a function
|
|
16
|
-
// to log results (for example: reportWebVitals(console.log))
|
|
17
|
-
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
18
|
-
reportWebVitals();
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom/client";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
import App from "./App";
|
|
5
|
+
import reportWebVitals from "./reportWebVitals";
|
|
6
|
+
|
|
7
|
+
const root = ReactDOM.createRoot(document.getElementById("root"));
|
|
8
|
+
document.body.style = "background: white;";
|
|
9
|
+
root.render(
|
|
10
|
+
<React.StrictMode>
|
|
11
|
+
<App />
|
|
12
|
+
</React.StrictMode>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
// If you want to start measuring performance in your app, pass a function
|
|
16
|
+
// to log results (for example: reportWebVitals(console.log))
|
|
17
|
+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
18
|
+
reportWebVitals();
|
package/src/reportWebVitals.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const reportWebVitals = onPerfEntry => {
|
|
2
|
-
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
3
|
-
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
4
|
-
getCLS(onPerfEntry);
|
|
5
|
-
getFID(onPerfEntry);
|
|
6
|
-
getFCP(onPerfEntry);
|
|
7
|
-
getLCP(onPerfEntry);
|
|
8
|
-
getTTFB(onPerfEntry);
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default reportWebVitals;
|
|
1
|
+
const reportWebVitals = onPerfEntry => {
|
|
2
|
+
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
3
|
+
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
4
|
+
getCLS(onPerfEntry);
|
|
5
|
+
getFID(onPerfEntry);
|
|
6
|
+
getFCP(onPerfEntry);
|
|
7
|
+
getLCP(onPerfEntry);
|
|
8
|
+
getTTFB(onPerfEntry);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default reportWebVitals;
|
package/src/setupTests.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
|
2
|
-
// allows you to do things like:
|
|
3
|
-
// expect(element).toHaveTextContent(/react/i)
|
|
4
|
-
// learn more: https://github.com/testing-library/jest-dom
|
|
5
|
-
import '@testing-library/jest-dom';
|
|
1
|
+
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
|
2
|
+
// allows you to do things like:
|
|
3
|
+
// expect(element).toHaveTextContent(/react/i)
|
|
4
|
+
// learn more: https://github.com/testing-library/jest-dom
|
|
5
|
+
import '@testing-library/jest-dom';
|