Giter Club home page Giter Club logo

Comments (4)

vshepel avatar vshepel commented on September 9, 2024

Hi 👋

This feature is not available in the current version. However, I would appreciate your pr!

from vite-svg-sprite-wrapper.

vshepel avatar vshepel commented on September 9, 2024

I found the same question svg-sprite/svg-sprite#731

from vite-svg-sprite-wrapper.

mehdi-valette avatar mehdi-valette commented on September 9, 2024

Hi!

Thanks for the link to the discussion on svg-sprite 👍️

I think I will add an option to vite-svg-sprite-wrapper to ouptut a typescript file types: {path: string; typeName: string}. Something quite simple should work: type SymbolId = 'one' | 'two' | 'three';

Based on a quick look at svg-sprite and vite-svg-sprite-wrapper, I see three ways to do it (I'm not sure yet which ones are possible):

The ideal way
svg-sprite gives access to the ID of the generated shapes through getShapes. We can use it in vite-svg-sprite-wrapper and generate that "type" file.

The risky way
In vite-svg-sprite-wrapper we recreate the generateId function of svg-sprite to "guess" the generated ID (using the config object when available). Then we hope they don't change their mind ever 😅️

The inefficient way
We parse the Symbol again to extract its ID.

I'll have a look on Monday and try to implement it in the ideal way 🤓️
Of course I'm open to do it another way if you think there's a better approach.

from vite-svg-sprite-wrapper.

mehdi-valette avatar mehdi-valette commented on September 9, 2024

A pull request was created: #8

from vite-svg-sprite-wrapper.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.