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
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]);
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


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

{title}
</ConfigurableLink>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { DashboardLinkConfig } from '../types';
import { DashboardExtension } from './DashboardExtension';

export const createDashboardLink = (db: DashboardLinkConfig) => {
const Dashboard = ({ basePath }: { basePath: string }) => {
return <DashboardExtension title={db.title} basePath={basePath} />;
const Dashboard = ({ basePath, currentPath }: { basePath: string; currentPath: string }) => {
return <DashboardExtension title={db.title} basePath={basePath} currentPath={currentPath} />;
};
return Dashboard;
};
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) {
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.

background-color: $ui-03;
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.

color: $ui-05;
padding: 1.2rem 0 1.2rem 1.2rem;
}
}