Spaces:
Running
Running
Sebastiankay
commited on
Commit
•
dcdd362
1
Parent(s):
108bf71
24. Sept. 2024, 22:10
Browse files- _res/_custom.js +34 -35
_res/_custom.js
CHANGED
@@ -1,41 +1,6 @@
|
|
1 |
function gradioCustomJS() {
|
2 |
console.log("gradioCustomJS Started")
|
3 |
|
4 |
-
let usedColor = "rgb(250, 179, 135)"
|
5 |
-
|
6 |
-
// MARK: DOM Change Detection
|
7 |
-
function onDomChange(callback) {
|
8 |
-
const observer = new MutationObserver(callback)
|
9 |
-
observer.observe(document.querySelector("#dominant_image_color"), {
|
10 |
-
childList: true,
|
11 |
-
subtree: true,
|
12 |
-
})
|
13 |
-
}
|
14 |
-
|
15 |
-
onDomChange(() => {
|
16 |
-
console.log("changed: " + document.querySelector("#dominant_image_color > label > textarea").value)
|
17 |
-
if (document.querySelector("#dominant_image_color > label > textarea").value.match(/^rgb\((\d{1,3}),(\s\d{1,3}),(\s\d{1,3})\)$/) && document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").src) {
|
18 |
-
document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").style.opacity = "0"
|
19 |
-
document.querySelector("body > gradio-app > div").classList.add("fade-bg")
|
20 |
-
document.querySelector("gradio-app").style.opacity = "0"
|
21 |
-
setTimeout(() => {
|
22 |
-
usedColor = document.querySelector("#dominant_image_color > label > textarea").value
|
23 |
-
document.querySelector("body").style.setProperty("--primary-600", usedColor)
|
24 |
-
document.querySelector("gradio-app").classList.add("has-bg-image")
|
25 |
-
document.querySelector("body").style.setProperty("--bg-image-path", `url("${document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").src}")`)
|
26 |
-
}, 400)
|
27 |
-
setTimeout(() => {
|
28 |
-
document.querySelector("gradio-app").style.opacity = "1"
|
29 |
-
document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").style.opacity = "1"
|
30 |
-
document.querySelector("#dominant_image_color > label > textarea").value = ""
|
31 |
-
}, 800)
|
32 |
-
setTimeout(() => {
|
33 |
-
//document.querySelector("body > gradio-app > div").classList.remove("fade-bg")
|
34 |
-
}, 2000)
|
35 |
-
}
|
36 |
-
//document.querySelector("body").style.setProperty("--primary-700", document.querySelector("#dominant_image_color > label > textarea").value)
|
37 |
-
})
|
38 |
-
|
39 |
// MARK: berechne Helligkeit der Akzentfarbe
|
40 |
function berechneHelligkeit(rgb) {
|
41 |
const match = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)
|
@@ -68,6 +33,7 @@ function gradioCustomJS() {
|
|
68 |
const body = document.querySelector("body")
|
69 |
body.className = "dark"
|
70 |
|
|
|
71 |
// Catppuccin colors
|
72 |
body.style.setProperty("--cat-rosewater", "rgb(245, 224, 220)")
|
73 |
body.style.setProperty("--cat-flamingo", "rgb(242, 205, 205)")
|
@@ -100,6 +66,39 @@ function gradioCustomJS() {
|
|
100 |
body.style.setProperty("--blur-value", "0px")
|
101 |
body.style.setProperty("--text-color-by-luminance", anpasseTextfarbe(usedColor))
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
// MARK: Selectors & Elements
|
104 |
const gradioApp = document.querySelector("gradio-app")
|
105 |
const gradioContainer = document.querySelector("body > gradio-app > div.gradio-container")
|
|
|
1 |
function gradioCustomJS() {
|
2 |
console.log("gradioCustomJS Started")
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
// MARK: berechne Helligkeit der Akzentfarbe
|
5 |
function berechneHelligkeit(rgb) {
|
6 |
const match = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)
|
|
|
33 |
const body = document.querySelector("body")
|
34 |
body.className = "dark"
|
35 |
|
36 |
+
let usedColor = "rgb(250, 179, 135)"
|
37 |
// Catppuccin colors
|
38 |
body.style.setProperty("--cat-rosewater", "rgb(245, 224, 220)")
|
39 |
body.style.setProperty("--cat-flamingo", "rgb(242, 205, 205)")
|
|
|
66 |
body.style.setProperty("--blur-value", "0px")
|
67 |
body.style.setProperty("--text-color-by-luminance", anpasseTextfarbe(usedColor))
|
68 |
|
69 |
+
// MARK: DOM Change Detection
|
70 |
+
function onDomChange(callback) {
|
71 |
+
const observer = new MutationObserver(callback)
|
72 |
+
observer.observe(document.querySelector("#dominant_image_color"), {
|
73 |
+
childList: true,
|
74 |
+
subtree: true,
|
75 |
+
})
|
76 |
+
}
|
77 |
+
|
78 |
+
onDomChange(() => {
|
79 |
+
console.log("changed: " + document.querySelector("#dominant_image_color > label > textarea").value)
|
80 |
+
if (document.querySelector("#dominant_image_color > label > textarea").value.match(/^rgb\((\d{1,3}),(\s\d{1,3}),(\s\d{1,3})\)$/) && document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").src) {
|
81 |
+
document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").style.opacity = "0"
|
82 |
+
document.querySelector("body > gradio-app > div").classList.add("fade-bg")
|
83 |
+
document.querySelector("gradio-app").style.opacity = "0"
|
84 |
+
setTimeout(() => {
|
85 |
+
usedColor = document.querySelector("#dominant_image_color > label > textarea").value
|
86 |
+
document.querySelector("body").style.setProperty("--primary-600", usedColor)
|
87 |
+
document.querySelector("gradio-app").classList.add("has-bg-image")
|
88 |
+
document.querySelector("body").style.setProperty("--bg-image-path", `url("${document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").src}")`)
|
89 |
+
}, 400)
|
90 |
+
setTimeout(() => {
|
91 |
+
document.querySelector("gradio-app").style.opacity = "1"
|
92 |
+
document.querySelector("#output_image > div.image-container.svelte-1p15vfy > button > div > img").style.opacity = "1"
|
93 |
+
document.querySelector("#dominant_image_color > label > textarea").value = ""
|
94 |
+
}, 800)
|
95 |
+
setTimeout(() => {
|
96 |
+
//document.querySelector("body > gradio-app > div").classList.remove("fade-bg")
|
97 |
+
}, 2000)
|
98 |
+
}
|
99 |
+
//document.querySelector("body").style.setProperty("--primary-700", document.querySelector("#dominant_image_color > label > textarea").value)
|
100 |
+
})
|
101 |
+
|
102 |
// MARK: Selectors & Elements
|
103 |
const gradioApp = document.querySelector("gradio-app")
|
104 |
const gradioContainer = document.querySelector("body > gradio-app > div.gradio-container")
|