Custom Login Screen
Posted: Fri Nov 22, 2024 2:18 pm
I have playing with the a Login screen by altering $nuWelcomeBodyInnerHTML within nuconfig.php. As its the coming up to Christmas I tried messing around with adding css and javascript snowflakes I tried various css styles and javascript scripts. Best result I had was one snow flake dropping from top to bottom.
Added to nuconfig.php
$nuConfigIncludeCSS .= "
<style>
.snowflakes {
position: fixed; /* Fixes the container in place */
top: 0;
left: 0;
width: 100%; /* Full width of the viewport */
height: 100vh; /* Full height of the viewport */
overflow: hidden;
pointer-events: none; /* Prevent interaction with snowflakes */
z-index: 9999; /* Ensure snowflakes appear on top */
}
.snowflake {
position: absolute;
color: #ffffff;
font-size: 1.5em;
opacity: 0.8;
user-select: none;
animation: snow 5s linear infinite;
background-color: red; /* Temporary color to debug */
}
@keyframes snow {
0% {
transform: translateY(0) translateX(0);
}
100% {
transform: translateY(100vh) translateX(100vw); /* Moves snowflakes down and across the screen */
}
}
</style>
";
$nuConfigIncludeJS .= "
<script>
document.addEventListener('DOMContentLoaded', function() {
let snowflakesContainer = document.createElement('div');
snowflakesContainer.classList.add('snowflakes');
document.body.appendChild(snowflakesContainer); // Append snowflakes container to the body
// Create snowflakes dynamically
for (let i = 0; i < 50; i++) { // Change the number as needed
let snowflake = document.createElement('div');
snowflake.classList.add('snowflake');
snowflakesContainer.appendChild(snowflake);
// Randomize horizontal and vertical starting positions
snowflake.style.left = Math.random() * 100 + 'vw'; // Random horizontal position
snowflake.style.top = Math.random() * 100 + 'vh'; // Random vertical position
// Randomize animation delay and duration
snowflake.style.animationDelay = Math.random() * 5 + 's'; // Random delay between 0 and 5 seconds
snowflake.style.animationDuration = (Math.random() * 5 + 5) + 's'; // Random duration between 5 and 10 seconds
}
});
</script>
";
That didn't do anything apart from show 6 snow flakes on the left hand side of the screen and static, so then I played around and added
to the bottom of index.php the following:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<!-- Other head elements -->
<!-- Snowflakes Styles -->
<style>
/* Basic snowflake styles */
.snowflake {
position: absolute;
top: -10px;
color: #fff;
font-size: 24px;
z-index: 9999;
pointer-events: none;
user-select: none;
animation: snow 10s linear infinite;
}
@keyframes snow {
to {
transform: translateY(100vh);
}
}
</style>
</head>
<body>
<!-- Login Form HTML Here -->
<div id="loginForm">
<!-- Actual login form content -->
</div>
<!-- Snowflakes JavaScript -->
<script>
// Number of snowflakes
var snowflakeCount = 50;
// Function to create snowflakes
function createSnowflakes() {
for (var i = 0; i < snowflakeCount; i++) {
var snowflake = document.createElement('div');
snowflake.classList.add('snowflake');
snowflake.innerHTML = '❄'; // Unicode snowflake symbol
snowflake.style.left = Math.random() * 100 + '%';
snowflake.style.animationDuration = Math.random() * 5 + 5 + 's'; // Snowflakes falling speed
snowflake.style.animationDelay = Math.random() * 5 + 's'; // Random delay
document.body.appendChild(snowflake);
}
}
// Create snowflakes when the page is loaded
window.onload = function() {
createSnowflakes();
};
</script>
</body>
</html>
I now see 1 white snowflake falling from the top left to the bottom left. As this is just a little temporary alteration I dont want to mess around to much with nubuilders core files and just wondered if anybody else had tried doing anything like this?
Added to nuconfig.php
$nuConfigIncludeCSS .= "
<style>
.snowflakes {
position: fixed; /* Fixes the container in place */
top: 0;
left: 0;
width: 100%; /* Full width of the viewport */
height: 100vh; /* Full height of the viewport */
overflow: hidden;
pointer-events: none; /* Prevent interaction with snowflakes */
z-index: 9999; /* Ensure snowflakes appear on top */
}
.snowflake {
position: absolute;
color: #ffffff;
font-size: 1.5em;
opacity: 0.8;
user-select: none;
animation: snow 5s linear infinite;
background-color: red; /* Temporary color to debug */
}
@keyframes snow {
0% {
transform: translateY(0) translateX(0);
}
100% {
transform: translateY(100vh) translateX(100vw); /* Moves snowflakes down and across the screen */
}
}
</style>
";
$nuConfigIncludeJS .= "
<script>
document.addEventListener('DOMContentLoaded', function() {
let snowflakesContainer = document.createElement('div');
snowflakesContainer.classList.add('snowflakes');
document.body.appendChild(snowflakesContainer); // Append snowflakes container to the body
// Create snowflakes dynamically
for (let i = 0; i < 50; i++) { // Change the number as needed
let snowflake = document.createElement('div');
snowflake.classList.add('snowflake');
snowflakesContainer.appendChild(snowflake);
// Randomize horizontal and vertical starting positions
snowflake.style.left = Math.random() * 100 + 'vw'; // Random horizontal position
snowflake.style.top = Math.random() * 100 + 'vh'; // Random vertical position
// Randomize animation delay and duration
snowflake.style.animationDelay = Math.random() * 5 + 's'; // Random delay between 0 and 5 seconds
snowflake.style.animationDuration = (Math.random() * 5 + 5) + 's'; // Random duration between 5 and 10 seconds
}
});
</script>
";
That didn't do anything apart from show 6 snow flakes on the left hand side of the screen and static, so then I played around and added
to the bottom of index.php the following:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<!-- Other head elements -->
<!-- Snowflakes Styles -->
<style>
/* Basic snowflake styles */
.snowflake {
position: absolute;
top: -10px;
color: #fff;
font-size: 24px;
z-index: 9999;
pointer-events: none;
user-select: none;
animation: snow 10s linear infinite;
}
@keyframes snow {
to {
transform: translateY(100vh);
}
}
</style>
</head>
<body>
<!-- Login Form HTML Here -->
<div id="loginForm">
<!-- Actual login form content -->
</div>
<!-- Snowflakes JavaScript -->
<script>
// Number of snowflakes
var snowflakeCount = 50;
// Function to create snowflakes
function createSnowflakes() {
for (var i = 0; i < snowflakeCount; i++) {
var snowflake = document.createElement('div');
snowflake.classList.add('snowflake');
snowflake.innerHTML = '❄'; // Unicode snowflake symbol
snowflake.style.left = Math.random() * 100 + '%';
snowflake.style.animationDuration = Math.random() * 5 + 5 + 's'; // Snowflakes falling speed
snowflake.style.animationDelay = Math.random() * 5 + 's'; // Random delay
document.body.appendChild(snowflake);
}
}
// Create snowflakes when the page is loaded
window.onload = function() {
createSnowflakes();
};
</script>
</body>
</html>
I now see 1 white snowflake falling from the top left to the bottom left. As this is just a little temporary alteration I dont want to mess around to much with nubuilders core files and just wondered if anybody else had tried doing anything like this?