diff --git a/Y/Scripts/yfold.js b/Y/Scripts/yfold.js
index 8b0c3d0..18c3f5a 100644
--- a/Y/Scripts/yfold.js
+++ b/Y/Scripts/yfold.js
@@ -79,3 +79,48 @@ function toggleYfold(id) {
var expand = content.classList.contains("anim-hide") || content.classList.contains("hidden") ;
setStatus(id, expand, content, true) ;
}
+
+/*********************************
+
+ Du js pour les codes snippets !
+ - theme sombre/clair
+ - copier le texte
+
+**********************************/
+
+window.onload = function() {
+ console.log("DOM loaded.")
+ var snippet = document.getElementsByTagName("code")[0];
+ console.log(snippet);
+
+ let img = document.createElement('div');
+ img.innerHTML = '';
+ img.addEventListener('click', function() {
+ console.log(snippet.innerText);
+ navigator.clipboard.writeText(snippet.innerText).then(function() {
+ console.log("copiƩ !");
+ img.classList = "valid"
+ }, function() {
+ console.log("pas copiƩ !");
+ img.classList = "not-valid"
+ });
+ });
+
+ let theme = document.createElement('div');
+ theme.setAttribute("class", "theme");
+ theme.innerHTML = '';
+
+ theme.addEventListener('click', function() {
+ snippet.classList.toggle("light");
+ console.log("theme switched !");
+ if (theme.classList == "theme darken") {
+ theme.classList = "theme lighten";
+ } else {
+ theme.classList = "theme darken";
+ }
+ });
+
+
+ snippet.appendChild(img)
+ snippet.appendChild(theme)
+};
diff --git a/Y/ystyle.css b/Y/ystyle.css
index ee6fba1..a251d38 100644
--- a/Y/ystyle.css
+++ b/Y/ystyle.css
@@ -211,8 +211,9 @@ footer .pcom a {
/* PAGE DE CODE */
code {
+ position: relative;
z-index: 2;
- background: #000;
+ background: rgba(19,19,19,.8);
width: min(94vw, 900px);
border-radius: 12px;
margin-left: 3vw;
@@ -237,6 +238,40 @@ code * {
display: inline;
}
+code div {
+ position: absolute;
+ top: 12px;
+ right: 12px;
+ padding: 6px;
+ border-radius: 8px;
+ height: 42px;
+ width: 42px;
+ background: #333;
+}
+
+code div.theme {
+ right: 62px;
+}
+
+code div svg {
+ height: 30px;
+ width: 30px;
+ filter: invert(1);
+}
+
+code div.valid {
+ background: #181;
+}
+
+code div.not-valid {
+ background: #811;
+}
+
+code div.valid, code div.not-valid, code div.darken {
+ animation-name: shake;
+ animation-duration: .6s;
+}
+
span.comment {
font-style: italic;
color: rgb(128, 139, 150);
@@ -244,17 +279,17 @@ span.comment {
}
span.kw {
- color: rgb(227,99,99);
-}
-
-span.type {
color: rgb(203, 128, 53);
}
-span.fname {
+span.type {
color: rgb(203, 203, 53);
}
+span.fname {
+ color: #72e0d1;
+}
+
span.string {
color: rgb(53, 203, 128);
}
@@ -352,3 +387,31 @@ span.uident{
margin-bottom: 0;
}
}
+
+@keyframes shake {
+ 0% {
+ transform: translateX(0%);
+ }
+
+ 20% {
+ transform: translateX(-5%);
+ }
+
+ 40% {
+ transform: translateX(15%);
+ }
+
+ 60% {
+ transform: translateX(-15%);
+ }
+
+ 80% {
+ transform: translateX(5%);
+ }
+
+ 100% {
+ transform: translateX(0%);
+ }
+
+
+}