PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.1.5
Tableberg – Simple Gutenberg Table Block v1.1.5
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / admin / src / components / Navigation.jsx

Navigation.jsx in Tableberg – Simple Gutenberg Table Block 1.1.5, at admin/src/components/Navigation.jsx

48 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useEffect, useState } from "react";
2 import Route from "../inc/Route";
3 import NavigationHeaderButton from "./NavigationHeaderButton";
4
5 /**
6 * Navigation component.
7 *
8 * @param {Object} props component properties
9 * @param {Array<Route>} props.routes routes array
10 * @param {string | null} props.currentRoutePath current route path
11 * @param {Function} props.setRoute set route path
12 * @class
13 */
14 function Navigation({ routes, currentRoutePath, setRoute }) {
15 const [calculatedStyle, setCalculatedStyles] = useState({});
16
17 /**
18 * useEffect hook.
19 */
20 useEffect(() => {
21 const style = {
22 gridTemplateColumns: `repeat(${routes.length}, minmax(0,1fr))`,
23 };
24 setCalculatedStyles(style);
25 }, [routes]);
26
27 return (
28 <div style={calculatedStyle} className={"tableberg-menu-navigation"}>
29 {routes.map(routeObj => {
30 return (
31 <NavigationHeaderButton
32 key={routeObj.getPath()}
33 title={routeObj.getTitle()}
34 targetPath={routeObj.getPath()}
35 isActive={currentRoutePath === routeObj.getPath()}
36 onClickHandler={setRoute}
37 />
38 );
39 })}
40 </div>
41 );
42 }
43
44 /**
45 * @module Navigation
46 */
47 export default Navigation;
48