Repository navigation
feat(gateway): add cid copy button to directory listings - #899
Merged
Merged
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
VersaliXis
force-pushed
the
gateway-feature
branch
from
March 26, 2025 10:15
a183789 to
d512c70
Compare
Contributor
|
Could you upload a screenshot with this PR? |
Contributor
Author
|
Sure! Here is what it looks like. If you want to change anything in the style, feel free to ask. The code is pretty simple, here is a diff: diff --git a/gateway/assets/directory.html b/gateway/assets/directory.html
index 888ecabf..9201ce83 100644
--- a/gateway/assets/directory.html
+++ b/gateway/assets/directory.html
@@ -59,6 +59,7 @@
<a class="ipfs-hash" translate="no" href={{ if $root.DNSLink }}"https://cid.ipfs.tech/#{{ .Hash | urlEscape}}" target="_blank" rel="noreferrer noopener"{{ else }}"{{ $root.GatewayURL }}/ipfs/{{ .Hash | urlEscape}}?filename={{ .Name | urlEscape }}"{{ end }}>
{{- .ShortHash -}}
</a>
+ <button class="copy-button" onclick="navigator.clipboard.writeText('{{ .Hash }}')">Copy</button>
{{ end }}
</div>
<div class="nowrap" title="Cumulative size of IPFS DAG (data + metadata)">{{ .Size }}</div>
diff --git a/gateway/assets/style.css b/gateway/assets/style.css
index a8dfdaf7..7e4512e7 100644
--- a/gateway/assets/style.css
+++ b/gateway/assets/style.css
@@ -66,6 +66,23 @@ a:visited {
font-family: var(--monospace);
}
+.copy-button {
+ color: #7f8491;
+ background-color: inherit;
+ border: 1px solid var(--dark-white);;
+ border-radius: 2px;
+ padding: 1px 2px;
+ cursor: copy;
+}
+
+.copy-button:hover {
+ background-color: var(--light-white);
+}
+
+.copy-button:active {
+ color: #00b0e9;
+}
+
#header {
align-items: center;
background: var(--navy); |
2color
reviewed
Apr 2, 2025
2color
reviewed
Apr 2, 2025
lidel
requested changes
Apr 2, 2025
VersaliXis
force-pushed
the
gateway-feature
branch
from
April 7, 2025 20:03
2d04486 to
eb3ce56
Compare
Including Adding the copy-icon in assets/icon.css and Adding the description "Copy Hash" on mouse hover
VersaliXis
force-pushed
the
gateway-feature
branch
from
April 7, 2025 20:12
eb3ce56 to
156cce3
Compare
- hand on hover - remove background-based feedback, switch to opacity on click - add copy option to the top
lidel
approved these changes
Apr 7, 2025
This was referenced Apr 10, 2025
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes: #895