-
Notifications
You must be signed in to change notification settings - Fork 102
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
Added option to use icons (like glyphicons) and LESSified styles, added min.css #25
Conversation
If you're using gulp or other task automation and you're including stylesheets inside a main stylesheet you'll probably find this useful.
To use icons add (say you're using glyphicons): `ico: ["glyphicons", "glyphicon-edit"]`
@@ -64,6 +64,6 @@ | |||
height: 20px; | |||
left: 0px; | |||
top: 3px; | |||
position: absolute; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why position is removed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just a typo. I'm working on two repositories and got thing messed up. It shouldn't be removed.
@@ -103,6 +103,7 @@ | |||
var name = selector[i].name, | |||
disable = selector[i].disable, | |||
fun = selector[i].fun, | |||
ico = selector[i].ico, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you maintain the indentation?
@@ -135,6 +136,26 @@ | |||
} | |||
} | |||
|
|||
//update ico | |||
if (ico) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While create its inside else if, but here its new if. This changes which one will be used among img/ico on create and update. Can you fix that.
And if ico was defined on create and later on update is defined than it will not remove the span element.
if (ico) { | ||
var imgIcon = elm.find('.iw-mIcon'); | ||
if (imgIcon.length) { | ||
if(imgIcon[0].tagName.toLowerCase() === "span"){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As its a jquery dependent library. You can use .is() method. ie imgIcon.is('span')
var imgIcon = elm.find('.iw-mIcon'); | ||
if (imgIcon.length) { | ||
if(imgIcon[0].tagName.toLowerCase() === "span"){ | ||
var classList = ["iw-mIcon"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just write imgIcon.attr('class', 'iw-mIcon '+ico). And always accept ico as string. If multiple class is required it can be added as space seperated ('icon-add align-left')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't thing of adding multiple classes as string with spaces. That simplifies stuff a lot. 👍
elm.prepend('<span align="absmiddle" class="iw-mIcon '+ico.toString().replace(",", " ")+'" />'); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it will be better just remove iw-mIcon and prepend it again based on ico/img. Something like this.
if(imgIcon){ imgIcon.remove(); }
if (img) {
elm.prepend('<img src="' + img + '" align="absmiddle" class="iw-mIcon" />');
} else if (ico) {
elm.prepend('<span align="absmiddle" class="' + ("iw-mIcon "+ico+'" />');
}
@@ -681,15 +702,17 @@ | |||
fun = selObj.fun || function() {}, | |||
subMenu = selObj.subMenu, | |||
img = selObj.img || '', | |||
ico = selObj.ico || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation.
Also I feel ico can be iconClass or just icon.
} | ||
|
||
} else if (ico) { | ||
list.prepend('<span align="absmiddle" class="' + ("iw-mIcon "+ico.toString().replace(","," "))+'" />'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accept ico only as string
Cool! Thanks for suggestions. I'll fix them ASAP and prepare commits. |
Let me know what you think now. I'm excited to get some more feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks great.
Just check if we can optimize .less file.
Or you can send me a PR leaving the less file for now. I will merge the icon feature. Less file we can merge in next PR.
*Lessified using http://css2less.co/ | ||
*/ | ||
// Color variables (appears count calculates by raw css) | ||
@color0: #333333; // Appears 2 times |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All colors are variation of black and white.
Can we just have two base colors and use lighten or darken method of less to provide variation? This will help a lot on customizing the theme.
It's hard to reduce more of them, you still need white for overlay, and I'd leave background and highlight colors as parameters
Let me know what you think abut LESS now. |
@@ -125,22 +126,21 @@ | |||
//update class name | |||
className != undefined && elm.attr('class', className); | |||
|
|||
//update image | |||
var imgIcon = elm.find('.iw-mIcon'); | |||
if(imgIcon.length) imgIcon[0].remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be imgIcon.remove();
imgIcon[0] will give DOM object and there is no remove method of DOM object (Thats a jquery method)
👍 |
If you're using gulp or other task automation and you're including stylesheets inside a main stylesheet you'll probably find this useful.