File tree Expand file tree Collapse file tree 3 files changed +60
-1
lines changed Expand file tree Collapse file tree 3 files changed +60
-1
lines changed Original file line number Diff line number Diff line change 6
6
<div local-class =" metadata" >
7
7
<h2 local-class =" heading" >Metadata</h2 >
8
8
9
+ <div local-class =" purl" data-test-purl>
10
+ {{ svg-jar " link" }}
11
+ <CopyButton
12
+ @copyText ={{ @version.purl }}
13
+ class =" button-reset"
14
+ local-class =" purl-copy-button"
15
+ >
16
+ <span local-class =" purl-text" >{{ @version.purl }} </span >
17
+ <Tooltip local-class =" purl-tooltip" ><strong >Package URL:</strong > {{ @version.purl }} <small >(click to copy)</small ></Tooltip >
18
+ </CopyButton >
19
+ </div >
20
+
9
21
<time
10
22
datetime ={{ date-format-iso @version.created_at }}
11
23
local-class =" date"
Original file line number Diff line number Diff line change
1
+ import { action } from '@ember/object' ;
1
2
import { service } from '@ember/service' ;
2
3
import Component from '@glimmer/component' ;
3
4
@@ -6,6 +7,7 @@ import { didCancel } from 'ember-concurrency';
6
7
import { simplifyUrl } from './crate-sidebar/link' ;
7
8
8
9
export default class CrateSidebar extends Component {
10
+ @service notifications ;
9
11
@service playground ;
10
12
@service sentry ;
11
13
@@ -39,4 +41,14 @@ export default class CrateSidebar extends Component {
39
41
}
40
42
} ) ;
41
43
}
44
+
45
+ @action
46
+ async copyToClipboard ( text ) {
47
+ try {
48
+ await navigator . clipboard . writeText ( text ) ;
49
+ this . notifications . success ( 'Copied to clipboard!' ) ;
50
+ } catch {
51
+ this . notifications . error ( 'Copy to clipboard failed!' ) ;
52
+ }
53
+ }
42
54
}
Original file line number Diff line number Diff line change 22
22
.msrv ,
23
23
.edition ,
24
24
.license ,
25
- .bytes {
25
+ .bytes ,
26
+ .purl {
26
27
display : flex;
27
28
align-items : center;
28
29
52
53
font-variant-numeric : tabular-nums;
53
54
}
54
55
56
+ .purl {
57
+ align-items : flex-start;
58
+ }
59
+
60
+ .purl-copy-button {
61
+ text-align : left;
62
+ width : 100% ;
63
+ min-width : 0 ;
64
+ cursor : pointer;
65
+
66
+ & : focus {
67
+ outline : 2px solid var (--yellow500 );
68
+ outline-offset : 1px ;
69
+ border-radius : var (--space-3xs );
70
+ }
71
+ }
72
+
73
+ .purl-text {
74
+ word-break : break-all;
75
+ max-width : 100% ;
76
+ overflow : hidden;
77
+ text-overflow : ellipsis;
78
+ white-space : nowrap;
79
+ display : block;
80
+ }
81
+
82
+ .purl-tooltip {
83
+ word-break : break-all;
84
+
85
+ > small {
86
+ word-break : normal;
87
+ }
88
+ }
89
+
55
90
.links {
56
91
> * + * {
57
92
margin-top : var (--space-m );
You can’t perform that action at this time.
0 commit comments