Skip to content
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

Merged
merged 17 commits into from
Jun 29, 2021

Conversation

imajit
Copy link
Contributor

@imajit imajit commented Jun 15, 2021

Part of #9686
In my last PR I had by reduced the button to the red part in the nav bar
Screenshot from 2021-06-15 16-55-32
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
Screenshot from 2021-06-15 16-56-09

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
Screenshot from 2021-06-15 17-23-28

Dashboard Buttons
Screenshot from 2021-06-16 01-39-38

Subscriptions Page Buttons
Screenshot from 2021-06-16 01-48-07
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.

@imajit imajit requested a review from a team as a code owner June 15, 2021 20:37
@gitpod-io
Copy link

gitpod-io bot commented Jun 15, 2021

@codecov
Copy link

codecov bot commented Jun 15, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@cf6f681). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head d12a468 differs from pull request most recent head d127d0d. Consider uploading reports for the commit d127d0d to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9810   +/-   ##
=======================================
  Coverage        ?   78.24%           
=======================================
  Files           ?       98           
  Lines           ?     5947           
  Branches        ?        0           
=======================================
  Hits            ?     4653           
  Misses          ?     1294           
  Partials        ?        0           

@jywarren
Copy link
Member

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 %>
Copy link
Member

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!

Copy link
Contributor Author

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 😕

Copy link
Member

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?

Copy link
Contributor Author

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

@imajit
Copy link
Contributor Author

imajit commented Jun 16, 2021

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!!!

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,
jQuery(".translationClass").children(":gt(6)").hide();
this will show only 5 globe icons, but I have never tested it on a live server with multiple users.

@jywarren
Copy link
Member

this will show only 5 globe icons, but I have never tested it on a live server with multiple users.

Did you want to try it in the JavaScript dev console on stable.publiclab.org to get a sense for it?

<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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing after comma.

<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)
Copy link

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 =.

Copy link
Member

@jywarren jywarren left a 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?

<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)
Copy link
Member

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 ---

Suggested change
def create_dropdown(href, text)
def create_nav_dropdown_item(href, text)

Copy link
Member

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!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

@jywarren
Copy link
Member

Also, this will need conflicts resolve as well. Thanks for sticking with this @imajit -- much appreciated!

@imajit
Copy link
Contributor Author

imajit commented Jun 22, 2021

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>
@jywarren
Copy link
Member

Ah indeed. You can try resolving directly or rebasing!

jywarren and others added 9 commits June 22, 2021 18:14
* 🐛 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>
@imajit imajit requested a review from a team as a code owner June 23, 2021 18:40
@imajit imajit requested a review from a team as a code owner June 23, 2021 18:40
@codeclimate
Copy link

codeclimate bot commented Jun 23, 2021

Code Climate has analyzed commit d127d0d and detected 0 issues on this pull request.

View more on Code Climate.

@jywarren jywarren merged commit d092648 into publiclab:main Jun 29, 2021
@jywarren
Copy link
Member

Nice! Thanks for doing this so thoroughly, @imajit !!

@imajit imajit deleted the button-fix branch June 30, 2021 13:58
17sushmita added a commit to 17sushmita/plots2 that referenced this pull request Jul 7, 2021
…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>
reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
…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>
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants