mc-react-header 0.3.1 → 0.3.4
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 +1 -1
- package/dist/Breadcrumbs.css +1 -5
- package/dist/Breadcrumbs.js +9 -7
- package/dist/Navbar.css +0 -1
- package/dist/Navbar.js +69 -131
- package/dist/index.js +19 -40
- package/package.json +2 -2
- package/src/App.js +6 -1
- package/src/MaterialsCloudHeader/Breadcrumbs.css +1 -5
- package/src/MaterialsCloudHeader/Breadcrumbs.js +13 -15
- package/src/MaterialsCloudHeader/Navbar.css +0 -1
- package/src/MaterialsCloudHeader/Navbar.js +48 -74
- package/src/MaterialsCloudHeader/index.js +10 -18
package/dist/Breadcrumbs.css
CHANGED
|
@@ -6,7 +6,6 @@ ul.mc-breadcrumb {
|
|
|
6
6
|
border-radius: 2px;
|
|
7
7
|
border: 1px solid #d6d6d6;
|
|
8
8
|
font-size: 16px;
|
|
9
|
-
font-weight: 300;
|
|
10
9
|
font-family: "Open Sans", sans-serif;
|
|
11
10
|
text-align: left;
|
|
12
11
|
margin: 6px;
|
|
@@ -21,11 +20,10 @@ ul.mc-breadcrumb {
|
|
|
21
20
|
align-items: center;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
|
|
25
23
|
/* Display list items side by side */
|
|
26
24
|
ul.mc-breadcrumb li {
|
|
27
25
|
display: inline;
|
|
28
|
-
line-height: 1
|
|
26
|
+
line-height: 1;
|
|
29
27
|
margin-right: 46px;
|
|
30
28
|
position: relative;
|
|
31
29
|
}
|
|
@@ -40,7 +38,6 @@ ul.mc-breadcrumb li a {
|
|
|
40
38
|
/* z-index: 3; */
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
|
|
44
41
|
/* Add a color on mouse-over, if the <a> has href defined */
|
|
45
42
|
ul.mc-breadcrumb li a[href]:hover {
|
|
46
43
|
text-decoration: underline;
|
|
@@ -98,4 +95,3 @@ ul.mc-breadcrumb li a:not([href]):hover {
|
|
|
98
95
|
border: 0;
|
|
99
96
|
display: none;
|
|
100
97
|
}
|
|
101
|
-
|
package/dist/Breadcrumbs.js
CHANGED
|
@@ -4,19 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
7
|
require("./Breadcrumbs.css");
|
|
9
|
-
|
|
10
|
-
function
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const Breadcrumbs = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
breadcrumbsPath
|
|
13
|
+
} = _ref;
|
|
11
14
|
return /*#__PURE__*/_react.default.createElement("ul", {
|
|
12
15
|
className: "mc-breadcrumb"
|
|
13
|
-
},
|
|
16
|
+
}, breadcrumbsPath.map((el, i) => {
|
|
14
17
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
15
18
|
key: i
|
|
16
19
|
}, /*#__PURE__*/_react.default.createElement("a", {
|
|
17
20
|
href: el.link
|
|
18
21
|
}, el.name));
|
|
19
22
|
}));
|
|
20
|
-
}
|
|
21
|
-
var _default = Breadcrumbs;
|
|
22
|
-
exports.default = _default;
|
|
23
|
+
};
|
|
24
|
+
var _default = exports.default = Breadcrumbs;
|
package/dist/Navbar.css
CHANGED
package/dist/Navbar.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
7
|
require("./Navbar.css");
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _mcloud_logo = _interopRequireDefault(require("./assets/mcloud_logo.png"));
|
|
10
10
|
require("font-awesome/css/font-awesome.min.css");
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
15
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
19
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
21
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
22
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
24
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
25
|
-
var mainSections = {
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
const mainSections = {
|
|
26
14
|
learn: {
|
|
27
15
|
name: "LEARN",
|
|
28
16
|
link: "https://www.materialscloud.org/learn"
|
|
@@ -44,7 +32,7 @@ var mainSections = {
|
|
|
44
32
|
link: "https://www.materialscloud.org/archive"
|
|
45
33
|
}
|
|
46
34
|
};
|
|
47
|
-
|
|
35
|
+
const dropdownSections = {
|
|
48
36
|
policies: {
|
|
49
37
|
name: "Policies",
|
|
50
38
|
link: "https://www.materialscloud.org/policies"
|
|
@@ -74,119 +62,69 @@ var dropdownSections = {
|
|
|
74
62
|
link: "https://www.materialscloud.org/explore/connect"
|
|
75
63
|
}
|
|
76
64
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
_this.toggleDropdown = _this.toggleDropdown.bind(_assertThisInitialized(_this));
|
|
88
|
-
_this.setWrapperRef = _this.setWrapperRef.bind(_assertThisInitialized(_this));
|
|
89
|
-
_this.handleClickOutside = _this.handleClickOutside.bind(_assertThisInitialized(_this));
|
|
90
|
-
return _this;
|
|
91
|
-
}
|
|
92
|
-
_createClass(DropdownMenu, [{
|
|
93
|
-
key: "componentDidMount",
|
|
94
|
-
value: function componentDidMount() {
|
|
95
|
-
document.addEventListener("mousedown", this.handleClickOutside);
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "componentWillUnmount",
|
|
99
|
-
value: function componentWillUnmount() {
|
|
100
|
-
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
101
|
-
}
|
|
102
|
-
}, {
|
|
103
|
-
key: "setWrapperRef",
|
|
104
|
-
value: function setWrapperRef(node) {
|
|
105
|
-
this.wrapperRef = node;
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
key: "handleClickOutside",
|
|
109
|
-
value: function handleClickOutside(event) {
|
|
110
|
-
if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {
|
|
111
|
-
if (this.state.dropdownOpen) {
|
|
112
|
-
this.setState({
|
|
113
|
-
dropdownOpen: false
|
|
114
|
-
});
|
|
115
|
-
}
|
|
65
|
+
const DropdownMenu = _ref => {
|
|
66
|
+
let {
|
|
67
|
+
activeSection
|
|
68
|
+
} = _ref;
|
|
69
|
+
const [dropdownOpen, setDropdownOpen] = (0, _react.useState)(false);
|
|
70
|
+
const wrapperRef = (0, _react.useRef)(null);
|
|
71
|
+
(0, _react.useEffect)(() => {
|
|
72
|
+
function handleClickOutside(event) {
|
|
73
|
+
if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
|
|
74
|
+
setDropdownOpen(false);
|
|
116
75
|
}
|
|
117
76
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
173
|
-
src: _mcloud_logo.default,
|
|
174
|
-
height: "50",
|
|
175
|
-
alt: "MC logo"
|
|
176
|
-
})), Object.keys(mainSections).map(function (key, i) {
|
|
177
|
-
var cname = "mc-navlink";
|
|
178
|
-
if (key == _this3.props.activeSection) cname += " active";
|
|
179
|
-
return /*#__PURE__*/_react.default.createElement("a", {
|
|
180
|
-
key: i,
|
|
181
|
-
className: cname,
|
|
182
|
-
href: mainSections[key].link
|
|
183
|
-
}, mainSections[key].name);
|
|
184
|
-
}), /*#__PURE__*/_react.default.createElement(DropdownMenu, {
|
|
185
|
-
activeSection: this.props.activeSection
|
|
186
|
-
}));
|
|
187
|
-
}
|
|
188
|
-
}]);
|
|
189
|
-
return Navbar;
|
|
190
|
-
}(_react.default.Component);
|
|
191
|
-
var _default = Navbar;
|
|
192
|
-
exports.default = _default;
|
|
77
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
78
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
79
|
+
}, []);
|
|
80
|
+
const toggleDropdown = () => setDropdownOpen(prev => !prev);
|
|
81
|
+
const dropdownContentClass = "dropdown-content" + (dropdownOpen ? " dropdown-open" : "");
|
|
82
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
83
|
+
ref: wrapperRef,
|
|
84
|
+
className: "more-dropdown"
|
|
85
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
86
|
+
className: "more-btn",
|
|
87
|
+
onClick: toggleDropdown
|
|
88
|
+
}, "More ", /*#__PURE__*/_react.default.createElement("i", {
|
|
89
|
+
className: "fa fa-caret-down"
|
|
90
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
91
|
+
className: dropdownContentClass
|
|
92
|
+
}, Object.keys(dropdownSections).map((element, i) => {
|
|
93
|
+
const {
|
|
94
|
+
link,
|
|
95
|
+
name
|
|
96
|
+
} = dropdownSections[element];
|
|
97
|
+
const cname = element === activeSection ? "active" : "";
|
|
98
|
+
return /*#__PURE__*/_react.default.createElement("a", {
|
|
99
|
+
key: i,
|
|
100
|
+
className: cname,
|
|
101
|
+
href: link
|
|
102
|
+
}, name);
|
|
103
|
+
})));
|
|
104
|
+
};
|
|
105
|
+
const Navbar = _ref2 => {
|
|
106
|
+
let {
|
|
107
|
+
activeSection
|
|
108
|
+
} = _ref2;
|
|
109
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
110
|
+
className: "mc-navbar"
|
|
111
|
+
}, /*#__PURE__*/_react.default.createElement("a", {
|
|
112
|
+
className: "mc-navbrand",
|
|
113
|
+
href: "https://www.materialscloud.org/home"
|
|
114
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
115
|
+
src: _mcloud_logo.default,
|
|
116
|
+
height: "50",
|
|
117
|
+
alt: "MC logo"
|
|
118
|
+
})), Object.keys(mainSections).map((key, i) => {
|
|
119
|
+
let cname = "mc-navlink";
|
|
120
|
+
if (key === activeSection) cname += " active";
|
|
121
|
+
return /*#__PURE__*/_react.default.createElement("a", {
|
|
122
|
+
key: i,
|
|
123
|
+
className: cname,
|
|
124
|
+
href: mainSections[key].link
|
|
125
|
+
}, mainSections[key].name);
|
|
126
|
+
}), /*#__PURE__*/_react.default.createElement(DropdownMenu, {
|
|
127
|
+
activeSection: activeSection
|
|
128
|
+
}));
|
|
129
|
+
};
|
|
130
|
+
var _default = exports.default = Navbar;
|
package/dist/index.js
CHANGED
|
@@ -1,49 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
7
|
require("./index.css");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
9
|
var _Navbar = _interopRequireDefault(require("./Navbar"));
|
|
11
10
|
var _Breadcrumbs = _interopRequireDefault(require("./Breadcrumbs"));
|
|
12
|
-
function _interopRequireDefault(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return _super.call(this, props);
|
|
31
|
-
}
|
|
32
|
-
_createClass(MaterialsCloudHeader, [{
|
|
33
|
-
key: "render",
|
|
34
|
-
value: function render() {
|
|
35
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
36
|
-
className: "main-container"
|
|
37
|
-
}, /*#__PURE__*/_react.default.createElement(_Navbar.default, {
|
|
38
|
-
activeSection: this.props.activeSection
|
|
39
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
40
|
-
className: "content-container"
|
|
41
|
-
}, /*#__PURE__*/_react.default.createElement(_Breadcrumbs.default, {
|
|
42
|
-
breadcrumbsPath: this.props.breadcrumbsPath
|
|
43
|
-
}), this.props.children));
|
|
44
|
-
}
|
|
45
|
-
}]);
|
|
46
|
-
return MaterialsCloudHeader;
|
|
47
|
-
}(_react.default.Component);
|
|
48
|
-
var _default = MaterialsCloudHeader;
|
|
49
|
-
exports.default = _default;
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const MaterialsCloudHeader = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
activeSection,
|
|
15
|
+
breadcrumbsPath,
|
|
16
|
+
children
|
|
17
|
+
} = _ref;
|
|
18
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
19
|
+
className: "main-container"
|
|
20
|
+
}, /*#__PURE__*/_react.default.createElement(_Navbar.default, {
|
|
21
|
+
activeSection: activeSection
|
|
22
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
23
|
+
className: "content-container"
|
|
24
|
+
}, /*#__PURE__*/_react.default.createElement(_Breadcrumbs.default, {
|
|
25
|
+
breadcrumbsPath: breadcrumbsPath
|
|
26
|
+
}), children));
|
|
27
|
+
};
|
|
28
|
+
var _default = exports.default = MaterialsCloudHeader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mc-react-header",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"author": "Kristjan Eimre <kristjan.eimre@epfl.ch>",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"font-awesome": "^4.7.0",
|
|
18
18
|
"react": "^18.2.0",
|
|
19
19
|
"react-dom": "^18.2.0",
|
|
20
|
-
"react-scripts": "5.0.1",
|
|
20
|
+
"react-scripts": "^5.0.1",
|
|
21
21
|
"web-vitals": "^2.1.4"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
package/src/App.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "./App.css";
|
|
2
2
|
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
3
5
|
import MaterialsCloudHeader from "./MaterialsCloudHeader";
|
|
4
6
|
|
|
5
7
|
function App() {
|
|
@@ -9,7 +11,10 @@ function App() {
|
|
|
9
11
|
activeSection={"discover"} // see the corresponding key in MaterialsCloudHeader/Navbar.js
|
|
10
12
|
breadcrumbsPath={[
|
|
11
13
|
{ name: "Discover", link: "https://www.materialscloud.org/discover" },
|
|
12
|
-
{
|
|
14
|
+
{
|
|
15
|
+
name: "Materials Cloud three-dimensional crystals database",
|
|
16
|
+
link: "https://www.materialscloud.org/discover/mc3d",
|
|
17
|
+
},
|
|
13
18
|
{ name: "test", link: null },
|
|
14
19
|
]}
|
|
15
20
|
>
|
|
@@ -6,7 +6,6 @@ ul.mc-breadcrumb {
|
|
|
6
6
|
border-radius: 2px;
|
|
7
7
|
border: 1px solid #d6d6d6;
|
|
8
8
|
font-size: 16px;
|
|
9
|
-
font-weight: 300;
|
|
10
9
|
font-family: "Open Sans", sans-serif;
|
|
11
10
|
text-align: left;
|
|
12
11
|
margin: 6px;
|
|
@@ -21,11 +20,10 @@ ul.mc-breadcrumb {
|
|
|
21
20
|
align-items: center;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
|
|
25
23
|
/* Display list items side by side */
|
|
26
24
|
ul.mc-breadcrumb li {
|
|
27
25
|
display: inline;
|
|
28
|
-
line-height: 1
|
|
26
|
+
line-height: 1;
|
|
29
27
|
margin-right: 46px;
|
|
30
28
|
position: relative;
|
|
31
29
|
}
|
|
@@ -40,7 +38,6 @@ ul.mc-breadcrumb li a {
|
|
|
40
38
|
/* z-index: 3; */
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
|
|
44
41
|
/* Add a color on mouse-over, if the <a> has href defined */
|
|
45
42
|
ul.mc-breadcrumb li a[href]:hover {
|
|
46
43
|
text-decoration: underline;
|
|
@@ -98,4 +95,3 @@ ul.mc-breadcrumb li a:not([href]):hover {
|
|
|
98
95
|
border: 0;
|
|
99
96
|
display: none;
|
|
100
97
|
}
|
|
101
|
-
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
1
|
import "./Breadcrumbs.css";
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
const Breadcrumbs = ({ breadcrumbsPath }) => (
|
|
6
|
+
<ul className="mc-breadcrumb">
|
|
7
|
+
{breadcrumbsPath.map((el, i) => {
|
|
8
|
+
return (
|
|
9
|
+
<li key={i}>
|
|
10
|
+
<a href={el.link}>{el.name}</a>
|
|
11
|
+
</li>
|
|
12
|
+
);
|
|
13
|
+
})}
|
|
14
|
+
</ul>
|
|
15
|
+
);
|
|
18
16
|
|
|
19
17
|
export default Breadcrumbs;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import "./Navbar.css";
|
|
2
2
|
|
|
3
|
+
import React from "react";
|
|
3
4
|
import Logo from "./assets/mcloud_logo.png";
|
|
4
5
|
|
|
5
6
|
import "font-awesome/css/font-awesome.min.css";
|
|
6
|
-
import
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
7
8
|
|
|
8
9
|
const mainSections = {
|
|
9
10
|
learn: { name: "LEARN", link: "https://www.materialscloud.org/learn" },
|
|
@@ -44,88 +45,61 @@ const dropdownSections = {
|
|
|
44
45
|
},
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
}
|
|
48
|
+
const DropdownMenu = ({ activeSection }) => {
|
|
49
|
+
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
50
|
+
const wrapperRef = useRef(null);
|
|
63
51
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
handleClickOutside(event) {
|
|
69
|
-
if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {
|
|
70
|
-
if (this.state.dropdownOpen) {
|
|
71
|
-
this.setState({ dropdownOpen: false });
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
function handleClickOutside(event) {
|
|
54
|
+
if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
|
|
55
|
+
setDropdownOpen(false);
|
|
72
56
|
}
|
|
73
57
|
}
|
|
74
|
-
|
|
58
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
59
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
60
|
+
}, []);
|
|
75
61
|
|
|
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
|
-
}
|
|
62
|
+
const toggleDropdown = () => setDropdownOpen((prev) => !prev);
|
|
108
63
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
64
|
+
const dropdownContentClass =
|
|
65
|
+
"dropdown-content" + (dropdownOpen ? " dropdown-open" : "");
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div ref={wrapperRef} className="more-dropdown">
|
|
69
|
+
<span className="more-btn" onClick={toggleDropdown}>
|
|
70
|
+
More <i className="fa fa-caret-down" />
|
|
71
|
+
</span>
|
|
72
|
+
<div className={dropdownContentClass}>
|
|
73
|
+
{Object.keys(dropdownSections).map((element, i) => {
|
|
74
|
+
const { link, name } = dropdownSections[element];
|
|
75
|
+
const cname = element === activeSection ? "active" : "";
|
|
119
76
|
return (
|
|
120
|
-
<a key={i} className={cname} href={
|
|
121
|
-
{
|
|
77
|
+
<a key={i} className={cname} href={link}>
|
|
78
|
+
{name}
|
|
122
79
|
</a>
|
|
123
80
|
);
|
|
124
81
|
})}
|
|
125
|
-
<DropdownMenu activeSection={this.props.activeSection} />
|
|
126
82
|
</div>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const Navbar = ({ activeSection }) => (
|
|
88
|
+
<div className="mc-navbar">
|
|
89
|
+
<a className="mc-navbrand" href="https://www.materialscloud.org/home">
|
|
90
|
+
<img src={Logo} height="50" alt="MC logo" />
|
|
91
|
+
</a>
|
|
92
|
+
{Object.keys(mainSections).map((key, i) => {
|
|
93
|
+
let cname = "mc-navlink";
|
|
94
|
+
if (key === activeSection) cname += " active";
|
|
95
|
+
return (
|
|
96
|
+
<a key={i} className={cname} href={mainSections[key].link}>
|
|
97
|
+
{mainSections[key].name}
|
|
98
|
+
</a>
|
|
99
|
+
);
|
|
100
|
+
})}
|
|
101
|
+
<DropdownMenu activeSection={activeSection} />
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
130
104
|
|
|
131
105
|
export default Navbar;
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import "./index.css";
|
|
3
2
|
|
|
3
|
+
import React from "react";
|
|
4
4
|
import Navbar from "./Navbar";
|
|
5
5
|
import Breadcrumbs from "./Breadcrumbs";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<div className="content-container">
|
|
17
|
-
<Breadcrumbs breadcrumbsPath={this.props.breadcrumbsPath} />
|
|
18
|
-
{this.props.children}
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
7
|
+
const MaterialsCloudHeader = ({ activeSection, breadcrumbsPath, children }) => (
|
|
8
|
+
<div className="main-container">
|
|
9
|
+
<Navbar activeSection={activeSection} />
|
|
10
|
+
<div className="content-container">
|
|
11
|
+
<Breadcrumbs breadcrumbsPath={breadcrumbsPath} />
|
|
12
|
+
{children}
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
24
16
|
|
|
25
17
|
export default MaterialsCloudHeader;
|