Skip to content

Commit

Permalink
add submenu items for overview page for places without subtopics pages (
Browse files Browse the repository at this point in the history
#606)

Co-authored-by: beets <[email protected]>
  • Loading branch information
chejennifer and beets authored Oct 15, 2020
1 parent a6c4f0b commit d1390b0
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions static/js/place/topic_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ class MenuCategory extends React.Component<MenuCategoryPropsType, unknown> {
const selectCategory = this.props.selectCategory;
const category = this.props.category;
const topics = this.props.topics;
const hrefString =
category === "Overview"
? `/place/${dcid}`
: `/place/${dcid}?topic=${category}`;

return (
<li className="nav-item">
<a
href={`/place/${dcid}?topic=${category}`}
href={hrefString}
className={`nav-link ${selectCategory === category ? "active" : ""}`}
>
{category}
Expand All @@ -49,10 +53,7 @@ class MenuCategory extends React.Component<MenuCategoryPropsType, unknown> {
{topics.map((topic: string) => {
return (
<li className="nav-item" key={topic}>
<a
href={`/place/${dcid}?topic=${category}#${topic}`}
className="nav-link"
>
<a href={`${hrefString}#${topic}`} className="nav-link">
{topic}
</a>
</li>
Expand All @@ -76,19 +77,22 @@ class Menu extends React.Component<MenuPropsType, unknown> {
const dcid = this.props.dcid;
const topic = this.props.topic;
const categories = Object.keys(this.props.pageChart);
const showOverviewSubmenu = categories.length === 1;
return (
<ul id="nav-topics" className="nav flex-column accordion">
<li className="nav-item">
<a
href={`/place/${dcid}`}
className={`nav-link ${!topic ? "active" : ""}`}
>
Overview
</a>
</li>
{showOverviewSubmenu ? null : (
<li className="nav-item">
<a
href={`/place/${dcid}`}
className={`nav-link ${!topic ? "active" : ""}`}
>
Overview
</a>
</li>
)}
{categories.map((category: string) => {
const topics = Object.keys(this.props.pageChart[category]);
if (category !== "Overview") {
if (showOverviewSubmenu || category !== "Overview") {
return (
<MenuCategory
key={category}
Expand Down

0 comments on commit d1390b0

Please sign in to comment.