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

Fix(styling): Make the Swagger UI Operation page more responsive on smaller screen #9325

Merged

Conversation

pedoch
Copy link
Contributor

@pedoch pedoch commented Oct 20, 2023

Make the Swagger UI page more responsive on smaller screens.

Description

This PR does the following:

  • Allows the Search input in the TopBar wrap under the logo at a breakpoint of 550px, when the screen is too small to contain both on the same line. [Screenshot section 1]
  • Stops the icon in the Authorize Button from moving under the text when space becomes too tight. [Screenshot section 2]
    • Instead, the Authorize Button itself moves to the next line to create more space for the icon to stay in place.
  • Lastly, it allows the operation path to be viewed more easily on smaller screens by moving the operation description below the path and reducing the font-size of the operation method. [Screenshot section 3]

Motivation and Context

These changes will improve the responsiveness of Swagger UI on smaller screens. It started off as a fix for this issue - #8940 but grew to a general responsiveness improvement.

Resolves #8940

How Has This Been Tested?

I tested these style changes using multiple devices on multiple platforms with different screen sizes.
Also, because these are just styling changes no new tests are needed and all existing tests pass.

Screenshots (if appropriate):

[1] TopBar Screenshot

Before:
image
After:
Screenshot from 2023-10-19 23-27-29

[2] Authorize Button Screenshot

Before:
image
After:
Screenshot from 2023-10-19 23-27-46

[3] Operation Summary Screenshots

Before:
image
After:
image

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

@pedoch pedoch force-pushed the bug/fix-operation-page-responsiveness branch from 7e32234 to 6524fe4 Compare October 20, 2023 00:11
@pedoch pedoch changed the title Fix(responsiveness): Make the Swagger UI Operation page more responsive on smaller screen Fix(styling): Make the Swagger UI Operation page more responsive on smaller screen Oct 20, 2023
@pedoch pedoch force-pushed the bug/fix-operation-page-responsiveness branch from aa1dc8f to 7001058 Compare October 20, 2023 17:28
@char0n
Copy link
Member

char0n commented Nov 10, 2023

Hi @pedoch, thank you for the PR. I've tested locally and it works well. The only noticeable negative effect is that the Copy button that appears onhover shifts the size of the texts, but that not something that your canges have caused.

image

Copy link
Member

@char0n char0n left a comment

Choose a reason for hiding this comment

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

LGTM

@char0n char0n merged commit e34d8fb into swagger-api:master Nov 10, 2023
6 checks passed
@AlexanderKhudoev
Copy link

AlexanderKhudoev commented Nov 15, 2023

Now the Authorize button moved to the Left side..
You need remove display: flex from .schemes style to make align Authorize button to the Right side..
sw
photo_2023-11-15_18-06-47

@char0n
Copy link
Member

char0n commented Nov 15, 2023

@AlexanderKhudoev would you mind issuing a PR?

@AlexanderKhudoev
Copy link

@AlexanderKhudoev would you mind issuing a PR?

I unfortunately don't have time to do that yet.
Even if I release the fixes, the very "idea" of optimizing the UI on "mobile devices" after the fix will go back to the state it was 5 days ago, before @pedoch commit

I don't know anyone who uses Swagger on mobile devices. In my practice for 10 years, everyone has only used Swagger through the Desktop browser.

And now, having moved the Authorize button to the left, it's become awkward to use Swagger on Desktops.

@pedoch
Copy link
Contributor Author

pedoch commented Nov 15, 2023

Apologies, I didn't notice this when testing. @char0n I can push a fix for it if given a couple of hours.

cc: @AlexanderKhudoev

@pedoch
Copy link
Contributor Author

pedoch commented Nov 16, 2023

@AlexanderKhudoev it turns out the reason the button was on the left in your screenshot was because the Schemes selector was not present. I failed to take that into account as it was always present while I was working on the issue.

@char0n I have now raised this PR: #9387 which takes this into account and ensures the Authorize button is always on the right on larger screens. Please feel free to take a look at it and approve/merge if you think the proposed solution makes sense.

@char0n
Copy link
Member

char0n commented Nov 20, 2023

Thank you both @AlexanderKhudoev and @pedoch for early regression report and fix.

char0n pushed a commit that referenced this pull request Nov 20, 2023
@bshain-vtinfo
Copy link

Hey there @pedoch , while this is a few months after this has gone in, I believe the changes in this PR introduced a regression around setting displayOperationId: true. It pushes the last few characters of the operation id onto a second line & makes the text much harder to read.

E.x. on version 5.9.4 (after this change went in):

image

And on version 5.9.3 (before this change went in):

image

I haven't seen a fix go up yet for this anywhere, so just wanted to call it out at least.

@char0n
Copy link
Member

char0n commented Jan 17, 2024

Hi @bshain-vtinfo,

Thanks a lot for the report. Would you try to investigate and issue a fixing PR? We would really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compensate Operation content in lower resolution sizes
4 participants