Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic birthday balloons #1849

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ node_modules/
data/cache/phpstan/
public/css/gewis-theme.css
public/css/gewis-theme.css.map
resources/scss/
public/styleguide/
autoload_classmap.php
.mysql
Expand Down
12 changes: 12 additions & 0 deletions module/Application/view/layout/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ endif; ?>
<?= $this->partial('partial/privacy-widget.phtml') ?>

<!-- Scripts -->
<?php
$currentDate = new DateTime();
$targetDate = DateTime::createFromFormat('j n', '28 6');

if ($currentDate->format('j n') === $targetDate->format('j n')) {
$this->inlineScript()->prependFile(
$this->basepath('js/balloons.js'),
'text/javascript',
['nonce' => NONCE_REPLACEMENT_STRING],
);
}
?>
<?= $this->inlineScript()
->prependFile(
$this->basepath('js/bootstrap.min.js'),
Expand Down
2 changes: 1 addition & 1 deletion public/css/gewis-theme.css

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions public/js/balloons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

function random(num) {
return Math.floor(Math.random() * num)
}

function getRandomStyles() {
const r = random(255);
const g = random(255);
const b = random(255);
const mt = random(200);
const ml = random(50);
const dur = random(5)+10;
const pos = random(screen.width);

return `
background-color: rgba(${r}, ${g}, ${b},0.7);
color: rgba(${r}, ${g}, ${b},0.7);
box-shadow: inset -7px -3px 10px rgba(${r - 10}, ${g - 10}, ${b - 10}, 0.7);
margin: ${mt}px 0 0 ${ml}px;
animation: float ${dur}s ease-in infinite;
left: ${pos}px;
`;
}

async function createBalloons(num) {
const body = document.body;
const balloonContainer = document.createElement("div");
balloonContainer.id = 'balloon-container';
body.append(balloonContainer);

for (let i = num; i > 0; i--) {
const balloon = document.createElement("div");
balloon.className = "balloon";
balloon.style.cssText = getRandomStyles();
balloonContainer.append(balloon);
await sleep(random(500));
}
}

window.onload = function() {
createBalloons(40);
}
56 changes: 56 additions & 0 deletions resources/scss/components/_balloons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.balloon {
height: 125px;
width: 105px;
border-radius: 75% 75% 70% 70%;
position: relative;

&:before {
content: "";
height: 75px;
width: 1px;
padding: 1px;
background-color: #FDFD96;
display: block;
position: absolute;
top: 132px;
left: 51px;
margin: auto;
}

&:after {
content: "▲";
text-align: center;
display: block;
position: absolute;
color: inherit;
top: 115px;
left: 0;
right: 0;
margin: auto;
}
}

@keyframes float {
from {
transform: translateY(100vh);
opacity: 1;
}
to {
transform: translateY(-300vh);
opacity: 0;
}
}

#balloon-container {
overflow: hidden;
z-index: 1000000;
pointer-events: none;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100vw;
margin: 0 auto;
height: 100vh;
}
1 change: 1 addition & 0 deletions resources/scss/gewis-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

// Components
@import 'components/badges';
@import 'components/balloons';
@import 'components/banner';
@import 'components/breadcrumbs';
@import 'components/button-groups';
Expand Down
Loading