Skip to content

Commit ea9674c

Browse files
authored
feat(#280): adds icon component with material desing icons (#384)
- Removes icomoon - Adds new dependency with Material Design icons `@mdi/js` - Adds a new icon component that imports Material Design icons, has variants, and sizes. - Our lint requires a two-word name for components. That's why the name is `IconSVG` - Replace all icons with the new component
1 parent ab3be86 commit ea9674c

28 files changed

+330
-1382
lines changed

.changeset/green-mirrors-teach.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@getodk/web-forms': patch
3+
---
4+
5+
Adds icon component with Material Design icons to replace Icomoon

packages/web-forms/README.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,16 @@ This package uses the Material Design system for the UI, though not strictly. Th
106106

107107
### Icons
108108

109-
We use **Material Icons** using IcoMoon to select a subset of icons in order to minimize the size. The font files are located in [`./src/assets/fonts/`](./src/assets/fonts/), and the CSS is [`./src/assets/css/icomoon.css`](/src/assets/css/icomoon.css). Our IcoMoon definition is in the root directory of this package at [`./icomoon.json`](./icomoon.json).
109+
The `IconSVG` component renders Material Design Icons (MDI) with customizable size and style variants. It uses the `@mdi/js` library for icon data and supports a predefined set of icons.
110110

111-
To update the icons using the [IcoMoon website](https://icomoon.io/app/):
111+
```js
112+
<IconSVG name="mdiCamera" size="md" variant="primary" />
113+
```
112114

113-
1. Click the "Import Icons" button in IcoMoon. Select [`icomoon.json`](/icomoon.json). When prompted, load the settings stored in the file.
114-
2. Scroll down to the "Add Icons From Library" link and add **Material Icons**.
115-
3. Move the imported set above Material Icons, using the 3-bar icon to the right of the imported set's title. (This should help preserve the icon order and minimize the diff.)
116-
4. Update the icons by selecting (highlighting) the new icons to add. They don't need to be moved or altered.
117-
5. Download the new font, then copy the files (`icomoon.css`, `fonts/*`, `icomoon.json`) into their locations in the repository.
118-
- You will need to rename the files and update the paths in the CSS (`fonts/icomoon.ttf?...` becomes `/fonts/icomoon.ttf?...` with a beginning slash).
119-
- You will also need to prettify the JSON file to use two space indentation.
115+
To add a new icon:
120116

121-
By following the steps above, you should minimize the diff. However, in the JSON file, you may still see changes for properties like `id`, `iconIdx`, `setId`, and `setIdx`.
117+
- Import the icon from `@mdi/js` in the `IconSVG` component.
118+
- Add the icon to the `iconMap` object with its corresponding name.
119+
- Use the icon by passing its name to the `name` prop.
122120

123121
Material Icons are available under the Apache License Version 2.0. Copy of the license can be found at [`./src/assets/fonts/LICENSE-2.0.txt`](./src/assets/fonts/LICENSE-2.0.txt)

0 commit comments

Comments
 (0)