Skip to content

Add Cargo.toml copy button to crate rows #1897

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

Merged
merged 3 commits into from
Nov 20, 2019

Conversation

DSpeckhals
Copy link
Contributor

To copy the most recent version of a crate to the clipboard, users would have to go to the crate's individual page. However, it would probably be convenient to have the same control on the search results page. To accomplish this, a new component was created to encapsulate the copy control and its notifications (success/failure). This new component was added to the search result page; the crate page was reworked to use it as well.

For this first run at the UI, I added the same copy button to the left of the name/link for the result. I'm open to any other ideas too!

Here are some screenshots to illustrate the changes:

Crate Page

Screenshot from 2019-11-14 12-33-09

Screenshot from 2019-11-14 12-32-03

Results Page

Screenshot from 2019-11-14 14-24-57

Fixes #1587

To copy the most recent version of a crate to the clipboard, users would
have to go to the crate's individual page. However, it would probably be
convenient to have the same control on the search results page. To
accomplish this, a new component was created to encapsulate the copy
control and its notifications (success/failure).

Fixes rust-lang#1587
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @carols10cents (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Copy link
Member

@carols10cents carols10cents left a comment

Choose a reason for hiding this comment

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

Thank you so much!!! The copy button works great!!

I wonder if it would look better if the copy button was after the crate name and before the badge? So that the crate name could still be left-aligned and directly above the description? I'm not a designer, but wdyt? I moved the markup over in the browser; the vertical alignment of the crate name, the copy button, and the version badge is messed up but I'm not sure how best to fix it:

Screen Shot 2019-11-15 at 10 57 57 AM

Also, when doing a search and there's a crate whose name matches the search exactly, the "Copied!" text overlaps the clipboard icon a bit for that result:

Screen Shot 2019-11-15 at 10 55 04 AM

Could you try resolving those two things? I'm not great at CSS, but I can spend a bit more time poking at it if you need help.

Also don't worry about the percy failure right now, we're changing the UI so that's expected. I'll approve the changes once we've got them the way we want them.

Thank you!!!

@DSpeckhals
Copy link
Contributor Author

Thank you for the input! Now that I see the copy button to the left of the crate name, I think I like that better. As for the location of the "Copied!" text, I know the problem and I'll correct it.

This allows the name to stay left-aligned. Also, space the "Copied!"
text in a way that better adapts to high DPI displays.
@DSpeckhals
Copy link
Contributor Author

What do you think of these changes? I made the icon a little smaller to better associate it with the crate name; another option would be to make it closer to the height of the badges. I personally like it smaller like the text, but it's not a strong opinion.

image

@carols10cents
Copy link
Member

I like it, thank you!! The badges not being the same height as the text is definitely a pre-existing condition 😥

The "Copied!" text on exact match search results is now overlapping the badges a bit though, not sure if that was supposed to be fixed with this latest commit or not:

Screen Shot 2019-11-18 at 1 19 16 PM

Divs inside of exact matches get a lot of padding, whereas other search
results don't. Defining 0 padding for this div makes  the positioning
correct.
@DSpeckhals
Copy link
Contributor Author

I fixed the notification positioning. It was incorrect in exact matches (like your screenshot).

@carols10cents
Copy link
Member

Looks great!!! Thank you so much!!

@bors r+

@bors
Copy link
Contributor

bors commented Nov 20, 2019

📌 Commit f24e3b3 has been approved by carols10cents

@bors
Copy link
Contributor

bors commented Nov 20, 2019

⌛ Testing commit f24e3b3 with merge 9885991...

bors added a commit that referenced this pull request Nov 20, 2019
…ents

Add Cargo.toml copy button to crate rows

To copy the most recent version of a crate to the clipboard, users would have to go to the crate's individual page. However, it would probably be convenient to have the same control on the search results page. To accomplish this, a new component was created to encapsulate the copy control and its notifications (success/failure). This new component was added to the search result page; the crate page was reworked to use it as well.

For this first run at the UI, I added the same copy button to the left of the name/link for the result. I'm open to any other ideas too!

Here are some screenshots to illustrate the changes:

### Crate Page

![Screenshot from 2019-11-14 12-33-09](https://user-images.githubusercontent.com/3310769/68895522-74884d80-06f7-11ea-9fa4-befbf5f44329.png)

![Screenshot from 2019-11-14 12-32-03](https://user-images.githubusercontent.com/3310769/68895511-6d613f80-06f7-11ea-9d2a-ecdf031325d5.png)

### Results Page
![Screenshot from 2019-11-14 14-24-57](https://user-images.githubusercontent.com/3310769/68895552-836f0000-06f7-11ea-820c-137f772cb2ab.png)

Fixes #1587
@bors
Copy link
Contributor

bors commented Nov 20, 2019

☀️ Test successful - checks-travis
Approved by: carols10cents
Pushing 9885991 to master...

@bors bors merged commit f24e3b3 into rust-lang:master Nov 20, 2019
@DSpeckhals DSpeckhals deleted the search-result-page-copy branch November 20, 2019 20:09
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.

Copyable version on search result page
5 participants