-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fixed globe icon placement in buttons by adding left padding #9810
Conversation
Codecov Report
@@ Coverage Diff @@
## main #9810 +/- ##
=======================================
Coverage ? 78.24%
=======================================
Files ? 98
Lines ? 5947
Branches ? 0
=======================================
Hits ? 4653
Misses ? 1294
Partials ? 0 |
Hi @imajit this looks lovely! Thank you for your attention to detail as well! I think we used to limit this to 5 max appearing on the screen so that it's not overwhelming. Did we ever implement that? I think this is fine but that's the only thing I worry a little about here. Do you perhaps want to address that soon too? I don't think it has to block merging this one. Thank you!!! |
<a class="dropdown-item" href="/post?template=event&tags=event"><%= translation('dashboard._header.dropdown.post_event') %></a> | ||
<div class="dropdown-divider"></div> | ||
<a class="dropdown-item" href="/post?tags=blog-submission"><%= translation('dashboard._header.dropdown.tell_story_blog') %></a> | ||
<% if current_user&.has_tag('translation-helper') && I18n.locale != :en %> |
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.
Ooh, actually... this is interesting. This repetition does make for a lot more code... i wonder... what do you think, is there any way to reduce repetition in this while still achieving what we want? What are some ideas to try to brainstorm this?
Sorry to pause a moment, but I hope my hesitation makes sense, @imajit -- still very much appreciate this work!
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.
Yeah, I agree there is a repetition in the code as I'm wrapping the button inside a div so that the globe icon stays inline with the text.
- If I keep the
if
part only, then the button size reduces for all users - If I keep the
else
part, then the globe icon overflows to the next line - I can't store it in a new file as partial as the repetition is kind of nested inside each
div
So, I did this bit ugly implementation to satisfy all cases. One way to avoid this is if I reduce the number of globe icons in the navbar, in that case, there will be less code repetition and fewer number of globe icons on the Dashboard.
For now, I can't see a different way of implementation though 😕
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.
Hmm.... I totally appreciate this is a tough one. Thanks for thinking hard on it. What if... we did it in JavaScript, after rendering? Could that work?
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.
I added a helper function to render the dropdown button, this reduces some repetition
I did read about it in a discussion #5651 (comment) but I don't think it has been implemented, there is a way using jquery to do this, |
Did you want to try it in the JavaScript dev console on stable.publiclab.org to get a sense for it? |
app/helpers/application_helper.rb
Outdated
<i data-toggle='tooltip' data-placement='top' title='Needs translation? Click to help translate this text.' style='position:relative; right:2px; color:#bbb; font-size: 15px;' class='fa fa-globe'></i></a> | ||
</span>)) | ||
else | ||
raw(translated_string) | ||
end | ||
end | ||
|
||
def create_dropdown(href,text) |
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.
Space missing after comma.
app/helpers/application_helper.rb
Outdated
<i data-toggle='tooltip' data-placement='top' title='Needs translation? Click to help translate this text.' style='position:relative; right:2px; color:#bbb; font-size: 15px;' class='fa fa-globe'></i></a> | ||
</span>)) | ||
else | ||
raw(translated_string) | ||
end | ||
end | ||
|
||
def create_dropdown(href,text) | ||
translated_string=translation(text) |
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.
Surrounding space missing for operator =
.
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.
The helper function does look good. I suggested a slight renaming. Does this approach work for the lines in this partial too, like lines 11-26?
app/helpers/application_helper.rb
Outdated
<i data-toggle='tooltip' data-placement='top' title='Needs translation? Click to help translate this text.' style='position:relative; right:2px; color:#bbb; font-size: 15px;' class='fa fa-globe'></i></a> | ||
</span>)) | ||
else | ||
raw(translated_string) | ||
end | ||
end | ||
|
||
def create_dropdown(href, text) |
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.
Ah, this is much cleaner. Could we rename this though so it's a little more specific? Let me think ---
def create_dropdown(href, text) | |
def create_nav_dropdown_item(href, text) |
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.
OK awesome. I think this is one of the last things before we merge, right? Thank you!!
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.
Yeah
Also, this will need conflicts resolve as well. Thanks for sticking with this @imajit -- much appreciated! |
Hmm, I think this is due to some recently added tests , looking into it |
* Reduced globe icon count * Added equal sign Co-authored-by: imajit <ajit.171it233@nitk.edu.in>
Ah indeed. You can try resolving directly or rebasing! |
* 🐛 minor bug fix, addressing issue with first timers adding tags. * ♻️ minor refactor, using function call to compare user role. * ♻️🔥 remove logged_in_as function call in conditional statement. * fixing failing tests by blocking first time posters from adding tags Co-authored-by: 17sushmita <17sushmita@gmail.com>
Code Climate has analyzed commit d127d0d and detected 0 issues on this pull request. View more on Code Climate. |
Nice! Thanks for doing this so thoroughly, @imajit !! |
…ab#9810) * Dropdown fixed * Fixed button 1 * Button fix 2 * Added helper function to render dropdown buttons * added space * Changed function name * Reduced globe icon count (publiclab#9826) * Reduced globe icon count * Added equal sign Co-authored-by: imajit <ajit.171it233@nitk.edu.in> * Update questionRich.html.erb (publiclab#9841) * Addressing issue with first timers adding tags. (publiclab#9829) * 🐛 minor bug fix, addressing issue with first timers adding tags. * ♻️ minor refactor, using function call to compare user role. * ♻️🔥 remove logged_in_as function call in conditional statement. * fixing failing tests by blocking first time posters from adding tags Co-authored-by: 17sushmita <17sushmita@gmail.com> * Dropdown fixed * Fixed button 1 * Button fix 2 * Added helper function to render dropdown buttons * added space * Changed function name Co-authored-by: imajit <ajit.171it233@nitk.edu.in> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com> Co-authored-by: lonwabo <60598841+lonwabo-mnyaiza@users.noreply.github.com> Co-authored-by: 17sushmita <17sushmita@gmail.com>
…ab#9810) * Dropdown fixed * Fixed button 1 * Button fix 2 * Added helper function to render dropdown buttons * added space * Changed function name * Reduced globe icon count (publiclab#9826) * Reduced globe icon count * Added equal sign Co-authored-by: imajit <ajit.171it233@nitk.edu.in> * Update questionRich.html.erb (publiclab#9841) * Addressing issue with first timers adding tags. (publiclab#9829) * 🐛 minor bug fix, addressing issue with first timers adding tags. * ♻️ minor refactor, using function call to compare user role. * ♻️🔥 remove logged_in_as function call in conditional statement. * fixing failing tests by blocking first time posters from adding tags Co-authored-by: 17sushmita <17sushmita@gmail.com> * Dropdown fixed * Fixed button 1 * Button fix 2 * Added helper function to render dropdown buttons * added space * Changed function name Co-authored-by: imajit <ajit.171it233@nitk.edu.in> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com> Co-authored-by: lonwabo <60598841+lonwabo-mnyaiza@users.noreply.github.com> Co-authored-by: 17sushmita <17sushmita@gmail.com>
…ab#9810) * Dropdown fixed * Fixed button 1 * Button fix 2 * Added helper function to render dropdown buttons * added space * Changed function name * Reduced globe icon count (publiclab#9826) * Reduced globe icon count * Added equal sign Co-authored-by: imajit <ajit.171it233@nitk.edu.in> * Update questionRich.html.erb (publiclab#9841) * Addressing issue with first timers adding tags. (publiclab#9829) * 🐛 minor bug fix, addressing issue with first timers adding tags. * ♻️ minor refactor, using function call to compare user role. * ♻️🔥 remove logged_in_as function call in conditional statement. * fixing failing tests by blocking first time posters from adding tags Co-authored-by: 17sushmita <17sushmita@gmail.com> * Dropdown fixed * Fixed button 1 * Button fix 2 * Added helper function to render dropdown buttons * added space * Changed function name Co-authored-by: imajit <ajit.171it233@nitk.edu.in> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com> Co-authored-by: lonwabo <60598841+lonwabo-mnyaiza@users.noreply.github.com> Co-authored-by: 17sushmita <17sushmita@gmail.com>
Part of #9686


In my last PR I had by reduced the button to the red part in the nav bar
I have corrected that part now the entire button is clickable in cases where globe icon is not there , here entire green part is now clickable
For buttons I have added some left padding in the function,now the icons don't render inside the buttons and in cases where the button occupies the entire width globe icon is rendered below the button

Admin Page Buttons
Dashboard Buttons

Subscriptions Page Buttons

The add button here is a
submit
button and has some tests linked with it. If you feel it is okay with the nested globe icon I can just leave it unchanged, else I'll change it with the globe icon outside the button and change the tests for it in a later PR.