@@ -15,71 +15,64 @@ export function copyCodeToClipboard(
15
15
attribute : string ,
16
16
outputElement : HTMLElement
17
17
) : void {
18
- const copyCodeButton = < HTMLElement > (
19
- document . querySelector ( `[data-download=${ attribute } -code]` )
20
- ) ;
21
- copyCodeButton . addEventListener ( 'click' , ( ) : void => {
22
- actOnGenerator ( ) ;
23
- } ) ;
18
+ actOnGenerator ( attribute , outputElement ) ;
19
+ }
24
20
25
- function actOnGenerator ( ) {
26
- let codeToCopy = '' ;
27
- let element ;
28
- switch ( attribute ) {
29
- case 'pic-text' :
30
- codeToCopy = `
31
- div {
32
- background-position: ${ outputElement . style . backgroundPosition } ;
33
- background-size: ${ outputElement . style . backgroundSize } ;
34
- background-repeat: ${ outputElement . style . backgroundRepeat } ;
35
- background-clip: ${ outputElement . style . backgroundClip } ;
36
- -webkit-background-clip: ${ outputElement . style . webkitBackgroundClip } ;
37
- -webkit-text-fill-color: ${ outputElement . style . webkitTextFillColor } ;
21
+ function actOnGenerator ( attribute : string , outputElement : HTMLElement ) {
22
+ let codeToCopy = '' ;
23
+ let element ;
24
+ switch ( attribute ) {
25
+ case 'pic-text' :
26
+ codeToCopy = `
27
+ div {
28
+ background-position: ${ outputElement . style . backgroundPosition } ;
29
+ background-size: ${ outputElement . style . backgroundSize } ;
30
+ background-repeat: ${ outputElement . style . backgroundRepeat } ;
31
+ background-clip: ${ outputElement . style . backgroundClip } ;
32
+ -webkit-background-clip: ${ outputElement . style . webkitBackgroundClip } ;
33
+ -webkit-text-fill-color: ${ outputElement . style . webkitTextFillColor } ;
34
+ }
35
+ ` ;
36
+ break ;
37
+ case 'gradient-text' :
38
+ codeToCopy = `
39
+ p{
40
+ font-size: ${ ( outputElement . children [ 0 ] as HTMLElement ) . style . fontSize } ;
41
+ background: ${
42
+ ( outputElement . children [ 0 ] as HTMLElement ) . style . backgroundImage
43
+ } ;
44
+ background-clip: 'text';
45
+ -webkit-background-clip: 'text';
46
+ -webkit-text-fill-color: 'transparent';
38
47
}
39
- ` ;
40
- break ;
41
- case 'gradient-text' :
42
- codeToCopy = `
43
- p{
44
- font-size: ${
45
- ( outputElement . children [ 0 ] as HTMLElement ) . style . fontSize
46
- } ;
47
- background: ${
48
- ( outputElement . children [ 0 ] as HTMLElement ) . style . backgroundImage
49
- } ;
50
- background-clip: 'text';
51
- -webkit-background-clip: 'text';
52
- -webkit-text-fill-color: 'transparent';
48
+ ` ;
49
+
50
+ break ;
51
+ case 'gradient-border' :
52
+ element = outputElement . style ;
53
+ codeToCopy = `
54
+ div {
55
+ border: ${ element . border } ,
56
+ border-width: ${ element . borderWidth } ,
57
+ border-image-slice: ${ element . borderImageSlice } ,
58
+ border-image-source: ${ element . borderImageSource } ,
53
59
}
54
- ` ;
55
-
56
- break ;
57
- case 'gradient-border' :
58
- element = outputElement . style ;
59
- codeToCopy = `
60
- div {
61
- border: ${ element . border } ,
62
- border-width: ${ element . borderWidth } ,
63
- border-image-slice: ${ element . borderImageSlice } ,
64
- border-image-source: ${ element . borderImageSource } ,
65
- }
66
- ` ;
67
- break ;
68
- case 'gradient-background' :
69
- element = outputElement . style ;
70
- codeToCopy = `
71
- div {
72
- height: 100px;
73
- width: 100px;
74
- background: ${ element . backgroundImage } ;
75
- }
76
- ` ;
77
- }
78
-
79
- copy ( codeToCopy ) ;
60
+ ` ;
61
+ break ;
62
+ case 'gradient-background' :
63
+ element = outputElement . style ;
64
+ codeToCopy = `
65
+ div {
66
+ height: 100px;
67
+ width: 100px;
68
+ background: ${ element . backgroundImage } ;
69
+ }
70
+ ` ;
71
+ break ;
80
72
}
81
- }
82
73
74
+ copy ( codeToCopy ) ;
75
+ }
83
76
/**
84
77
* @function countForText
85
78
* @summary Counts the number of text in the input element
0 commit comments