jwarby / jquery-awesome-cursor

jQuery plugin for using FontAwesome icons as custom CSS cursors
https://jwarby.github.io/jquery-awesome-cursor/
MIT License
179 stars 69 forks source link

Less Color Varieble not a color #22

Closed EinfachAleks closed 7 years ago

EinfachAleks commented 8 years ago

https://github.com/jwarby/jquery-awesome-cursor#colour

Can i add a Less Variable instead hex color to the Color parameter like this:

Less-File: @green: #00cc00;

JS-File: $('.carousel.slide a.right.carousel-control').awesomeCursor('chevron-right', { color: '@green' });

jwarby commented 7 years ago

Hi @EinfachAleks, no this isn't possible sorry - not at least without some hacks. What you could do is somehow parse the LESS variable value (a quick Google search for "less variables in javascript" brings up a few hacks), and then use your parsed value instead. As this is not possible without hacks though, it's not something the plugin itself will be supporting.

EinfachAleks commented 7 years ago

I createt my own "hack" ..

HTML <span class="theme-color hide"></span>

JavaScript

var themeColor = $("span.theme-color.hide").css("color"); function rgb2hex(rgb) { rgb = rgb.match(/^rgba?((\d+),\s(\d+),\s(\d+)(?:,\s*(\d+))?)$/); function hex(x) { return ("0" + parseInt(x).toString(16)).slice(-2); } return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); } var cursorColor = rgb2hex(themeColor); $(".carousel.slide a.right.carousel-control").awesomeCursor("chevron-right", { color: cursorColor, size: 32 }); $(".carousel.slide a.left.carousel-control").awesomeCursor("chevron-left", { color: cursorColor, size: 32 });

jwarby commented 7 years ago

Ah cool solution @EinfachAleks! You shouldn't need to convert from RGB to hex though, the plugin should handle any valid CSS colour string already.