Giter Site home page Giter Site logo

Comments (5)

gorangajic avatar gorangajic commented on May 12, 2024

Use of context is broken in react-svg-morph see issue -> gorangajic/react-svg-morph#2 and because react-icons now uses context they do not work anymore. Sorry for that but you can always use svg directly

from react-icons.

szjanos avatar szjanos commented on May 12, 2024

Thank you for you fast response!

I've very new to SVG and I've spent hours to resize the google's clouduploud icon to 100px. Finally I ended up with this:

export default class CloudUpload extends Component {
    render() {
        return (
            <svg width="100" height="100" viewBox="0 7 40 25">
               <g> <path d="m23.4 21.6h5l-8.4-8.2-8.4 8.2h5v6.8h6.8v-6.8z m8.9-4.9c4.3 0.3 7.7 3.9 7.7 8.3 0 4.6-3.7 8.4-8.4 8.4h-21.6c-5.5 0-10-4.5-10-10 0-5.2 3.9-9.4 8.9-10 2.1-3.9 6.3-6.8 11.1-6.8 6.1 0 11.1 4.3 12.3 10.1z" />
            </g></svg>
        )
    }
}

(If you have any better solution please tell me)

And now when I am attaching it to the MorphReplace it drops all the attributes svg what I set... :(

I have also tried it with the MorphReplaceResize but it will ignore the viewBox="0 7 40 25" property so the cloud image is not at the middle of the viewport.

<MorphReplaceResize width={100} height={100} viewBox={"0 7 40 25"}>
        {this.increment % 2 === 1 ? <Hashtag  /> : <CloudUpload />}
</MorphReplaceResize>

Could you please help me out a little bit, cause I am kind a stucked...

I also wanted to ask if there is a better way to get the icons from the react-icons or do I have to always copy the path and create a new React class?

from react-icons.

gorangajic avatar gorangajic commented on May 12, 2024

Until context bug is fixed react-icons will not work with react-svg-morph for now, you can manually copy the path or use older version.

You should not provide viewBox to MorphReplaceResize it should work without that.

Not sure what you want to do but I have created something similar http://www.webpackbin.com/VyThQMOo-

from react-icons.

szjanos avatar szjanos commented on May 12, 2024

The problem is that the Hashtag has a different size than CloudUpload, that's why I cannot use the same viewport.

My Hashtag class looks like this:

export default class Hashtag extends Component {
    render() {
        return (
            <svg width="100" height="100" viewBox="0 0 100 100">
                <path d="m 72.4,3.5 c -2,0 -3.9,0 -5.9,0 -4.5,0 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5,2.5 5,5 7.5,7.5 0.9,-7.3 1.8,-14.7 2.8,-22 0.5,-4.1 -3.8,-7.4 -7.5,-7.5 -7.4,-0.2 -14.8,-0.3 -22.2,-0.5 2.4,3.2 4.8,6.3 7.2,9.5 0.3,-1.9 0.6,-3.9 0.8,-5.8 -2.4,1.8 -4.8,3.7 -7.2,5.5 7.3,0.2 14.7,0.3 22,0.5 4.5,0.1 7,-3.5 7.5,-7.5 1,-7.7 1.9,-15.4 2.9,-23.2 0.5,-4.1 -3.8,-7.4 -7.5,-7.5 -7.2,-0.2 -14.4,-0.3 -21.5,-0.5 2.4,3.2 4.8,6.3 7.2,9.5 0.3,-1.9 0.6,-3.9 0.8,-5.8 -2.4,1.8 -4.8,3.7 -7.2,5.5 7.1,0.2 14.3,0.3 21.4,0.5 4.5,0.1 7,-3.5 7.5,-7.5 0.9,-7.1 1.8,-14.2 2.7,-21.3 -2.5,2.5 -5,5 -7.5,7.5 2,0 3.9,0 5.8,0 -2.5,-2.5 -5,-5 -7.5,-7.5 -0.9,7.1 -1.8,14.3 -2.7,21.4 -0.5,4.1 3.8,7.4 7.5,7.5 7.8,0.2 15.6,0.3 23.3,0.5 4.5,0.1 7,-3.5 7.5,-7.5 0.9,-7.3 1.8,-14.6 2.7,-21.9 -2.5,2.5 -5,5 -7.5,7.5 2,0 3.9,0 5.9,0 9.6,0 9.6,-15 -0.1,-15 z" />
            </svg>
        )
    }
}

MorphTransitionResize would do the thing but it ignores the first to property of the svg's viewbox so this way my cloud won't be in the middle.

So from the viewBox={"0 7 40 25"} the 7 number is ignored which would pull my icon to the middle of the viewBox.

EDIT: I think I've found the solution. The viewbox and width/height has to be always in synchrone and I have to let the library resize the stuff for me. This means for me that I can't resize via viewbox or if I resize via viewbox I can't set the position of the path so it won't be in the middle of the SVG.

from react-icons.

gorangajic avatar gorangajic commented on May 12, 2024

great then I will close this issue

from react-icons.

Related Issues (20)

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.