colours.dalfuss.link/index.html
2024-12-23 01:30:27 +01:00

52 lines
No EOL
2.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
<link rel="stylesheet" href="./css/custom.css">
</head>
<body>
<div class="popup" id="popup"> Copied color: <span id="popupText"></span> </div>
<h1><img class="logo" src="./images/logo.png" alt="Controller Icon with a blue to pink to blue gradient"></h1>
<p>These are the colours <a href="https://dalfuss.link">I</a> use!</p>
<h2 style="color: #F5A9B8">Dalfuss "Brand" Colours</h2>
<div class="palette">
<div class="color" style="background-color: #f5a9b8;">#F5A9B8</div>
<div class="color" style="background-color: #5bcffa;">#5BCFFA</div>
<div class="color white" style="background-color: #FFFFFF;">#FFFFFF</div>
<div class="color" style="background-color: #161618;">#161618</div>
</div>
<script>
const colors = document.querySelectorAll(".color");
const popup = document.getElementById("popup");
const popupText = document.getElementById("popupText");
function rgbToHex(rgb) {
const result = rgb.match(/^rgb\((\d+), (\d+), (\d+)\)$/);
if (result) {
const r = parseInt(result[1]).toString(16).padStart(2, '0');
const g = parseInt(result[2]).toString(16).padStart(2, '0');
const b = parseInt(result[3]).toString(16).padStart(2, '0');
return `#${r}${g}${b}`;
}
return rgb; // Falls kein gültiger RGB-Wert gefunden wurde
}
colors.forEach(color => {
color.addEventListener("click", () => {
const colorValue = color.style.backgroundColor;
const hexColor = rgbToHex(colorValue); // Umwandlung in Hex-Code
navigator.clipboard.writeText(hexColor); // Hex-Code in die Zwischenablage kopieren
popupText.innerText = hexColor; // Anzeige des Hex-Codes im Popup
popup.style.display = "block";
setTimeout(() => {
popup.style.display = "none";
}, 2000);
});
});
</script>
</body>
</html>