-
Notifications
You must be signed in to change notification settings - Fork 12
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
Default theme: icon types #109
Comments
I would definitely go with a deeper investigation around SVG. It seems to be the best option, especially taking in consideration the benefits it would bring to handle different DPIs and screen sizes. |
About icon fonts:
Actually it is quite easy to generate font from SVG icons. There is of course gulp plugin for it ;) So by creating SVG icons, we could have both: SVG icons/sprites and icon font (AFAIR Google is using similar mechanism for their Material Icons).
As I said, ligatures could be the answer to that question. It is probably even more accessible than SVG with some ARIA/alternative text, but I don't have any test to prove it. |
@Comandeer Good to know. But I'm more worried about the color limitations of icon fonts. And there are more questions:
|
I think that the "Resources" part of this issue has enough arguments to support SVG over Font. |
If font icon is using ligatures, then icons are connected with words/phrases, not unique characters – so when the font is switched, the text shows up.
As SVG with builder.
Well, there is also a possibility to create one-char fonts… ;) But yes, recompilation is probably the most sane way
https://css-tricks.com/stackicons-icon-fonts/ ;) But that's totally insane and should be done with SVG. @fredck I know that articles and I don't state that icon fonts are better than SVG. I'll rather see the "hybrid" solution: SVG and icon font generated from it. If we're going to switch to one of options, I'd stick to SVG as well. |
Maybe I'm missing something. What would the "hybrid" solution solve? Lack of SVG support? |
Icon fonts can be better cached, as nearly all nice features that SVG has require to inline it AFAIR. Icon fonts are just easier to use – drop stylesheet and it's done. Fallback for font with ligatures is also nicer than for SVG: it's just plain text. I'd say that icon fonts are better suitable for "light" themes where inlining SVG, probably via Ajax, could be an overkill. Maybe not solving some big issues, but rather a nice added value. I'm also wondering why Google still recommend icon font for their Material Icons as they provide SVG sprites. |
The problem with ligatures is that you would need to create a font for each language, or every user would get the same English text and so any potential benefit from that usage goes away. If someone wants to create a theme using an icon font it would be good if it's possible, but I find that it's hard to justify making the default theme that way. It's important to think about 3rd party plugins, they will provide their icons and asking them to create a font (or even a SVG icon) might be an extra effort, so it should be possible to keep using png besides the main icons in whatever format you choose to go. At least I would have a very hard time to create a SVG icon for each of the plugins that I have. |
|
May this be related to the file size only? They're talking about 750+ icons after all. |
To take the burden of icon maintenance off of the CK team I recommend using Font Awesome. In addition to over 500 general icons they have an editor specific set If you don't want to implement Font Awesome icons as icon font you can use other tools Node-based like this to generate images at all sizes and change colors. It's also open-source: https://fortawesome.github.io/Font-Awesome/license/ By the way, a plugin that let users add icons to their content from the font awesome set would also be pretty sweet, and if the library is already in CK that would be pretty trivial I imagine. |
Font Awesome also has some nice solutions for animated icons and for keeping code dry by re-using the same icon for multiple orientations (up, down, left, right). |
Open source does not mean compatible with licenses used by CKEditor. AFAIR SIL OFL 1.1 is incompatible with *GPL. |
I think it was compatible. cc @wwalc. |
I have mixed feelings, in general Font Awesome does not provide all the icons we need anyway so I think we'd be much safer with creating all icons by ourselves. |
Why not just contribute those missing icons to font awesome? Seems like much less effort. |
I'm also curious to know which icons font awesome does not have. Their set is pretty massive. |
Just posted this on D.O. Hopefully we'll sees some movement. https://www.drupal.org/node/2139273#comment-10871158 |
Contributing icons to or collaborating with FontAwesome would create great freedom for addon developers to just pick an icon from the full set. I would suggest contacting them for collaboration. |
I don't know how FontAwesome works but what if we wanted some very specific icons for the features that makes sense only for us? I guess we would have to fork FontAwesome because contributing all of them to the official branch of the project would significantly slow us down? In fact, forking would be necessary anyway, because I find some of the existing icons less readable than ours (I've said this many times so far – @oleq has done a tremendous job designing the current icon set). Perhaps some of our changes would be accepted by FontAwesome, but we cannot be blocked by some rejections. If this can work and the license thing could be resolved, perhaps choosing FontAwesome would make some sense. It might give us good grounds for building the icon set. |
Update on Drupal license issue:
Presumably if the Drupal LWG can work out an adequate compromise position then other GPL V2 projects may be able to as well. |
Another little company that moves away from icon fonts: https://github.com/blog/2112-delivering-octicons-with-svg |
Much probably having font icons from an external source (like Font Awesome) is definitely a great idea. In the other hand, the way we deliver them still need to be defined as SVG may be a better fit. Therefore, if we are able to easily transform font icons into SVG we may have found the best approach for this. |
I've never liked font icons myself simply because I don't like hacks. So I would vote for SVG. As for Font Awesome, it's definitely useful if you can easily take icons from a nice library which Font Awesome is. We could have some tools which let's you use the icon font as a source of icons for the editor (or your editor feature which you develop). I'd guess though that there must be some nice SVG icon libraries as well. So if we'll go with SVGs, what does Font Awesome give us (other than headaches with the license :D)? |
An extensive icon set which is extremely popular and hopefully well maintained in the long run. But ofc, any other library matching that same criteria would work. |
So maybe Material Design Icons? They're already in SVG format. |
Sure, that is certainly going to be a well maintained repo. :) I have no particular loyalty to Font Awesome, my only points were 1. Recognition through ubiquity, and 2. Offloading tech debt, and Material certainly addresses both. |
After some research I came up with an idea to use DetailsThe whole trick is that separate SVG icons
are compiled into an inline SVG sprite which is injected into DOM: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="ck-sprite">
<symbol viewBox="0 0 20 20" id="ck-icon-align-center">
<title>align-center</title>
<path d="M16 10v1H4v-1h12zm-1 6v1H5v-1h10zm3-3v1H2v-1h16zm-2-9v1H4V4h12zm2 3v1H2V7h16z" fill="#444" fill-rule="evenodd"/>
</symbol>
<symbol viewBox="0 0 20 20" id="ck-icon-align-left">
<title>align-left</title>
<path d="M3 10v1h12v-1H3zm0 6v1h10v-1H3zm0-3v1h15v-1H3zm0-9v1h12V4H3zm0 3v1h15V7H3z" fill="#444" fill-rule="evenodd"/>
</symbol>
...
</svg> Then a simple reference in HTML inserts the actual icon, i.e.: <a href="#" class="ck-button">
<svg class="ck-icon ck-icon-left">
<use xlink:href="#ck-icon-align-center"></use>
</svg>
Align center
</a> The working example is in https://github.com/ckeditor/ckeditor5-design/tree/theme-architecture branch: AdvantagesThe solution combines all the advantages of SVG backgrounds (CSS Unlike inline SVGs, generated SVG sprite is injected in DOM only once. Inserting an icon is pretty cheap ( I checked Chrome, Firefox, Safari (also iOS) and Edge and it seems that Disadvantages? Future and MVCThe idea is that icon might become
In the first approach, The later approach assumes that Either way, controlling icons with |
Great job! Symbol-driven SVG sprites look great. As for MVC, I'm for a separate component. This will allow replacing SVG icons with any other icons just by replacing that one component's view. |
Maybe we can consider external SVG? https://css-tricks.com/svg-use-with-external-reference-take-2/ The only big problem with it is probably lack of decent CORS support: https://bugs.chromium.org/p/chromium/issues/detail?id=470601 |
@Comandeer Though it looks nice (because there's no need to inject SVG into DOM) it would generate additional HTTP request IIRC, wouldn't it? The main advantage of direct injection into DOM handled by JS with pre–generated SVG string it that is spares us that request. |
Yes, it would generate additional request, but actually it can be very useful. Inlining resources is an optimization technique good mainly for HTTP/1.x. Currently HTTP/2 is gaining popularity and with it that kind of resources can be pushed to the client – it's something like "server-side inline". But that kind of "inline" could be also cached ;) And changed on the fly. Inline SVG is bound to the build process AFAIK. |
I would like to not think of bundling myself, because this gave me huge headaches when I've been thinking about ES6 modules, but so far bundling is must-have. |
Cleaning up old discussions. See #186. |
There are 3 different types of icons default theme could use:
Resources:
The text was updated successfully, but these errors were encountered: