Closed nick-next closed 1 week ago
Looks great!
Can write you add the instructions for adding new icons to flask & react at docs/icons.md
, and link to that from docs/developer_guide.md
?
Can write you add the instructions for adding new icons to flask & react at
docs/icons.md
, and link to that fromdocs/developer_guide.md
?
Done!
I've just added in a python script that makes the job of creating the icons simple.
For example, to create an ArrowRight icon, you would run python3 generate_icon.py arrow_right
. The script will fetch the icon from Material and by default build both the flask version and the React version (with flags to change that behavior).
I've put description of how to use the script to generate the icons, how to create the icons manually if we ever need to (maybe for an icon not available from Material), and how to use the icons in the code.
The README is in the same directory as the script (in /tools/resources
) and linked to in the developers guide. Let me know if there is any other documentation or adjustments needed!
Description
Material icons are used throughout the Data Commons site, and these usages are primary done via Google Fonts. While this is convenient, there is a drawback in that the icons only render after the font has completed downloading. This can cause flashes of unstyled content. In some cases, these flashes are significant enough to cause major flashes (as the span takes up a significant amount of space before the font loads).
An earlier PR made initial updates to solve the more obvious flashes (particularly in the header bar) by replacing the Material fonts with inline SVGs.
This PR aims to continue that process by creating an extensible library of font components to replace those inline SVGs.
This PR includes icons that the are currently used, and converts font usage to icon component usage on recently revamped header and home pages. If this approach is approved, we can expand this approach everywhere, with the eventual goal of removing the fonts completely.
This PR also removes a final FOUC in the header (relating to a remaining font-based icon usage.
The goals are:
Notes
In this approach, we include the icons we need (and only the icons we need) without relying on a third-party library. This way, we do not need to import heavy dependencies and have full control over the icon set we use. The icons are easy to add - the SVGs being available from https://fonts.google.com/icons. If this overall approach is approved, we can write a script that, given a new icon we want to use, downloads it and prepares it automatically.
Example Usage
Replacing a font-based Material icon:
Old
New
Replacing an inline Material Icon:
Old
New
Replacing an SVG (or font-based icon) in a template:
Old
New