-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Convert to octicon SVG library #9258
Conversation
Signed-off-by: jolheiser <[email protected]>
Our current bindata.go system compresses the resources into a virtual file system, so Gitea's executable stays compact. Perhaps there's a way of compressing this too? How will this affect custom templates that currently use the octicon font? |
I think I would prefer that icons would stay purely in client side (css/webfont/js) |
Inline SVG is certainly the way to go, it will for example allow to have multi-colored icons and allow proper targeting/sizing via CSS. Webfonts are just a ugly hack in my eyes. |
Problem is that we can't really use them in dynamic client side scripts/vue components than |
To be honest, I don't know how much it can compress inside the Go code it lives in.
Currently, it won't. The two can live independently of each other.
Unfortunately we cannot ever update octicons then, as they no longer have a webfont. (Though there are some third-party libraries that seem to be attempting to re-create the webfonts) |
There are ways to achieve that. The backend could serve a "spritemap" in HTML and individual images could be referenced via https://github.com/cascornelissen/svg-spritemap-webpack-plugin |
@silverwind I don't mind svg icons but I don't like that icons are being generated in html templates from go code |
Yeah, agree on that one, that kills them for any frontend usage. Ideally I'd like to see us having a directory of SVGs to be bundled into one file via webpack or similar. Then, both backend and frontend code can load them via |
@guillep2k I have sent a PR #7109 to add compress to embbed resources. But that may have some conflict with macaron static middleware. That needs more work. |
The performance aspect of using SVGs is a hairy problem. There are pros and there are cons:
There may be a technique to send all possible icons in a single SVG file to the client and resource from that, a concept similar to a spritemap but in the form of a XML file with all the SVGs inside as snippets, managed by a web worker that can slice by ID. I've never tried this, so I don't know if it's taxing for the user agent, but from the network point of view it should be on par with the font option. |
I think ideal usage would indeed be a spritemap. I only went this route because I am more comfortable with Go than the JS ecosystem. |
@guillep2k spritemap is one single request, just like a webfont. It can be inlined in HTML too, thought that will not be so easy for us as HTML is not in webpack (yet). |
Thought it could be baked right into a go template too I guess in a readable format like <svg xmlns="http://www.w3.org/2000/svg" style="display: none">
<symbol id="codepen" viewBox="0 0 64 64">
<path etc.../>
</symbol>
<symbol id="youtube" viewBox="0 0 64 64">
<path etc.../>
</symbol>
<symbol id="twitter" viewBox="0 0 64 64">
<path etc.../>
</symbol>
</svg> then include that template in |
Oh, that's what I was talking about. I didn't know the term spritemap was used beyond bitmaps. 😝 Inlining seems inefficient, because we won't be able to cache it. Seems to me that it's better off as a separate resource, that can be cached. |
Closing this PR, it seems we've come to a proposed solution. |
This is an exploratory PR looking to (incrementally) replace the webfont Octicons with SVGs using https://gitea.com/go-icon/octicon
The version of octicons we use is one of the last before they abandoned webfonts and moved to only SVGs.
The vendored library basically converts the SVGs into Go-code that can be used to inline them.
Updating it is trivial compared to a webfont (not to mention we can't update it otherwise, as noted above)
For this draft, I updated the repository header icons for a preview.




Images are with no avatar, though it also updates the icons placed after the repo name if there is an avatar.