-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
O3-578: Left Nav Page section is not highlighted correctly. #721
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
import React from 'react'; | ||
import React, { useMemo } from 'react'; | ||
import { last } from 'lodash'; | ||
|
||
import { ConfigurableLink } from '@openmrs/esm-framework'; | ||
import styles from './dashboardextension.scss'; | ||
|
||
export interface DashboardExtensionProps { | ||
title: string; | ||
basePath: string; | ||
currentPath: string; | ||
} | ||
|
||
export const DashboardExtension = ({ title, basePath }: DashboardExtensionProps) => { | ||
export const DashboardExtension = ({ title, basePath, currentPath }: DashboardExtensionProps) => { | ||
const navLink = useMemo(() => decodeURIComponent(last(currentPath.split('/'))), [currentPath]); | ||
|
||
const activeClassName = title === navLink ? 'active-left-nav-link' : 'non-active'; | ||
|
||
return ( | ||
<div key={title}> | ||
<ConfigurableLink to={`${basePath}/${encodeURIComponent(title)}`} className="bx--side-nav__link"> | ||
<div key={title} className={activeClassName}> | ||
<ConfigurableLink to={`${basePath}/${encodeURIComponent(title)}`} className={'bx--side-nav__link ' + styles.link}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'm missing something? Currently that styles file doesn't have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's there in the styles maybe you had not refreshed. |
||
{title} | ||
</ConfigurableLink> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@import "~@openmrs/esm-styleguide/src/vars"; | ||
@import "~carbon-components/src/globals/scss/vars"; | ||
@import "~carbon-components/src/globals/scss/mixins"; | ||
|
||
:global(.active-left-nav-link) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we want left-nav to be a site-wide convention this should really go in core. Another good indicator of this is the use of the global tag. If we really are making a new global convention it should probably exist somewhere in styleguide. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The global tag is in the core but I wanted to emphasize some styles on a link for when there is an active class, so I called the global class here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the point remains though. Because the style is only affecting patient-chart a left nav link used in outpatient app will have a different styling... Or am I missing something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I am not understanding what you are meaning we should have a call about it, but I will merge it for now. |
||
background-color: $ui-03; | ||
outline: none; | ||
color: $ui-05; | ||
border-left: 4px solid var(--brand-01); | ||
.link:nth-child(1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ZacButko this is the link class that I was referring to. |
||
color: $ui-05; | ||
padding: 1.2rem 0 1.2rem 1.2rem; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be good to move into its own hook. probably after the react-router v6 upgrade