FredrikNoren / ungit

The easiest way to use git. On any platform. Anywhere.
MIT License
10.42k stars 637 forks source link

Add clipboard button on commit #1462

Closed wmertens closed 3 years ago

wmertens commented 3 years ago

Right now, it shows when you hover or click the commit. How can I make it also show when I just hover over the commit hash?

Should this have a test? What should it test?

campersau commented 3 years ago

Please note that navigator.clipboard.writeText will only work on localhost and https sites. Since ungit can bind to other hostnames as well (or all 0.0.0.0) this would not work in these cases.

Note that the API only works when served over secured domains (https) or localhost and when the page is the browser's currently active tab.

https://web.dev/async-clipboard/#security-and-permissions

See also https://stackoverflow.com/a/30810322 for possible workarounds. You can test this scenario by setting ungitBindIp to 0.0.0.0 and then load ungit with http://[yourcomputername]:8448


ungit uses octicon icons everywhere else so I think it would be better to use them here too. E.g. https://primer.style/octicons/clippy-16


What do you think about making the button smaller like btn-xs?

wmertens commented 3 years ago

@campersau actually I'm a complete n00b at KO and I'm working on the nodegit branch, this was a quick hack to get a feel for it. If you were to implement your suggestions I'd be really grateful :sweat_smile: (if not, I totally understand, I'm just saying that I wouldn't feel offended in the least if you implemented this properly, on the contrary)

campersau commented 3 years ago

@wmertens How do you like that? image

Ref: https://github.com/FredrikNoren/ungit/issues/108

wmertens commented 3 years ago

@campersau :100: :heart_eyes:

wmertens commented 3 years ago

I just wonder how to show the button when you hover over the commit message, not the commit node. That way you can quickly copy an oid from the page.

campersau commented 3 years ago

Or just keep the button always visible regardless of mouseover?

wmertens commented 3 years ago

Hmm right, I was worrying that it adds too much visual noise

campersau commented 3 years ago

@wmertens this is how you would only show the button on mouseenter / mouseleave but since the button is higher than the text it moves the files a bit down when it gets rendered. So for simplicity I am going to show the button when the node is selected. https://github.com/FredrikNoren/ungit/commit/4530d032839c868ff009abb8b603f670eb0e6879