-
Notifications
You must be signed in to change notification settings - Fork 184
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) Add CarbonMRS icon infrastructure and React components #969
Conversation
Size Change: -624 kB (-15.29%) 👏 Total Size: 3.46 MB
ℹ️ View Unchanged
|
Seems like it would be great if we could avoid it, right? Even if all the icons shared their own bundle that would seem to be better than having them in openmrs.js.
Yes, I think they do. |
12d46a0
to
40954af
Compare
Alright, my impression is the e2e test failures here are unavoidable because of how the Docker image used here is constructed. That's because this PR introduces several new components into the styleguide, which are now used by all apps, but the Dockerfile is built using the published version of the app shell, and so those components are not present. That should be fixed, but I'm going to mark this as ready for review. |
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.
LGTM, @ibacher. Very well implemented.
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.
We can probably remove this file.
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.
Once an SVG is added, yes. Grace wanted to turn this stuff into tickets for newbies, so I was aiming to ensure that the /svgs/
folder is present here to make things easier (that's also why the instructions are in really painful detail).
@denniskigen Huh! I anticipated the shrinking in the apps themselves, since we no longer depend on However, the icons I added don't consume much more space than they did before, despite having almost twice as many: The React components are much more heavy-weight: But it seems that adding the svgo-loader, which optimizes SVGs, made a huge amount of savings in the size of the logo: So... yeah, this looks legit to me... |
You're seeing exactly what you should be seeing. All the icon files are current just that placeholder image. I reverted things back to where it was initially, which was before we had any of the actual svgs in the design docs. |
I made some slight adjustments to this to try to reduce the chance of mistakenly importing the various SVGs, e.g., in Jest tests. This entailed some minor updates to the description of adding an icon or pictogram, which I've made above. |
@@ -97,12 +97,12 @@ const Workspace: React.FC<WorkspaceProps> = ({ workspaceInstance }) => { | |||
<div className={styles.headerContent}>{title}</div> | |||
<Button | |||
className={styles.closeButton} | |||
onClick={workspaceInstance?.closeWorkspace} | |||
onClick={() => workspaceInstance?.closeWorkspace} |
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 is not right; it causes the closeWorkspace function to be returned rather than executed. Fix #1011
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.
You're absolutely right, and that's an huge oversight on my part. Thanks for the catch! (I really did mean to have the extra ()
there).
Requirements
feat
,fix
, orchore
, among others). See existing PR titles for inspiration.For changes to apps
If applicable
Summary
This is a PR for implementing the CarbonMRS icon set and replacing most uses of the Carbon icons with custom icons; this PR only supplies icon placeholders. I've also added infrastructure to support pictograms, but no pictograms are added in this PR.
Screenshots
Related Issue
Other
NOTE Merging this will immediately make O3 ugly. That's because all the included SVGs are a placeholder, and I've swapped most of the uses of
@carbon/react/icons
for the framework-provided icons in the core app, so it currently looks like this:That's sort of intentional—I needed something to ensure the icons worked and it gives us a visual TODO list.
How to add an icon
addSvg()
in thesetupIcons()
function. TheaddSvg()
call consists of the icon identifier and the icon itself. The icon identifier is always the name of the icon prefixed withomrs-icon-
. For example,user-avatar
becomesomrs-icon-user-avatar
and theaddSvg()
call isaddSvg('omrs-icon-user-avatar', userAvatar);
The icon is now part of the framework. Now we need to add a React component for the icon. To do so open src/icons/icons.tsx in the styleguide and add a component that follows this template:
For example, the
user-avatar
icon is implemented like this:Finally, you want to add a mock for the component to the styleguide's
mock.tsx
file. This mock always looks like:E.g.,
And now you're done.
How to add a pictogram
Adding a pictogram follows the same process as for an icon, with the following modifications:
src/pictograms
folder of the styleguide instead of thesrc/icons
folder.omrs-pict-
instead ofomrs-icon-
.pictogram-registration.ts
instead oficon-registration.ts
pictograms.tsx
instead oficons.tsx
and looks like the following template: