Viewers icon indicating copy to clipboard operation
Viewers copied to clipboard

How Are The Toolbar Icons Generated?

Open mtm12 opened this issue 7 years ago • 2 comments

Hello,

In the previous version of the OHIF Stand Alone Viewer I created custom icons for two new buttons for custom functionality. The way the icons are generated has changed significantly in the current version (0.2.1). In the current version, where are the icons stored and how are they built into the toolbar?

Thank you, Marc

mtm12 avatar Aug 16 '19 15:08 mtm12

In the monorepo version, the icons are located at \platform\ui\src\elements\Icon\icons To create a custom icon:

  1. store svg file in \platform\ui\src\elements\Icon\icons
  2. import icon file into \platform\ui\src\elements\Icon\getIcon.js
  3. add import to ICONS const in \platform\ui\src\elements\Icon\getIcon.js
  4. specify new icon to use for button in \extensions\cornerstone\src\toolbarModules.js
  5. restart app

mtm12 avatar Aug 20 '19 17:08 mtm12

FWIW, this works well if you don't mind maintaining a fork. A less conflict-prone solution could be updating the Toolbar module/config to allow the consumer to provide their own component to use in place of the Icon or ToolbarButton component. That component could be a simple React component that encapsulates an SVG.

That is something we plan on eventually supporting, and would be more than happy to review a PR for.

dannyrb avatar Aug 20 '19 17:08 dannyrb