Skip to content

Commit 682aae9

Browse files
committed
Add text folding
1 parent da1477d commit 682aae9

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

index.html.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
◊orga{18:45 Doors open & Welcome}
8181
◊p[#:class ""]{◊span[#:class "font-medium"]{Really Functional Data Structures} (Marvin)}
8282
◊abstract{
83-
Last time, David showed us functional data structures in the form of persistent data structures. In this talk, I want to show you data structures that are defined entirely by functions themselves - no classes, structs, bitmaps, etc.! Knowing about such structures not only tickles the brain, but can also lead to a better intuition for solving problems functionally. Furthermore, one of the data structures shown can be used for space-efficient encodings of fractals and fun animations.
83+
Last time, David showed us functional data structures in the form of persistent data structures. In this talk, I want to show you data structures that are defined entirely by functions themselves - no classes, structs, bitmaps, etc.! Knowing about such structures not only tickles the brain, but can also lead to a better intuition for solving problems functionally. Furthermore, one of the data structures shown can be used for space-efficient encodings of fractals and fun animations.
8484
}
8585
◊orga{Short break}
8686
◊p[#:class ""]{◊span[#:class "font-medium"]{Decoupled by Default – Funktionale Programmierung in der Softwarearchitektur} (Markus)}

main.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,57 @@ document.addEventListener('DOMContentLoaded', function() {
2525
console.error('One or more required elements are missing from the DOM');
2626
}
2727
});
28+
29+
document.addEventListener('DOMContentLoaded', () => {
30+
const abstracts = document.querySelectorAll('.abstract-wrapper');
31+
32+
abstracts.forEach(abstract => {
33+
const content = abstract.querySelector('.abstract-content');
34+
const button = abstract.querySelector('.toggle-button');
35+
const lineClamp = 8; // Number of lines set in line-clamp
36+
37+
// Function to count the number of lines in the content
38+
const countLines = (element) => {
39+
const computedStyle = window.getComputedStyle(element);
40+
const lineHeight = parseFloat(computedStyle.lineHeight);
41+
const height = parseFloat(computedStyle.height);
42+
return Math.round(height / lineHeight);
43+
};
44+
45+
// Determine if the content exceeds the line-clamp
46+
const isTruncated = () => {
47+
const totalLines = countLines(content);
48+
return totalLines > lineClamp;
49+
};
50+
51+
// Show or hide the toggle button based on content length
52+
if (isTruncated()) {
53+
button.classList.remove('hidden');
54+
} else {
55+
button.classList.add('hidden');
56+
}
57+
});
58+
59+
const toggleButtons = document.querySelectorAll('.toggle-button');
60+
61+
toggleButtons.forEach(button => {
62+
button.addEventListener('click', () => {
63+
const wrapper = button.closest('.abstract-wrapper');
64+
const content = wrapper.querySelector('.abstract-content');
65+
66+
// Toggle expanded state
67+
// wrapper.classList.toggle('max-h-60'); // Tailwind's max-height: 13rem (52 * 0.25rem)
68+
// content.classList.toggle('max-h-48'); // Tailwind's max-height: 13rem (52 * 0.25rem)
69+
content.classList.toggle('line-clamp-[8]');
70+
content.classList.toggle('line-clamp-none');
71+
72+
// Update button text
73+
const isExpanded = !content.classList.contains('line-clamp-[8]');
74+
const buttonText = button.querySelector('.button-text')
75+
buttonText.textContent = isExpanded ? 'Show Less' : 'Show More';
76+
77+
// Update aria-expanded attribute for accessibility
78+
// button.setAttribute('aria-expanded', isExpanded);
79+
});
80+
});
81+
});

pollen.rkt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@
4545
(span ([class "border-solid border-b border-zinc-300 flex-1"]))))
4646

4747
(define (abstract . body)
48-
`(div ([class "md:mx-8 mt-2 mb-4 italic text-base"]) ,@body))
48+
`(div ([class "abstract-wrapper flex flex-col overflow-hidden italic text-base md:mx-8 mt-2 mb-4"])
49+
(div ([class "abstract-content line-clamp-[8] transition-all duration-300 ease-in-out mb-2"])
50+
,@body)
51+
(button ([class ,"toggle-button inline-flex justify-center items-center gap-2 self-center text-[@{jordy}]/80 hover:text-[@{jordy}] transition-all duration-200"])
52+
(span ([class "button-text"]) "Show more")
53+
)))
54+
4955

5056
(define (meetup #:title title #:img [img ""] . body)
5157
`(div ([class "overflow-hidden my-4 snap-center flex w-[90%] shrink-0 mx-8 sm:mx-16 shadow-lg rounded-lg"])

0 commit comments

Comments
 (0)