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

there is no method to add gradient colors #51

Open
Awaiszeeshan opened this issue Aug 10, 2021 · 1 comment
Open

there is no method to add gradient colors #51

Awaiszeeshan opened this issue Aug 10, 2021 · 1 comment

Comments

@Awaiszeeshan
Copy link

hi, i couldn't find a way to fill the icon with the gradient colors,
if there is a method kindly guide me through the steps

@DanielTerletzkiy
Copy link

Something like this should work.

<svg style="width:0;height:0;position:absolute;" aria-hidden="true" focusable="false">
      <linearGradient :id="uniqueId" x1="0%" y1="0%" x2="100%" y2="0%"
                      v-if="gradient">
        <stop v-for="{offset, color} in gradient" :key="offset" :offset="offset+'%'"
              :stop-color="color"/>
      </linearGradient>
</svg>

<unicon  :name="name" :width="size" :height="size" :fill="`url(#${this.uniqueId}) ${color}`"/>

Replace uniqueId with a id/key that is both present on the linearGradient and unicon -> fill tags.

gradient is an array of objects and could look like this:

[
   {offset: 0, color: '#fff'},
   {offset: 100, color: '#000'},
]

gradientRotation is the rotation of the gradient in deg

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

2 participants