nguyenvanduocit / vue-loading-spinner

Just another collection of loading spinners with Vue.js, alot of spinners
https://nguyenvanduocit.github.io/vue-loading-spinner/
687 stars 106 forks source link

RotateSquare2 background property not working #29

Closed arthabus closed 1 year ago

arthabus commented 5 years ago

Can't change color of RotateSquare2. Source code exposes prop "background" but it seem to be ignored.

nguyenvanduocit commented 5 years ago

I think it's better to copy the code and paste to your project. Sorry about that.

rbayley commented 3 years ago

Hi @nguyenvanduocit

You can, using CSS variables (more precisely called CSS custom properties).

export default {
  props: {
    size: {
      default: '40px'
    },
    background: {
      default: '#41b883'
    }
  },
  computed: {
    styles () {
      return {
        width: this.size,
        height: this.size,
        '--my-var-color':  this.background
      }
    }
  }
}

Then on your style tag you simply reference you the --var you have set with your computed property. (for simplicity sake I am only pasting code relevant to the answer). and voilà!! :)

<style lang="scss" scoped>

    &:after {
      background: var(--my-var-color);
    }
  }
</style>

I hope this helps you keep this great component active again!

regards

zhanghaifei1997 commented 3 years ago

Is there any development document? I want to use it in my own project, but I find it doesn't work. I want to add this loading effect when the pop-up window appears.

zhanghaifei1997 commented 3 years ago

Is there any development document? I want to use it in my own project, but I find it doesn't work. I want to add this loading effect when the pop-up window appears.