mc-react-header 0.2.1 → 0.3.3
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 +97 -101
- package/dist/Breadcrumbs.js +11 -11
- package/dist/Navbar.css +128 -129
- package/dist/Navbar.js +69 -132
- package/dist/index.css +14 -15
- package/dist/index.js +19 -41
- 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 +97 -101
- package/src/MaterialsCloudHeader/Breadcrumbs.js +15 -19
- package/src/MaterialsCloudHeader/Navbar.css +128 -129
- package/src/MaterialsCloudHeader/Navbar.js +104 -131
- package/src/MaterialsCloudHeader/index.css +14 -15
- package/src/MaterialsCloudHeader/index.js +16 -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,104 @@
|
|
|
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
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
document.addEventListener("mousedown",
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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 { useEffect, useRef, useState } 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
|
+
const DropdownMenu = ({ activeSection }) => {
|
|
48
|
+
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
49
|
+
const wrapperRef = useRef(null);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
function handleClickOutside(event) {
|
|
53
|
+
if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
|
|
54
|
+
setDropdownOpen(false);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
58
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
const toggleDropdown = () => setDropdownOpen((prev) => !prev);
|
|
62
|
+
|
|
63
|
+
const dropdownContentClass =
|
|
64
|
+
"dropdown-content" + (dropdownOpen ? " dropdown-open" : "");
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div ref={wrapperRef} className="more-dropdown">
|
|
68
|
+
<span className="more-btn" onClick={toggleDropdown}>
|
|
69
|
+
More <i className="fa fa-caret-down" />
|
|
70
|
+
</span>
|
|
71
|
+
<div className={dropdownContentClass}>
|
|
72
|
+
{Object.keys(dropdownSections).map((element, i) => {
|
|
73
|
+
const { link, name } = dropdownSections[element];
|
|
74
|
+
const cname = element === activeSection ? "active" : "";
|
|
75
|
+
return (
|
|
76
|
+
<a key={i} className={cname} href={link}>
|
|
77
|
+
{name}
|
|
78
|
+
</a>
|
|
79
|
+
);
|
|
80
|
+
})}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const Navbar = ({ activeSection }) => (
|
|
87
|
+
<div className="mc-navbar">
|
|
88
|
+
<a className="mc-navbrand" href="https://www.materialscloud.org/home">
|
|
89
|
+
<img src={Logo} height="50" alt="MC logo" />
|
|
90
|
+
</a>
|
|
91
|
+
{Object.keys(mainSections).map((key, i) => {
|
|
92
|
+
let cname = "mc-navlink";
|
|
93
|
+
if (key === activeSection) cname += " active";
|
|
94
|
+
return (
|
|
95
|
+
<a key={i} className={cname} href={mainSections[key].link}>
|
|
96
|
+
{mainSections[key].name}
|
|
97
|
+
</a>
|
|
98
|
+
);
|
|
99
|
+
})}
|
|
100
|
+
<DropdownMenu activeSection={activeSection} />
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
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,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<Breadcrumbs breadcrumbsPath={this.props.breadcrumbsPath} />
|
|
18
|
-
{this.props.children}
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default MaterialsCloudHeader;
|
|
1
|
+
import "./index.css";
|
|
2
|
+
|
|
3
|
+
import Navbar from "./Navbar";
|
|
4
|
+
import Breadcrumbs from "./Breadcrumbs";
|
|
5
|
+
|
|
6
|
+
const MaterialsCloudHeader = ({ activeSection, breadcrumbsPath, children }) => (
|
|
7
|
+
<div className="main-container">
|
|
8
|
+
<Navbar activeSection={activeSection} />
|
|
9
|
+
<div className="content-container">
|
|
10
|
+
<Breadcrumbs breadcrumbsPath={breadcrumbsPath} />
|
|
11
|
+
{children}
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
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';
|