File tree Expand file tree Collapse file tree 6 files changed +106
-97
lines changed Expand file tree Collapse file tree 6 files changed +106
-97
lines changed Original file line number Diff line number Diff line change 48
48
<div data-test-install>
49
49
<h2 local-class =" heading" >Install</h2 >
50
50
51
- <p local-class =" copy-help" >Run the following Cargo command in your project directory:</p >
52
- {{ #if (is-clipboard-supported )}}
53
- <CopyButton
54
- @copyText ={{ this.cargoAddCommand }}
55
- title =" Copy command to clipboard"
56
- local-class =" copy-button"
57
- >
58
- <span local-class =" selectable" >{{ this.cargoAddCommand }} </span >
59
- {{ svg-jar " copy" aria-hidden =" true" local-class =" copy-icon" }}
60
- </CopyButton >
61
- {{ else }}
62
- <code local-class =" copy-fallback" >
63
- {{ this.cargoAddCommand }}
64
- </code >
65
- {{ /if }}
66
-
67
- <p local-class =" copy-help" >Or add the following line to your Cargo.toml:</p >
68
- {{ #if (is-clipboard-supported )}}
69
- <CopyButton
70
- @copyText ={{ this.tomlSnippet }}
71
- title =" Copy Cargo.toml snippet to clipboard"
72
- local-class =" copy-button"
73
- >
74
- <span local-class =" selectable" >{{ this.tomlSnippet }} </span >
75
- {{ svg-jar " copy" aria-hidden =" true" local-class =" copy-icon" }}
76
- </CopyButton >
77
- {{ else }}
78
- <code local-class =" copy-fallback" >
79
- {{ this.tomlSnippet }}
80
- </code >
81
- {{ /if }}
51
+ <CrateSidebar::InstallInstructions
52
+ @crate ={{ @crate.name }}
53
+ @version ={{ @version.num }}
54
+ @exactVersion ={{ @requestedVersion }}
55
+ />
82
56
</div >
83
57
{{ /unless }}
84
58
Original file line number Diff line number Diff line change @@ -14,18 +14,6 @@ export default class CrateSidebar extends Component {
14
14
return homepage && ( ! repository || simplifyUrl ( repository ) !== simplifyUrl ( homepage ) ) ;
15
15
}
16
16
17
- get cargoAddCommand ( ) {
18
- return this . args . requestedVersion
19
- ? `cargo add ${ this . args . crate . name } @=${ this . args . requestedVersion } `
20
- : `cargo add ${ this . args . crate . name } ` ;
21
- }
22
-
23
- get tomlSnippet ( ) {
24
- let version = this . args . version . num . split ( '+' ) [ 0 ] ;
25
- let exact = this . args . requestedVersion ? '=' : '' ;
26
- return `${ this . args . crate . name } = "${ exact } ${ version } "` ;
27
- }
28
-
29
17
get playgroundLink ( ) {
30
18
let playgroundCrates = this . playground . crates ;
31
19
if ( ! playgroundCrates ) return ;
Original file line number Diff line number Diff line change 50
50
font-variant-numeric : tabular-nums;
51
51
}
52
52
53
- .copy-help {
54
- font-size : 12px ;
55
- }
56
-
57
- .copy-button ,
58
- .copy-fallback {
59
- display : flex;
60
- width : 100% ;
61
- align-items : center;
62
- justify-content : space-between;
63
- padding : var (--space-2xs ) var (--space-xs );
64
- font-family : var (--font-monospace );
65
- font-size : 14px ;
66
- line-height : 1.5em ;
67
- color : var (--main-color );
68
- background : transparent;
69
- border-radius : var (--space-3xs );
70
- border : solid var (--space-4xs ) var (--gray-border );
71
-
72
- span {
73
- flex : auto;
74
- display : block;
75
- word-break : break-word;
76
- }
77
- }
78
-
79
- .copy-button {
80
- text-align : start;
81
- cursor : pointer;
82
-
83
- & : hover {
84
- background-color : light-dark (white, # 141413 );
85
- }
86
- }
87
-
88
- .copy-icon {
89
- flex-shrink : 0 ;
90
- height : 1.1em ;
91
- width : auto;
92
- /* for slightly nicer alignment... */
93
- margin-top : -3px ;
94
- margin-left : var (--space-2xs );
95
- opacity : 0 ;
96
- transition : opacity var (--transition-fast );
97
-
98
- .copy-button : hover & {
99
- opacity : 1 ;
100
- }
101
- }
102
-
103
- .selectable {
104
- user-select : text;
105
- }
106
-
107
53
.links {
108
54
> * + * {
109
55
margin-top : var (--space-m );
Original file line number Diff line number Diff line change
1
+ <p local-class =" copy-help" >Run the following Cargo command in your project directory:</p >
2
+
3
+ {{ #if (is-clipboard-supported )}}
4
+ <CopyButton
5
+ @copyText ={{ this.cargoAddCommand }}
6
+ title =" Copy command to clipboard"
7
+ local-class =" copy-button"
8
+ >
9
+ <span local-class =" selectable" >{{ this.cargoAddCommand }} </span >
10
+ {{ svg-jar " copy" aria-hidden =" true" local-class =" copy-icon" }}
11
+ </CopyButton >
12
+ {{ else }}
13
+ <code local-class =" copy-fallback" >
14
+ {{ this.cargoAddCommand }}
15
+ </code >
16
+ {{ /if }}
17
+
18
+ <p local-class =" copy-help" >Or add the following line to your Cargo.toml:</p >
19
+
20
+ {{ #if (is-clipboard-supported )}}
21
+ <CopyButton
22
+ @copyText ={{ this.tomlSnippet }}
23
+ title =" Copy Cargo.toml snippet to clipboard"
24
+ local-class =" copy-button"
25
+ >
26
+ <span local-class =" selectable" >{{ this.tomlSnippet }} </span >
27
+ {{ svg-jar " copy" aria-hidden =" true" local-class =" copy-icon" }}
28
+ </CopyButton >
29
+ {{ else }}
30
+ <code local-class =" copy-fallback" >
31
+ {{ this.tomlSnippet }}
32
+ </code >
33
+ {{ /if }}
Original file line number Diff line number Diff line change
1
+ import Component from '@glimmer/component' ;
2
+
3
+ export default class InstallInstructions extends Component {
4
+ get cargoAddCommand ( ) {
5
+ return this . args . exactVersion
6
+ ? `cargo add ${ this . args . crate } @=${ this . args . version } `
7
+ : `cargo add ${ this . args . crate } ` ;
8
+ }
9
+
10
+ get tomlSnippet ( ) {
11
+ let version = this . args . version . split ( '+' ) [ 0 ] ;
12
+ let exact = this . args . exactVersion ? '=' : '' ;
13
+ return `${ this . args . crate } = "${ exact } ${ version } "` ;
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ .copy-help {
2
+ font-size : 12px ;
3
+ }
4
+
5
+ .copy-button ,
6
+ .copy-fallback {
7
+ display : flex;
8
+ width : 100% ;
9
+ align-items : center;
10
+ justify-content : space-between;
11
+ padding : var (--space-2xs ) var (--space-xs );
12
+ font-family : var (--font-monospace );
13
+ font-size : 14px ;
14
+ line-height : 1.5em ;
15
+ color : var (--main-color );
16
+ background : transparent;
17
+ border-radius : var (--space-3xs );
18
+ border : solid var (--space-4xs ) var (--gray-border );
19
+
20
+ span {
21
+ flex : auto;
22
+ display : block;
23
+ word-break : break-word;
24
+ }
25
+ }
26
+
27
+ .copy-button {
28
+ text-align : start;
29
+ cursor : pointer;
30
+
31
+ & : hover {
32
+ background-color : light-dark (white, # 141413 );
33
+ }
34
+ }
35
+
36
+ .copy-icon {
37
+ flex-shrink : 0 ;
38
+ height : 1.1em ;
39
+ width : auto;
40
+ /* for slightly nicer alignment... */
41
+ margin-top : -3px ;
42
+ margin-left : var (--space-2xs );
43
+ opacity : 0 ;
44
+ transition : opacity var (--transition-fast );
45
+
46
+ .copy-button : hover & {
47
+ opacity : 1 ;
48
+ }
49
+ }
50
+
51
+ .selectable {
52
+ user-select : text;
53
+ }
You can’t perform that action at this time.
0 commit comments