Skip to content

Commit

Permalink
fix: refactored and removed mobile prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Cayla Hamann committed Jun 25, 2020
1 parent 63eca33 commit 0933aba
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
6 changes: 1 addition & 5 deletions src/components/MobileHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ const MobileHeader = ({ className, isOpen, toggle }) => {
onChange={(e) => setSearchTerm(e.target.value)}
value={searchTerm}
/>
<Navigation
mobile
searchTerm={searchTerm}
className={styles.navigation}
/>
<Navigation searchTerm={searchTerm} className={styles.navigation} />
</>
)}
</header>
Expand Down
3 changes: 1 addition & 2 deletions src/components/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const filterPageNames = (pages, searchTerm, parent = []) => {
].filter((el) => el !== undefined);
};

const Navigation = ({ className, searchTerm, mobile }) => {
const Navigation = ({ className, searchTerm }) => {
const searchTermSanitized = searchTerm?.replace(
/[.*+?^${}()|[\]\\]/g,
'\\$&'
Expand All @@ -50,7 +50,6 @@ const Navigation = ({ className, searchTerm, mobile }) => {
searchTerm={searchTermSanitized}
pages={pages}
filteredPageNames={filteredPageNames}
mobile={mobile}
/>
</ul>
</nav>
Expand Down
17 changes: 3 additions & 14 deletions src/components/NavigationItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const NavigationItems = ({
filteredPageNames,
searchTerm,
depthLevel = 0,
mobile,
}) => {
const groupedPages = pages.reduce((groups, page) => {
const { group = '' } = page;
Expand Down Expand Up @@ -53,21 +52,14 @@ const NavigationItems = ({
searchTerm={searchTerm}
filteredPageNames={filteredPageNames}
key={index}
mobile={mobile}
/>
))}
</Fragment>
);
});
};

const NavItem = ({
page,
depthLevel,
searchTerm,
filteredPageNames,
mobile,
}) => {
const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => {
const crumbs = useContext(BreadcrumbContext).flatMap((x) => x.displayName);
const isHomePage = crumbs.length === 0 && depthLevel === 0;

Expand Down Expand Up @@ -116,7 +108,7 @@ const NavItem = ({
{headerIcon}
{display}
</span>
{!mobile && isCurrentPage && (
{isCurrentPage && (
<FeatherIcon
className={styles.currentPageIndicator}
name="chevron-right"
Expand All @@ -131,7 +123,7 @@ const NavItem = ({
onKeyPress={() => setIsExpanded(!isExpanded)}
tabIndex={0}
>
{!mobile && depthLevel > 0 && (
{depthLevel > 0 && (
<FeatherIcon
className={cx(
{ [styles.isExpanded]: isExpanded },
Expand All @@ -155,7 +147,6 @@ const NavItem = ({
filteredPageNames={filteredPageNames}
depthLevel={depthLevel + 1}
searchTerm={searchTerm}
mobile={mobile}
/>
</ul>
)}
Expand All @@ -168,15 +159,13 @@ NavigationItems.propTypes = {
filteredPageNames: PropTypes.array,
searchTerm: PropTypes.string,
depthLevel: PropTypes.number,
mobile: PropTypes.bool,
};

NavItem.propTypes = {
page: link,
filteredPageNames: PropTypes.array,
searchTerm: PropTypes.string,
depthLevel: PropTypes.number.isRequired,
mobile: PropTypes.bool,
};

export default NavigationItems;
3 changes: 3 additions & 0 deletions src/components/NavigationItems.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ button.navLink {

.currentPageIndicator {
stroke-width: 4;
@media (min-width: 760px + 1) {
display: none;
}
}

.nestedChevron {
Expand Down

0 comments on commit 0933aba

Please sign in to comment.