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

feature: need to swap Out SVG Icons #221

Open
antinmaze opened this issue May 1, 2024 · 0 comments
Open

feature: need to swap Out SVG Icons #221

antinmaze opened this issue May 1, 2024 · 0 comments

Comments

@antinmaze
Copy link

antinmaze commented May 1, 2024

What version of astro-icon are you using?

v1.1.0

Astro Info

The use case is to switch local icons for instance from the eye-fill svg and the eye-slash-fill svg.
Using javascript, this does not work trying updating the <Icon/> name. In this case I am not able to refresh the icon. However may be this is not the right strategy as an Icon should be a static by construction withe a unique id...
So another strategy would be to implement 2 icons and Hide/Show SVG Elements using display: none; or display: blocks;
The current Astro Icon release does not manage the display parameter
Some other strategy such as manipulating a multi paths svg but this is not the best solution as we need manipulate simple svg file. 
see https://css-tricks.com/swapping-svg-icons/ for more
But maybe I miss something to manage this use-case without relaying on React or Vue JS .

If this issue only occurs in one browser, which browser is a problem?

Chrome

Describe the Bug

The use case is to switch local icons for instance from the eye-fill svg and the eye-slash-fill svg.
Using javascript, this does not work trying updating the name. In this case I am not able to refresh the icon. However may be this is not the right strategy as an Icon should be a static by construction withe a unique id...
So another strategy would be to implement 2 icons and Hide/Show SVG Elements using display: none; or display: blocks;
The current Astro Icon release does not manage the display parameter
Some other strategy such as manipulating a multi paths svg but this is not the best solution as we need manipulate simple svg file.
see https://css-tricks.com/swapping-svg-icons/ for more
But maybe I miss something to manage this use-case without relaying on React or Vue JS .

What's the expected result?

Able to switch between Two icons updating the Icon name parameter from name="eye-slash-fill" to name="eye-fill"

        <button
          id="password-button"
          type="button"
          class="absolute inset-y-0 right-0 flex items-center px-2 bg-transparent"
        >
          <Icon
            id="eye-icon"
            class="absolute right-1 -mr-0 text-2xl"
            name="eye-slash-fill"
          />
        </button>

Link to Minimal Reproducible Example

https://stackblitz.com/edit/astro-tdbmyy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant