Skip to content
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

Merged
merged 4 commits into from
Jun 27, 2022

Conversation

hadijahkyampeire
Copy link
Contributor

Requirements

  • This PR has a title that briefly describes the work done, including the ticket number if there is a ticket.
  • My work conforms to the OpenMRS 3.0 Styleguide.
  • My work includes tests or is validated by existing tests.

Summary

  • Use location from react-router to detect the active nav link and apply the necessary styles.

Screenshots

Screenshot 2022-06-17 at 01 41 38

Related Issue

Other

  • Video
sidenavActiveLink.mov

Copy link
Contributor

@ZacButko ZacButko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good enough to merge. A minimum ask is to remove the use of important flag. The other ask is harder, but will potentially reduce some memory use.

Thanks for this work :) Exciting to finally have this working again!

Use location from react-router
remove the overriding
styles from core
Copy link
Contributor

@ZacButko ZacButko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to move the styling of dashboard links into styleguide so they can be used even when patient-chart is not loaded? Or do you have some different idea here?

@import "~carbon-components/src/globals/scss/vars";
@import "~carbon-components/src/globals/scss/mixins";

:global(.active-left-nav-link) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

}

export const DashboardExtension = ({ title, basePath }: DashboardExtensionProps) => {
export const DashboardExtension = ({ title, basePath, currentPath }: DashboardExtensionProps) => {
const navLink = useMemo(() => decodeURIComponent(last(currentPath.split('/'))), [currentPath]);
Copy link
Contributor

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

<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}>
Copy link
Contributor

Choose a reason for hiding this comment

The 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 link class name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's there in the styles maybe you had not refreshed.

outline: none;
color: $ui-05;
border-left: 4px solid var(--brand-01);
.link:nth-child(1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZacButko this is the link class that I was referring to.

@hadijahkyampeire hadijahkyampeire merged commit d8625ae into master Jun 27, 2022
@hadijahkyampeire hadijahkyampeire deleted the hadijah/O3-578 branch June 27, 2022 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants