-
Notifications
You must be signed in to change notification settings - Fork 36
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
"icons" to move to font icons or SVG icons #434
Comments
I think @tkrugg had some arguments against using font icons but using directly SVG. See also: http://css-tricks.com/icon-fonts-vs-svg/ I guess the three issues with using SVG are:
@tkrugg I'll let you step in with your arguments. |
There are very few cases where we've actually used icon fonts so far and even then, I don't think switch would be so painful. For instance instead of the iconClass in Button.html will rather include This implies the use of a d-icon component but lots of benefits come with it. (cf. document linked below)
As long as the SVG in inlined, you can style it with CSS.
Bandwidth wise, there is a benchmark showing how otf/ttf tend to be much smaller than svg files. I've been working on gathering the pros & cons for it in this document, I think it will anwser some of your questions. |
@tkrugg, I'm curious to know how your |
I have to say i didn't think that specific case through. Is it a very common case? |
Oh, I'm fine with that but I just don't understand how the |
I've been spending some time on sketching an API for this d-icon widget,
<span class="fontawesome-arrow"></span>
.fontawesome-arrow::before { content: ... } /* overriding the arrow icon */
.d-star-rating-full::before { content: ... } /* customize the icon used by a widget. */
With SVG<d-icon-pack id="fontawesome" ></d-icon-pack>
<d-icon pack="fontawesome" name="arrow-right"></d-icon>
<!-- fontawesome/arrow-right.svg file will be fetched and stored inside d-icon-pack--> bundling icons<d-icon-pack id="fontawesome" src="fontawesome.svg"></d-icon-pack>
<d-icon pack="fontawesome" name="arrow-right"></d-icon>
<!-- won't be fetched as it exists in src --> Overriding icons<d-icon-pack id="fontawesome" src="fontawesome.svg">
<svg>
<symbol id="#arrow-right">...</symbol>
<!-- overriding #arrow-right from arrows-icons-pack.svg -->
<symbol id="#star-rating-icon">
<use xlink:href="#star"></use>
</symbol>
<!-- overriding #star-rating-icon used by StarRating -->
// TODO: there is no way to say star-icon should use this icon pack.
// shoudln't it be better if star rating took a name and a pack as properties?
// I have no better solution for this, please feel free to make suggestions.
</svg>
</d-icon-pack>
<d-icon pack="fontawesome" name="arrow-right"></d-icon> Defining new icons or stacking existing ones.<d-icon-pack id="fontawesome" src="fontawesome.svg">
<svg>
<symbol id="#arrow-double">
<!-- creating a double arrow from two existing arrows -->
<use xlink:href="#arrow-left"></use>
<use xlink:href="#arrow-right"></use>
</symbol>
</svg>
</d-icon-pack>
<d-icon pack="fontawesome" name="arrow-double"></d-icon> There is a prototype that implements all of the above features. With Fonts<d-icon-pack id="fontawesome"
font-src="icons.tff,icons.otf,icons.woff" css-src="icons.css"></d-icon-pack>
<d-icon pack="fontawesome" name="arrow-right"></d-icon>
<!-- would compile to <span class="fontawesome_arrow-right"></span> --> With PNGsI didn't put more thought into this but theoretically it should be possible to make their use a little easier. Programmaticallydefine([
// "deliteful/d-icon-pack!<IconPack>,<icon1>,<icon2>,..."
"deliteful/d-icon-pack!fontawesome,arrow-right,arrow-down"
], function(){
...
}) <template>
<button>
<!-- an instance of <d-icon-pack id="fontawesome"></d-icon-pack> is placed in the page if it doesn't exist yet -->
<d-icon pack="fontawesome" name="arrow-right"></d-icon> Click plz
</button>
</template> The information passed in as a dependency will be used during the build to bundle svgs together. ThemingWe want to:
At the moment
I'm not sure how we could keep theses inside theme folders and still have them fetched as dependencies. @cjolif suggested Bower hooks. I've tried them and I can say it's solving this problem. Other ideasA few other features we could imagine adding to d-icon: <d-icon names="square,check"></d-icon>
<d-icon name="arrow" direction="right"></d-icon>
<d-icon name="checkbox" state="checked/unchecked"></d-icon>
<d-icon name="refresh" spinning></d-icon>
<d-icon name="arrow" size="mini/normal/big"></d-icon> <!-- multiple levels of details --> Please share your thoughts on this. |
Thanks for that summary. I'm intrigued by the My main thought though is that the icons themselves shouldn't be tied to "deliteful/d-icon-pack!deliteful/icons/{{theme}}/fontawesome,arrow-right,arrow-down" Actually, I'm confused, because your other example suggests that this is already supported: <d-icon-pack id="fontawesome" src="fontawesome.svg"> Presumably Anyway, one example where this would be useful would be deliteful/Button, which displays a user-defined icon. So the user needs some way to load his custom icons. I also wonder if there's some overlap w/the ticket about making custom themes. |
"deliteful/d-icon-pack!deliteful/icons/{{theme}}/fontawesome,arrow-right,arrow-down" is much simpler and more consistent with the rest. <d-icon-pack id="myicons" src="path/to/my/icon/pack.svg"></d-icon-pack>
<d-icon pack="myicons" name="arrow-right"></d-icon> then maybe he could get something theme specific with <d-icon-pack id="allicons" src="deliteful/icons/{{theme}}/icons.svg"></d-icon-pack>
<d-icon pack="allicons" name="arrow-right"></d-icon>
There is the option to keep sets of icons within the theme folders of the widget that's using them, but I think it may be harder to manage. Also by sticking to the structure of a regular widget, I was hoping to fall in the case investigated here: #457 (comment) (not that it's a sufficient reason to do so) |
OK, thanks, makes sense. When I vaguely mentioned "overlap w/the ticket about making custom themes", I was actually thinking of sharing code for things like:
What do you think about enhancing the define([
...
"delite/theme!./ToggleButton/themes/{{theme}}/ToggleButton.css",
"delite/theme!./IconPack/themes/{{theme}}/fontawesome/ToggleButtonCheckmark.svg"
], ...
Oh, I don't care what directory they are in. |
That sounds good! I'll look into that. |
I think this article is a bit exaggerated but still, looks like more reasons to switch to SVG icons: https://speakerdeck.com/ninjanails/death-to-icon-fonts. |
Closing this since we no longer have plans to switch to SVG icons, and CheckBox, StarRating, and Combobox already specify their icons via CSS |
In the components:
In the samples:
We made decide to keep unicode char for some of them if there are good reasons but font icons or SVG icons should give us better cross platform behavior.
The text was updated successfully, but these errors were encountered: