background fades to new color, new left side menu (WIP)

This commit is contained in:
2024-05-12 21:18:59 -07:00
parent 7adb79881e
commit cfdf406f6c
6 changed files with 49 additions and 51 deletions

View File

@@ -9,26 +9,19 @@
<style>
.animated-background {
transition: background-color 1s ease-in-out; /* add a transition effect */
background-color: #fff; /* initial background color */
}
.animated-background.update-color {
background-color: var(--color); /* change the background color to black */
}
@keyframes fade-in {
to {
background-color: var(--color); /* change the background color to black */
}
background-color: var(--color); /* initial background color */
transition: margin-left 0.5s; /* add a transition effect */
}
.progress-container {
position: fixed;
bottom: 8px;
width: 100%;
background-color: #ddd;
transition: background-color 1s ease-in-out; /* add a transition effect */
background-color: var(--color);
}
.progress-bar {
width: 0%;
height: 10px;
background-color: #d734e9;
text-align: center;
line-height: 4px;
color: white;
@@ -39,12 +32,14 @@
font-weight: bold;
text-align: center;
margin-bottom: 5px;
transition: color 1s ease-in-out; /* add a transition effect */
}
.artist-text {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 29px;
text-align: center;
margin-top: 5px;
transition: color 1s ease-in-out; /* add a transition effect */
}
.middle {
position: relative;
@@ -69,6 +64,7 @@
text-align: center;
}
.buttons {
transition: filter 1s ease-in-out; /* add a transition effect */
position: absolute;
bottom: 0;
left: 0;
@@ -91,11 +87,26 @@
vertical-align: center;
width: 33%;
}
/* LEFT SIDE SWIPE PAGE */
.leftside {
height: 100%;
width: 0;
position: fixed;
top: 0;
left: 0;
background-color: var(--color);
overflow-x: hidden;
transition: 0.5s;
}
</style>
</head>
<body class="animated-background">
<!-- <link href="http://127.0.0.1:8888/font" rel="stylesheet"> -->
<div class="total">
<div class="leftside" id="leftpage">
<a href="javascript:void(0)" onclick="closeNav()">Close</a>
</div>
<span onclick="openNav()">Swipe</span>
<div class="left">
<img id="image" src="{{ data['image'] }}" alt="Song Image" type="image/jpeg" style="max-width: 330px; padding-left: 25%;">
<video width="330" autoplay muted playsinline loop id="canvas_url" src="{{ data['canvas_url'] }}" type="video/mp4" style="display: none; padding-left: 10%;"></video>
@@ -244,56 +255,49 @@
const img = document.getElementById('image');
img.crossOrigin = 'Anonymous';
animatedBackground = document.querySelector('.animated-background');
document.documentElement.style
.setProperty('--my-variable-name', '100px');
progressContainer = document.querySelector('.progress-container');
//get property
getComputedStyle(document.documentElement)
.getPropertyValue('--my-variable-name'); // returns value
if (img.complete) {
const color = colorThief.getColor(img);
// document.body.style.backgroundColor = 'rgb(' + color + ')';
// document.body.style.backgroundColor = 'rgb(' + color + ')';
animatedBackground.style.setProperty('--color', 'rgb(' + color + ')');
animatedBackground.classList.add('update-color');
progressContainer.style.setProperty('--color', 'rgb(' + color + ')');
getLuminance(color);
} else {
img.addEventListener('load', function() {
const color = colorThief.getColor(img);
// document.body.style.backgroundColor = 'rgb(' + color + ')';
animatedBackground.style.setProperty('--color', 'rgb(' + color + ')');
animatedBackground.classList.add('update-color');
progressContainer.style.setProperty('--color', 'rgb(' + color + ')');
getLuminance(color);
});
}
}
function getLuminance(color) {
songText = document.querySelector('.song-text');
artistText = document.querySelector('.artist-text');
buttonsDiv = document.querySelector('.buttons');
if (Math.sqrt(0.299 * (color[0] ** 2) + 0.587 * (color[1] ** 2) + 0.114 * (color[2] ** 2)) > 170) {
document.getElementById('name').style.color = 'black';
document.getElementById('artist').style.color = 'black';
document.getElementById('lyric').style.color = 'black';
document.getElementById('previous').style.filter = 'invert(100%)';
document.getElementById('playpause').style.filter = 'invert(100%)';
document.getElementById('next').style.filter = 'invert(100%)';
document.getElementById('like').style.filter = 'invert(100%)';
document.getElementById('progress_container').style.backgroundColor = 'rgb(' + color + ')';
songText.style.color = 'black';
artistText.style.color = 'black';
buttonsDiv.style.filter = 'invert(100%)';
darkColor = [color[0] - 75, color[1] - 75, color[2] - 75]
document.getElementById('progress_bar').style.backgroundColor = 'rgb(' + darkColor + ')';
} else {
document.getElementById('name').style.color = 'white';
document.getElementById('artist').style.color = 'white';
document.getElementById('lyric').style.color = 'white';
document.getElementById('previous').style.filter = '';
document.getElementById('playpause').style.filter = '';
document.getElementById('next').style.filter = '';
document.getElementById('like').style.filter = '';
document.getElementById('progress_container').style.backgroundColor = 'rgb(' + color + ')';
songText.style.color = 'white';
artistText.style.color = 'white';
buttonsDiv.style.filter = '';
lightColor = [color[0] + 75, color[1] + 75, color[2] + 75]
document.getElementById('progress_bar').style.backgroundColor = 'rgb(' + lightColor + ')';
}
}
function openNav() {
document.getElementById('leftpage').style.width = "100%";
document.querySelector('.animated-background').style.marginLeft = "100%";
}
function closeNav() {
document.getElementById('leftpage').style.width = "0";
document.querySelector('.animated-background').style.marginLeft = "0";
}
// function getLuminance() {
// }