You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To be inline with the UI migration #6374, there is a collection of SVG assets that serve as icons that can also be converted to Chakra!
Aside from the approach to use the Icon component, which is good for use with icons from 3rd party packages, there is the createIcon() function which allows you to build the svg parts and supercharge the icon itself with Chakra props. The icon can then be imported into another part of the project as a Chakra component to be styled directly.
This can cut down on, say, the need to use descendant selecting in CSS to be able to alter any styling.
Note: using createIcon() over the Icon component is a semantic choice. From the Chakra docs, it states that "[This] function is a convenience wrapper around the process of generating icons with 'Icon', allowing you to achieve the same functionality with less effort."
I personally find createIcon() to be cleaner for this use! 😅
Current Behavior
For example, the current approach is to import an svg as a react component via gatsby-plugin-react-svg as the following:
import{HardwareSupportIcon}from"../../../components/icons/wallets/HardwareSupportIcon"// Or exported through a common `index.ts` for each sub-directoryimport{HardwareSupportIcon}from"../../../components/icons/wallets"
As this is arguably a major overhaul, the following are proposed outlined steps to be taken:
Identify all svg icons from the assets directory
Convert each icon to a .tsx file with Chakra's createIcon() function, save the new files into src/components/icons, and divided here in the same sub-directory structure present in assets. Also, they would be given a new naming convention of [Name]Icon.tsx
i.e. hardware_support.svg currently resides in src/assets/wallets/hardware_support.svg. Its name and location would now become src/components/icons/wallets/HardwareSupportIcon.tsx
Convert the icon imports in all components and pages.
3a. Adjust implementation as necessary.
Additional Thoughts
One known expected result in this conversion is the loss of SVG image previews via an IDE extension, and a solid replacement was not found. However, with the current consideration of bringing in StorybookJS to the workflow a story could be created to display all of the icons.
The text was updated successfully, but these errors were encountered:
Strongly agree with this idea. This was a similar approach to what we took when working on the geth website and thought it was a good pattern.
I don't think the loss of that svg preview is the end of the world, but we could always start with the pattern of keeping both the svg and icon implementation to start, with the intent of removing the svg files once storybook has been implemented.
To be inline with the UI migration #6374, there is a collection of SVG assets that serve as icons that can also be converted to Chakra!
Aside from the approach to use the
Icon
component, which is good for use with icons from 3rd party packages, there is the createIcon() function which allows you to build the svg parts and supercharge the icon itself with Chakra props. The icon can then be imported into another part of the project as a Chakra component to be styled directly.This can cut down on, say, the need to use descendant selecting in CSS to be able to alter any styling.
Current Behavior
For example, the current approach is to import an svg as a react component via
gatsby-plugin-react-svg
as the following:Now if the
fill
or any other styling of thesvg
element were need to be altered, you would use a descendant selector in the parent componentNew Behavior
With
createIcon()
for hardware_support.svg:The original example can now become:
Setup
As this is arguably a major overhaul, the following are proposed outlined steps to be taken:
assets
directory.tsx
file with Chakra'screateIcon()
function, save the new files intosrc/components/icons
, and divided here in the same sub-directory structure present inassets
. Also, they would be given a new naming convention of[Name]Icon.tsx
hardware_support.svg
currently resides insrc/assets/wallets/hardware_support.svg
. Its name and location would now becomesrc/components/icons/wallets/HardwareSupportIcon.tsx
3a. Adjust implementation as necessary.
Additional Thoughts
One known expected result in this conversion is the loss of SVG image previews via an IDE extension, and a solid replacement was not found. However, with the current consideration of bringing in StorybookJS to the workflow a story could be created to display all of the icons.
The text was updated successfully, but these errors were encountered: