Skip to content
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

Ensure stories use Icon components instead of SVG components #38

Open
AaronPlave opened this issue Jun 6, 2023 · 3 comments
Open

Ensure stories use Icon components instead of SVG components #38

AaronPlave opened this issue Jun 6, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@AaronPlave
Copy link
Member

For some reason the <Icon*> components are shown as <Svg*> in the Story code. These Svg components do not export/import correctly (which we could look at) so users who paste in the Navbar example (for example) run into errors.

@AaronPlave AaronPlave added the bug Something isn't working label Jun 6, 2023
@anilnatha
Copy link
Collaborator

I ran into this issue when trying to use SVGChevronLeft inside a Button as described here so it's not just related to the Navbar.

Source:

import SvgChevronLeft from "@nasa-jpl/react-stellar/dist/cjs/components/Icons/ChevronLeft";

...

<Button><SvgChevronLeft /><span>Back to application selection</span></Button>

Error:

11:29:51 AM [vite] Internal server error: Failed to resolve import "@nasa-jpl/react-stellar/dist/cjs/components/Icons/ChevronLeft" from "src/routes/jobs/new/chirp-rebinning/index.tsx". Does the file exist?
  Plugin: vite:import-analysis
  File: /Users/anatha/Projects/Unity/Repos/unity-ui/src/routes/jobs/new/chirp-rebinning/index.tsx:11:27
  18 |  //import ChevronLeft from "@nasa-jpl/stellar/icons/chevron_left.svg";
  19 |  //import { IconChevronLeft } from "@nasa-jpl/react-stellar";
  20 |  import SvgChevronLeft from "@nasa-jpl/react-stellar/dist/cjs/components/Icons/ChevronLeft";

A workaround for the time being, which requires some additional CSS, is to import the svg from stellar and use it as the value for the src attribute on an img.

@AaronPlave
Copy link
Member Author

You should also be able to import the icon as IconChevronLeft from "@nasa-jpl/react-stellar".

@anilnatha
Copy link
Collaborator

anilnatha commented Dec 11, 2023

I had tried that as well without success, but tried again and got it to work, I must have accidentally passed IconChevronLeft as a value to the src attribute on img rather than just using it as <IconChevronLeft />.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants