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

Added option to use icons (like glyphicons) and LESSified styles, added min.css #25

Merged
merged 6 commits into from
Sep 26, 2016

Conversation

falxcerebri
Copy link
Contributor

If you're using gulp or other task automation and you're including stylesheets inside a main stylesheet you'll probably find this useful.

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"]`
@falxcerebri falxcerebri changed the title Lessified css file, for folks who use LESS Added option to use icons (like glyphicons) and LESSified styles, added min.css Sep 22, 2016
@@ -64,6 +64,6 @@
height: 20px;
left: 0px;
top: 3px;
position: absolute;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why position is removed ?

Copy link
Contributor Author

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,
Copy link
Owner

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) {
Copy link
Owner

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"){
Copy link
Owner

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"];
Copy link
Owner

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')

Copy link
Contributor Author

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(",", " ")+'" />');
}
}

Copy link
Owner

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 || '',
Copy link
Owner

@s-yadav s-yadav Sep 22, 2016

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(","," "))+'" />');
Copy link
Owner

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

@falxcerebri
Copy link
Contributor Author

Cool! Thanks for suggestions. I'll fix them ASAP and prepare commits.

@falxcerebri
Copy link
Contributor Author

Let me know what you think now. I'm excited to get some more feedback.

Copy link
Owner

@s-yadav s-yadav left a 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
Copy link
Owner

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
@falxcerebri
Copy link
Contributor Author

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();
Copy link
Owner

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)

@s-yadav s-yadav merged commit b022af3 into s-yadav:master Sep 26, 2016
@falxcerebri
Copy link
Contributor Author

👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants