Skip to content

Commit

Permalink
Optimization Events
Browse files Browse the repository at this point in the history
  • Loading branch information
cnoss committed Oct 22, 2024
1 parent b11378f commit 8e5f7ee
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 102 deletions.
39 changes: 33 additions & 6 deletions assets/js/news-aggregator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
function createNews() {
const newsUrls = ['https://th-koeln.github.io/mi-master-wtw/pulse.json', '/events/index.json'];
const newsUrls = ['https://th-koeln.github.io/mi-master-wtw/pulse.json', '/events/index.json'];
const displayMax = 16;

const showAdditionalNews = () => {
const areThereMoreNews = document.querySelectorAll(".news-item").length > displayMax;
if(!areThereMoreNews) return;

const targetContainer = document.querySelector('#eventblock');
if(!targetContainer) return;

targetContainer.insertAdjacentHTML("beforeend", `<button class="more-events-button m-mi-pulse-teaser" data-js-show-more-news class="button">Weitere Events anzeigen</button>`);

const showMoreButton = document.querySelector("[data-js-show-more-news]");
if(!showMoreButton) return;

showMoreButton.addEventListener("click", () => {
const hiddenItems = document.querySelectorAll(".news-item.is-hidden");
hiddenItems.forEach(item => {
item.classList.remove("is-hidden");
item.classList.add("is-visible");
});
showMoreButton.style.display = "none";
});
};

function createNews() {
const target = document.querySelector('#eventblock');
let promises = [];
let data = [];
Expand Down Expand Up @@ -54,15 +78,17 @@ function createNews() {
const news = data.slice(0, 100);

target.innerHTML = '';
news.forEach(function (item) {
news.forEach(function (item, index) {
let bild = getTeaserImage(item);

let external = (!item.url.includes(getCurrentUrl())) ? '<i class="material-icons m-mi-pulse-teaser--external">open_in_new</i>' : '';
let teaserImageCode = '<div class="m-mi-pulse-teaser--image"><img loading="lazy" src="' + bild + '" alt="'+item.title+'"></div>';
let teaserImage = (bild && bild.match(/jpg|jpeg|png|webP|j2/)) ? teaserImageCode : "";


const visibilityClass = index < displayMax ? 'is-visible' : 'is-hidden';

target.innerHTML += `
<a href="${item.url}">
<a href="${item.url}" class="news-item ${visibilityClass}">
<div class="m-mi-pulse-teaser has-image">
${teaserImage}
<div class="m-mi-pulse-teaser--content">
Expand All @@ -84,7 +110,8 @@ function createNews() {
Promise.all(promises)
.then(() => cleanItems())
.then(() => sortItems())
.then(() => displayItems());
.then(() => displayItems())
.then(() => showAdditionalNews())
}

document.onreadystatechange = function () {
Expand Down
7 changes: 4 additions & 3 deletions assets/scss/_mi-base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ body,
html {
font-family: IBMplex, Arial, Helvetica, sans-serif;
font-size: $bfs;
font-weight: $fw-normal;

hyphens: auto;
overflow-x: hidden;
@media screen and (max-width: 640px) {
Expand All @@ -18,14 +20,13 @@ html {
}

body {
font-family: IBMplex, Helvetica, Roboto, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
}

/* Headlines & Texts -----------------------------------------------------------------------------*/

h1 {
font-weight: bold;
font-weight: $fw-bold;
margin-bottom: $bfs-xl;
hyphens: none;
@media screen and (max-width: 640px) {
Expand Down Expand Up @@ -55,7 +56,7 @@ h4 {
h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
font-family: IBMplex, Helvetica, Roboto, Arial, sans-serif;
font-style: normal;
font-weight: normal;
font-weight: $fw-bold;
color: inherit;
text-rendering: optimizeLegibility;
}
Expand Down
43 changes: 23 additions & 20 deletions assets/scss/_mi-moduls.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
float: left;
min-width: 10px;
padding: 0;
font-weight: bold;
font-weight: $fw-bold;
color: #9313ce;
padding-top: $bfs-xxs;
}
Expand Down Expand Up @@ -140,7 +140,7 @@
}

&.active {
font-weight: bold;
font-weight: $fw-bold;
}

&.active::before {
Expand Down Expand Up @@ -325,7 +325,7 @@

.mi-studienverlaufsplan-master .tabs .tabs-title.is-active a {
background-color: #d16;
font-weight: bold;
font-weight: $fw-bold;
color: #fff;
}

Expand All @@ -338,32 +338,35 @@
}


/* events & video-overview
/* video-overview
---------------------------------------------------------------------------- */

.events, .video-overview {
.video-overview {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr) );
grid-gap: $bfs;
}

@media(max-width: $mi-vp-xl) {
.events, .video-overview {
grid-template-columns: repeat(3, 1fr);
}
}

@media(max-width: $mi-vp-l) {
.events, .video-overview{
grid-template-columns: 1fr 1fr;
}
}

@media(max-width: $mi-vp-s) {
.events, .video-overview {
grid-template-columns: 1fr;
/* events
---------------------------------------------------------------------------- */

.events {

margin-top: $fluid-xs;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr) );
grid-gap: $bfs-xl;

@media screen and (min-width: 60rem){
padding-right: $fluid-l;
}
}






/* Blog
Expand Down Expand Up @@ -640,7 +643,7 @@ img {

thead th, thead td, tfoot th, tfoot td {
padding: .5rem .625rem .625rem;
font-weight: bold;
font-weight: $fw-bold;
text-align: left;
}

Expand Down
24 changes: 23 additions & 1 deletion assets/scss/_mi-vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ $mi-black: #231f20;
$mi-grau: #aaaaaa;
$mi-hellgrau: #efefef;
$lighten: rgba(255,255,255,0.5);
$dark: rgba(0,0,0,0.7);
$darker: rgba(0,0,0,0.85);
$darkest: rgba(0,0,0,1);
$light: rgba(255,255,255,0.7);
$lighter: rgba(255,255,255,0.85);
$lightest: rgba(255,255,255,1);

// MI Fonts
// ---------
Expand Down Expand Up @@ -117,6 +123,13 @@ $mi-vp-xl: 1399px;
// ---------
$from-left: 100px;

// Font Weights
// ---------
$fw-light: 200;
$fw-normal: 300;
$fw-medium: 400;
$fw-bold: 600;


// MI Borders
// ---------
Expand Down Expand Up @@ -150,6 +163,15 @@ $text-small: 24rem;
$tr-fast: 0.3s;
$tr-medium: 0.6s;

// Radien
// ---------
$radius-xs: $xs;
$radius-s: $s;
$radius-m: $m;


// Sonstiges
// ---------
$shadow-s: 0 0 10px rgba(0,0,0,0.2);
$shadow-s: 0 0 10px rgba(0,0,0,0.2);


111 changes: 44 additions & 67 deletions assets/scss/molecules/mi-pulse-teaser/mi-pulse-teaser.scss
Original file line number Diff line number Diff line change
@@ -1,87 +1,64 @@
.m-mi-pulse-teaser {
background-color: $mi-black;
background-size: cover;
background-position: center center;
height: $bfs-max *3;
overflow: hidden;
position: relative;
padding: $bfs $bfs-xs;
color: #fff;
box-shadow: 0 0 0 rgba(0,0,0,0.7);
transition: transform 0.2s ease;

&:hover {
transform: rotate(3deg) scale(1.02);
}
transition: transform $tr-fast;

&.has-image::before,
&--image::before {
content: '';
top: 0;
bottom: 30%;
position: absolute;
right: 0;
left: 0;
background-size: auto;
background-image: linear-gradient(to top,rgba(35, 31, 32, 0),rgba(35, 31, 32, 0.8));
background-repeat: no-repeat;
background-position: bottom;
opacity: 1;
z-index: 0;
}

&--external {
float: right;
&:hover {
transform: scale(1.02);
}

&--image{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
img{
width: 100%;
height: 100%;
object-fit: cover;
}
&.has-image{
background: linear-gradient(rgba(0,0,0,0.05), rgba(0,0,0,0));
border-radius: $radius-xs;
overflow: hidden;
position: relative;
}

&--content {
position: relative;
&--image {
mix-blend-mode: darken;
z-index: 1;

.title {
font-size: $bfs-l;
@media screen and (max-width: 640px) {
font-size: $bfs;
}
word-break: break-word;
text-shadow: 1px 1px 10px rgba(0,0,0,0.6);
img{
aspect-ratio: 16/9;
width: 100%;
object-fit: cover;
}

margin-bottom: $s;

}

&--footer {
&--external {
position: absolute;
left: 0;
right: 0;
bottom: 0;
background-color: $mi-black;
z-index: 1;
margin-bottom: 0;
padding: $bfs-xxs $bfs-xs;
min-height: 52px;
}
top: $s;
right: $s;
z-index: 100;
}

&--content {
color: $darker;

&.is-text-only {
background-color: $mi-lila;

.title {
text-shadow: none !important;
.title{
font-size: $m;
text-wrap: balance;
margin-bottom: 0.25em;
font-weight: $fw-bold;
}

.m-mi-pulse-teaser--footer {
background-color: rgba(0,0,0,0.2);
}

&.more-events-button{
aspect-ratio: 16/9;
font-size: $m;
border-radius: $radius-s;

transition: background-color $tr-fast;

&:hover{
cursor: pointer;
background-color: $mi-pink;
color: $lightest;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

ul{
padding-top: $m;
font-weight: light;
font-weight: $fw-light;
}
}

Expand Down
2 changes: 1 addition & 1 deletion assets/scss/molecules/mi-textblock/mi-textblock.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
min-width: $fluid-s;
padding: 0;
padding-top: 0;
font-weight: 700;
font-weight: $fw-bold;
color: $mi-lila;

&::after {
Expand Down
4 changes: 2 additions & 2 deletions assets/scss/system/navigationHeader/navigationHeader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
}

&--logoSlug {
font-weight: 400;
font-weight: $fw-medium;
}


&--text {
display: inline-block;
font-family: $family-headlines;
font-weight: bold;
font-weight: $fw-bold;

}

Expand Down
Loading

0 comments on commit 8e5f7ee

Please sign in to comment.