Skip to content

Fix TOTP copy button layout with longer code (LG-5436)#5743

Merged
zachmargolis merged 4 commits intomainfrom
margolis-totp-copy-placement
Dec 21, 2021
Merged

Fix TOTP copy button layout with longer code (LG-5436)#5743
zachmargolis merged 4 commits intomainfrom
margolis-totp-copy-placement

Conversation

@zachmargolis
Copy link
Contributor

Follow-up to #5604, which had a small visual regression

before after
mobile Screen Shot 2021-12-21 at 11 06 43 AM Screen Shot 2021-12-21 at 11 06 51 AM
desktop Screen Shot 2021-12-21 at 11 06 20 AM Screen Shot 2021-12-21 at 11 06 08 AM


def generate_totp_secret
ROTP::Base32.random(20)
ROTP::Base32.random(20) # 160-bit secret, per RFC 4226
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not technically related but it was a comment I had before #5604 (comment)

) do %>
<%= t('links.copy') %>
<% end %>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Will give a closer look shortly, but: Do we need this div anymore? One thing I notice is it was applying flex-align-center, which I assume was to vertically center the code and button when they were part of the same line. Since they aren't anymore, probably could at least remove that class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, looking again, I think we could get rid of a lot of the grid stuff that existed previously only to support the horizontal arrangement.

The div could make sense to keep, since code is an inline element, or we could just apply display: block to it.

diff --git a/app/views/users/totp_setup/new.html.erb b/app/views/users/totp_setup/new.html.erb
index 673d99d9e..a6bd05d11 100644
--- a/app/views/users/totp_setup/new.html.erb
+++ b/app/views/users/totp_setup/new.html.erb
@@ -35,15 +35,13 @@
           <%= image_tag @qrcode, skip_pipeline: true, alt: t('image_description.totp_qrcode') %>
         </div>
         <%= t('instructions.mfa.authenticator.manual_entry') %>
-        <div class="grid-row margin-top-2 flex-align-center">
-          <code class="grid-col-fill font-family-mono padding-y-2 padding-x-1 border-base-lighter border-1px text-bold" id="qr-code">
-            <%= @code %>
-          </code>
-        </div>
+        <code class="display-block margin-y-2 font-family-mono padding-y-2 padding-x-1 border-base-lighter border-1px text-bold" id="qr-code">
+          <%= @code %>
+        </code>
         <%= render ClipboardButtonComponent.new(
               clipboard_text: @code.upcase,
               outline: true,
-              class: 'ico ico-copy margin-top-2',
+              class: 'ico ico-copy',
             ) do %>
           <%= t('links.copy') %>
         <% end %>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

love it, thanks! added in 2954f66

Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Suggestion for simplifying the markup further, but technically looks fine as-is 👍

) do %>
<%= t('links.copy') %>
<% end %>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, looking again, I think we could get rid of a lot of the grid stuff that existed previously only to support the horizontal arrangement.

The div could make sense to keep, since code is an inline element, or we could just apply display: block to it.

diff --git a/app/views/users/totp_setup/new.html.erb b/app/views/users/totp_setup/new.html.erb
index 673d99d9e..a6bd05d11 100644
--- a/app/views/users/totp_setup/new.html.erb
+++ b/app/views/users/totp_setup/new.html.erb
@@ -35,15 +35,13 @@
           <%= image_tag @qrcode, skip_pipeline: true, alt: t('image_description.totp_qrcode') %>
         </div>
         <%= t('instructions.mfa.authenticator.manual_entry') %>
-        <div class="grid-row margin-top-2 flex-align-center">
-          <code class="grid-col-fill font-family-mono padding-y-2 padding-x-1 border-base-lighter border-1px text-bold" id="qr-code">
-            <%= @code %>
-          </code>
-        </div>
+        <code class="display-block margin-y-2 font-family-mono padding-y-2 padding-x-1 border-base-lighter border-1px text-bold" id="qr-code">
+          <%= @code %>
+        </code>
         <%= render ClipboardButtonComponent.new(
               clipboard_text: @code.upcase,
               outline: true,
-              class: 'ico ico-copy margin-top-2',
+              class: 'ico ico-copy',
             ) do %>
           <%= t('links.copy') %>
         <% end %>

Co-authored-by: Andrew Duthie <aduth@users.noreply.github.com>
@zachmargolis zachmargolis merged commit 613079e into main Dec 21, 2021
@zachmargolis zachmargolis deleted the margolis-totp-copy-placement branch December 21, 2021 22:23
jmhooper pushed a commit that referenced this pull request Dec 28, 2021
* Fix layout of QR code and copy button with longer code (LG-5436)
* Add some comments that I wanted on the previous PR
* Simplify markup

Co-authored-by: Andrew Duthie <aduth@users.noreply.github.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.

2 participants