-
Notifications
You must be signed in to change notification settings - Fork 322
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
ENH: add icon_links option for custom navbar icons (with docs and pypi example) #293
ENH: add icon_links option for custom navbar icons (with docs and pypi example) #293
Conversation
I think this is great, thanks @bollwyvl - my one question is whether we should just put the "dedicated social media" links through a deprecation cycle and recommend that all users use the generic "icon links" approach here. WDYT? Also - could you add a test? |
Are there any good examples of good language for a deprecation like that? And are you thinking just in docs, or starting to throw warnings during builds? I hate being that guy 😢 but you're right, probably the right thing to do. I'll get on the tests, though! |
And I'm not overly-attached to "icon_links" as a name either, but couldn't think of anything else at the right level of generality... |
Also would it be reasonable to add a |
Hm, as I'm looking at this: i wonder if it isn't worth taking a step back and thinking about some of the navbar stuff more broadly. Is it worth there being a (future) unification of |
hmmm - well the external links currently have a different place in the UI (next to the site's main links) rather than in the icons section. Plus, I think that ultimately we should be using Sphinx's functions to define the links in the navbar rather than our own custom functions (that way you'd specify external links in the navbar the same way you'd do so in any other sphinx site - via I think "icon links" is a reasonable name, esp if we keep it to icons-only :-) if we use this, we should define the icon links in a separate template so that downstream themes can reuse that section (e.g. via |
Thanks @bollwyvl! Yeah, giving the different placement currently in the navbar, I am not sure combining it with external links is best. But at least this refactor to "icon_links" makes the pattern more consistent with "external_links".
+1 One advantage of keeping some of the most used "social links" instead of deprecating them, is that you don't need to know what the name of the fa icon is. Of course, good documentation could also alleviate that to some extent. |
Sidenote here, I am planning to give this repo a bit more love over the holidays (plan ..), and that would certainly be on my radar then! |
Great, #219 sounds good if it allows for all of the flexibility needed. I'll concentrate on other stuff! |
@bollwyvl to be clear #219 would only fix the "external links in the navbar" issue but not the original issue this PR addresses (icon links) so I think we should def get this one in as well! @jorisvandenbossche good point about the short-hand, what if we allowed for another field in icon-links like |
Indeed, we are going to want to keep the functionality of "icon_links" anyway, that's not directly related to #219
Ah, yes, that could also be an option. Still another option to have this idea of shorthands, but simply for the "icon" field, instead of introducing another field? So for the "icon" field, we can check for some known values ("github", "twitter", etc), and otherwise assume it are correct fab names? |
@jorisvandenbossche yeah I like that for "icon" - what if we just said "if |
ok, opened it back up! Though did make some progress on the so... the entire inventory of icons is available at build time:
an entry looks like this:
We could dump that to JSON, stick it in the rendering context, and give us a lot of bang for the buck, e.g. ...
icon_links = [
{"icon": "twitter-square"}
] If If It could also pull the label, etc. though Heck, we could even generate a dumb python file that gave you autocomplete on the keys. |
Ok, mostly updated with review comments... I wasn't sure exactly what reuse/overload pattern is desired. Also changed the |
Interesting about the yml...the one thing I’m not sure of is where the prefix (eg fab vs fa etc) would be found, I don’t see that in the data file. Perhaps we can just assume fab is the default prefix, and then if people want to use the other fa prefixes they can specify manually? |
I don't think assuming anything about Other People's CSS is safe, over time. If someone wants a cat icon, give'm a cat icon, and don't expect it to be CatCorp. I do note that the CSS currently does special stuff for However: as I suggested in the code snippet, if we did hoist the YAML, reading off Anyhow: forgoing any data-driven stuff (which i will happily explore, on this PR or on a follow-up, if there's some agreement it would be useful), I'm not sad about sending people to the FontAwesome docs which are, well, awesome, and one can see all the info needed on the icon detail page to "do it the hard way": |
Ahh I see now what you’re doing by pulling just the first letter of that field. Yeah that could definitely work. Though to your point about the FA docs being awesome, I feel like a good first step is to ask users to manually specify the icon according to the FA docs, and explore a future improvement of getting more clever with figuring out the right prefix and such. |
Actually, the bigger icons look like trash when used in other places. Will try some other stuff... |
62ead20
to
61e67c6
Compare
One concrete thing we could do is have an icon test sheet in the docs site... though maybe that belongs to the "future work" piece... |
I agree that for now, it seems perfectly fine to require people to specify the full fontawesome name (as it's basically copying that from the icon doc page on fontawesome docs). We can explore fancier automatic stuff later ;-) Given that we currently include specific coloring for github/twitter, it's maybe fine to keep special casing this? (or at least keeping the css for it?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
|
||
i.fa-twitter-square:before { | ||
color: #55acee; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we intend to keep that in our css, it might be worth mentioning that this is already done for twitter and github, so it's clear that you don't need to do the above manually for twitter/github?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in d616236!
docs/user_guide/configuring.rst
Outdated
} | ||
|
||
|
||
The value of ``icon`` can be any full | ||
`FontAwesome 5 Free <https://fontawesome.com/icons?d=gallery&m=free>`__. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be missing a word in the sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in d616236!
src/scss/index.scss
Outdated
|
||
/* Social media buttons */ | ||
|
||
i { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include this in the navbar-icon-links
selector above, so those colors are only used there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limited in d616236!
hey @bollwyvl - this is a cool PR! Any interest in giving a little push to get it over the finish line? |
It appears all the comments were addressed... if there's anything else, please let me know! |
src/scss/index.scss
Outdated
|
||
/* Social media buttons */ | ||
|
||
.navbar-icon-links i { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.navbar-icon-links i { | |
#navbar-icon-links i { |
Thanks for the updates! |
@jorisvandenbossche thanks for the review! I moved the selector up, looking correct now on RTD: |
This looks great to me! I think from a functionality perspective I am +1 on merging. I have one quick under-the-hood question. Do you think that the I think of |
I think raising the overall page architecture question to a higher-level issue is appropriate here... I'll take a stab at a strawman, but would echo not blocking this merge, rather we can refer to it as an example, perhaps. The scope of what had to change (e.g. docs, gold master html) is not something I'd like to re-do/re-review at this stage in this PR... it is a relatively small change, and still touched 11 files! |
{% endif %} | ||
</ul> | ||
{%- block icon_links -%} | ||
{%- include "icon-links.html" with context -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{%- include "icon-links.html" with context -%} | |
{%- include "_templates/icon-links.html" with context -%} |
Just to be clear, I wasn't suggesting that we re-work the architecture of the layout in this PR, I just meant that we move icon-links.html
to _templates/icon-links.html
, and then make this change.
@bollwyvl good point that I don't think this should be blocking. If the suggestion seems like "no brainer" to you, then go for it, but if you think it's more nuanced than this, I suggest we just merge this in and then iterate in your discussion issue 👍 |
OK, let's keep it as a follow-up, and merge this. Thanks again @bollwyvl ! |
Thanks all! Every little bit moves forward!
|
This adds
icon_links
tohtml_theme_options
, as well as labels to the existing few, and an example which points to PyPI (with a non-brand
-style icon).snake
looks cool, but is not freeAs a screen reader might describe it:
b
rand