Adding a click to copy function, needs indication that it was successful
This commit is contained in:
		
							
								
								
									
										13
									
								
								js/app.js
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								js/app.js
									
									
									
									
									
								
							@@ -1,3 +1,5 @@
 | 
			
		||||
const clipboard = navigator.clipboard;
 | 
			
		||||
 | 
			
		||||
let app = new Vue({
 | 
			
		||||
  el: '#app',
 | 
			
		||||
 | 
			
		||||
@@ -10,6 +12,8 @@ let app = new Vue({
 | 
			
		||||
    ],
 | 
			
		||||
    inputBox: "ccc\n#4f46e5\n#db2777aa\n",
 | 
			
		||||
 | 
			
		||||
    copyInput: "",
 | 
			
		||||
 | 
			
		||||
    hexRegex: /^\#?[a-f0-9]{3,9}/i,
 | 
			
		||||
    rgbRegex: /^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)/i,
 | 
			
		||||
    rgbaRegex: /^rgba\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*(0(\.[0-9])?|1(\.0)?)\s*\)/i,
 | 
			
		||||
@@ -108,6 +112,7 @@ let app = new Vue({
 | 
			
		||||
          blue = Number.parseInt(blue);
 | 
			
		||||
 | 
			
		||||
          converted.hex = "#" + this.rgbaToHexa(red, green, blue, alpha);
 | 
			
		||||
 | 
			
		||||
          converted.rgb = "rgba(" + red + ", " + green + ", " + blue + ", " + alpha + ")";
 | 
			
		||||
 | 
			
		||||
          let hsl = this.rgbToHsl(red, green, blue);
 | 
			
		||||
@@ -367,6 +372,12 @@ console.error('hexa to HSLa not implemented yet');
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return alpha.toFixed(1);
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    updateClipboard: function (text) {
 | 
			
		||||
      clipboard.writeText(text).then(() => {
 | 
			
		||||
        console.log('text copied!');
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user