Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

maelle
Copy link
Contributor

@maelle maelle commented Jun 25, 2021

Fix #1086

Also related #1040 (currently the copy-code button might hide some code)

Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

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

Great. Can you add NEWS bullet so that we track the different changes ?

I will triage and merge the different bs4_book() items at the end before release to make a single big part on all the changes. Thanks!

@maelle
Copy link
Contributor Author

maelle commented Jun 25, 2021

I'm not sure this should be merged as this can hide text, though?

@maelle
Copy link
Contributor Author

maelle commented Jun 25, 2021

image

@maelle maelle marked this pull request as draft June 25, 2021 08:03
@cderv
Copy link
Collaborator

cderv commented Jun 25, 2021

Thanks. I see.

This is an issue because we show the copy button always, with no opacity. It would probably no be an issue if the button was shown on hover only (like in gitbook())

This is a topic that we are still thinking about (#1040 and associated PR #1041).

Best is to deal with this PR when we will deal with the other.

@maelle
Copy link
Contributor Author

maelle commented Jun 25, 2021

Solution I put together with DevTools:

  • Put the copy div right at the beginning of the pre node. (prepending instead of appending)
  • CSS
pre .copy {
float: right;
margin-left: 1rem;
margin-bottom: 1rem;
}

@maelle
Copy link
Contributor Author

maelle commented Jun 25, 2021

image

@cderv
Copy link
Collaborator

cderv commented Jun 25, 2021

FWIW, quarto as a smaller icon and deal with this by having a padding for the pre block, leaving space between the code part and pre background for the icon

pre.sourceCode.code-with-copy {
    padding-right: 25px;
}

image

This leave the code aligned the same way on the right side.

@cderv
Copy link
Collaborator

cderv commented Jun 25, 2021

with gitbook() the icon is right above the text in the margin
image

@cderv
Copy link
Collaborator

cderv commented Jun 25, 2021

@apreshill we should look into that in the same bundle as the copy button improvement, and uniformisation between outputs.

What are your thoughts on this ?

@cderv cderv requested a review from apreshill June 25, 2021 10:07
@apreshill
Copy link
Contributor

apreshill commented Jun 30, 2021

Hi @cderv looking into this right now. Also another point of comparison is GitHub's new copy icon UI:

apreshill/bs4booktesting#1

Looks like they actually do the scrolling underneath the button on hover.

I like the padding-right idea, but needed to add 60px to clear the button instead of 25px. Here is how that looks:
https://apreshill.github.io/bs4booktesting/

Screen Shot 2021-06-30 at 10 30 22 AM

I wish the padding could be a bit more narrow.

For completeness, here is @maelle's tweak: if we keep the word "copy" I like this solution:

Screen Shot 2021-06-30 at 10 51 08 AM


Using this space to think out loud here:

  1. I'd like to keep the existing behavior of permanent copy button (no reveal just on hover). I think that makes sense for a book output, and is more friendly to readers who may not be programmers.
  2. @hadley might you be open to switching to an icon here? That would decrease the padding needed. We could follow Quarto's lead and use the Bootstrap clipboard icon: https://icons.getbootstrap.com/icons/clipboard/ (maybe switching to this icon after click: https://icons.getbootstrap.com/icons/clipboard-check/). If you want to keep the word copy, we'll go with @maelle's solution.

@hadley
Copy link
Member

hadley commented Jun 30, 2021

I think it makes sense to match quarto here; I'm fine with the icon.

@cderv
Copy link
Collaborator

cderv commented Jul 6, 2021

This branch is now tested in https://cderv.github.io/bs4booktesting/wrap-and-scroll/

and it's look like this
image

Current master looks like this: https://cderv.github.io/bs4booktesting/

image

So this PR:

@apreshill to discuss.

@cderv cderv marked this pull request as ready for review July 6, 2021 14:16
@cderv cderv changed the title no scroll on x overflow bs4_book: no scroll on x overflow and correct copy btn placement Jul 6, 2021
@cderv cderv merged commit dc87225 into rstudio:master Jul 6, 2021
cderv added a commit that referenced this pull request Jul 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy copy button fix
4 participants