Skip to content
This repository has been archived by the owner on May 29, 2020. It is now read-only.

Add possibility to rotate existing glyph with css transform #341

Closed
wants to merge 2 commits into from

Conversation

fry2k
Copy link

@fry2k fry2k commented Jun 3, 2016

This pull request adds the possibility to rotate any existing glyph with an angel between 1 and 259 degrees and adds the css definition therefore. The rotated glyphs are also shown at the demo.html.
You can rotate the source glyph multiple times.

I used this for arrows that I have only for example the svg for arrow-right and rotate the arrow with 90, 180 and 270 deg for arrow-down, arrow-left and arrow-up.

If you like it I could also add the possibility to flip a glyph horizontal or vertical.

I run into trouble verifying the generated demo.html with my rotated icons so I commited also the fix about the wrong font-face generation at the demo.html which is discussed here: #331

@scottyeck
Copy link
Collaborator

scottyeck commented Jun 3, 2016

This could easily be resolved with a pre-processor. 😎

For example, with Sass:

//
// Base styles
//
.icon:before {
    font-family: "Icons";
    // other properties here
}

//
// Codepoint assignment
//
.icon-arrow-up:before {
    content: "\f104";
}

All the code above would have been generated by grunt-webfont. You'd only need to add the following:

.icon-arrow-down {
     @extend .icon-arrow-up;
     &:before {
          transform: rotate(180deg);
     }
}

Just my two cents, but I'd be concerned about over-specialization here. Obviously @sapegin has the more important say 😜

@scottyeck
Copy link
Collaborator

Also, FWIW, should this code get merged, just a head's up that the authorship of your commits isn't currently tied to your GitHub username, which I'd recommend gets amended. 👍

@sapegin
Copy link
Owner

sapegin commented Jun 5, 2016

@scottyeck is right, no need to implement CSS inside the plugin.

@sapegin sapegin closed this Jun 5, 2016
content:"<% if (addLigatures) { %><%= glyphs[glyphIdx] %><% } else { %>\<%= codepoints[glyphIdx] %><% } %>";
content:"<% if (addLigatures) { %><%= glyphs[glyphIdx] %><% } else { %>\<%= codepoints[glyphIdx] %><% } %>";<% if (cssRotate[glyphs[glyphIdx]]) { %>
display: inline-block;
-webkit-transform: rotate(<%= cssRotate[glyphs[glyphIdx]] %>deg);
Copy link
Owner

Choose a reason for hiding this comment

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

By the way, in 2016 we don’t need any of these prefixes ;-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants