diff --git a/color.js b/color.js new file mode 100644 index 0000000..db36e31 --- /dev/null +++ b/color.js @@ -0,0 +1,33 @@ +let letters = "0123456789ABCDEF"; +let color = '#'; +for (let i = 0; i < 6; i++) { + color += letters[(Math.floor(Math.random() * 16))]; +} + +let favicon = document.getElementById("favicon"); +let copy = document.getElementById("color"); +let text = document.querySelector("#show-text"); +let urlcolor = "https://www.colorhexa.com/" + color.slice(1) + ".png"; + +function copyLabelText() { + let labelText = document.getElementById("color").innerText; + navigator.clipboard.writeText(labelText) +}; + +copy.addEventListener("click", function () { + text.classList.remove("hidden"); + setTimeout(function () { + text.style.opacity = 0; + }, 1000); + text.style.opacity = 100; +}); + +text.addEventListener("transitionend", function () { + text.classList.add("hidden"); + text.style.opacity = 100; +}); + +document.body.style.background = color; +document.querySelector("label").textContent = color; +document.querySelector("title").textContent = color; +favicon.setAttribute("href", urlcolor); diff --git a/index.html b/index.html index 6388daa..d020e1b 100644 --- a/index.html +++ b/index.html @@ -1,82 +1,21 @@ + - randomcolor - + + - -
-
- -
-
- -
-
- + +
+ + + +
- + + \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..b7ed36e --- /dev/null +++ b/style.css @@ -0,0 +1,26 @@ +label { + font-size: 3rem; +} + +p { + font-size: 1.25rem; +} + +main { + font-family: 'Consolas', monospace; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100dvh; + height: 100vh; +} + +.hidden { + display: none; +} + +#show-text { + color: #000; + transition: opacity 1s; +} \ No newline at end of file