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

(Feat) O3-2801 Icons across O3 Navigation MVP #2121

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Munyua123
Copy link

@Munyua123 Munyua123 commented Nov 28, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

Screenshots

Screenshot from 2024-11-28 14-05-54

Related Issue

https://openmrs.atlassian.net/browse/O3-2801

Other

@Munyua123 Munyua123 changed the title O3-2801 Icons across O3 Navigation MVP (Feat) O3-2801 Icons across O3 Navigation MVP Nov 28, 2024
@Munyua123
Copy link
Author

@denniskigen @gracepotma @CynthiaKamau I have made the changes. I had a problem with the last pull request with the build but this one should work just fine. KIndly review

@gracepotma
Copy link
Contributor

Asante SANA @Munyua123!! LGTM <3

Copy link
Member

@ibacher ibacher left a comment

Choose a reason for hiding this comment

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

Nice work! Some minor nits and a redesign suggestion.

Comment on lines +40 to +60
type MenuTitle = keyof typeof MenuIcons;

const MenuIcons = {
'Patient Summary': ReportIcon,
'Vitals & Biometrics': ActivityIcon,
Medications: MedicationIcon,
Orders: ShoppingCartIcon,
Results: ChartAverageIcon,
Visits: CalendarHeatMapIcon,
Allergies: WarningIcon,
Conditions: ListCheckedIcon,
Immunizations: SyringeIcon,
Attachments: DocumentAttachmentIcon,
Programs: ProgramsIcon,
Appointments: EventScheduleIcon,
} as const;

const menuIcon = (title: MenuTitle) => {
const Icon = MenuIcons[title];
return Icon ? <Icon className={styles.icon} /> : null;
};
Copy link
Member

Choose a reason for hiding this comment

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

There's no good reason for these to be located inside this component. They would be better located outside of it.

Copy link
Member

Choose a reason for hiding this comment

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

Honestly, though, I think this might not be the right way to design things. This works, but only for providing icons for known menu titles, which is bad for extensibility. Better would be to update the DashboardExtensionProps to take a string of the name icon and just render it like:

document.getElementById(`omrs-icon-${icon}`) ? <Icon className={styles.icon} icon={`omrs-icon-${icon}`} /> : null;

return Icon ? <Icon className={styles.icon} /> : null;
};

const renderIcon = menuIcon(title as MenuTitle);
Copy link
Member

Choose a reason for hiding this comment

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

No weird edge-cases and we don't have to lie to TypeScript:

Suggested change
const renderIcon = menuIcon(title as MenuTitle);
const renderIcon = Object.keys(MenuIcons).includes(title) ? menuIcon(title) : null;

@@ -0,0 +1,8 @@
.menu {
display: flex;
align-items: center;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think centering is the right option here. The items should flex from the start regardless of the width of the container.

Suggested change
align-items: center;
align-items: start;

}

.icon {
margin-right: 0.5rem;
Copy link
Member

Choose a reason for hiding this comment

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

Please use the Carbon spacing tokens for things like this (use @carbon/layout; margin: layout.$spacing-03;

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