generated from ipfs/ipfs-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 115
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
feat(gateway): add cid copy button to directory listings #899
Merged
Conversation
This file contains 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
This comment was marked as outdated.
This comment was marked as outdated.
a183789
to
d512c70
Compare
Could you upload a screenshot with this PR? |
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
2d04486
to
eb3ce56
Compare
Including Adding the copy-icon in assets/icon.css and Adding the description "Copy Hash" on mouse hover
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
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