Skip to content

Commit 182869f

Browse files
Merge pull request #81 from palladius/carousel
Carousel for speakers
2 parents 1865898 + 5505cef commit 182869f

4 files changed

Lines changed: 124 additions & 25 deletions

File tree

rubycon.it/_data/speakers.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@
2222
role: Full-Stack Ruby On Rails Developer
2323
description: "Julia is from Barcelona and has been working with Rails for almost 15 years."
2424
labels: [ruby, ruby on rails]
25+
- avatar: '/assets/images/logo/0_0.jpeg'
26+
full_name: Julius Caesar
27+
role: Senior Ruby developer @Gallia 3P
28+
description: cooming soon.
29+
labels: [ruby, ruby on rails]

rubycon.it/_includes/speakers.html

Lines changed: 81 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,89 @@
11
{% capture speakers_content %}
2-
<div class="grid sm:grid-cols-2 lg:grid-cols-3 gap-8">
3-
{% for speaker in site.data.speakers %}
4-
<div class="my-card rounded-lg overflow-hidden shadow-md transition duration-300">
5-
<div class="relative" data-aos="fade-zoom">
6-
<img src="{{ speaker.avatar | relative_url }}" alt="{{ speaker.full_name }}"
7-
class="w-full h-64 object-cover">
8-
<div class="absolute inset-0 bg-gradient-to-t from-black to-transparent opacity-70"></div>
9-
<div class="absolute bottom-4 left-4">
10-
<h3 class="text-white text-2xl font-bold">{{ speaker.full_name }}</h3>
11-
<p class="text-red-200">{{ speaker.role }}</p>
12-
</div>
13-
</div>
14-
<div class="p-6" data-aos="fade-zoom">
15-
<div class="text-gray-600 mb-4">{{ speaker.description | markdownify }}</div>
16-
<div class="flex space-x-2">
17-
{% for label in speaker.labels %}
18-
<span class="bg-red-100 text-red-800 text-xs px-3 py-1 rounded-full">{{ label }}</span>
19-
{% endfor %}
2+
<div id="speakers-wrapper" class="overflow-hidden relative">
3+
<div class="flex speakers-track">
4+
{% for speaker in site.data.speakers %}
5+
<div class="my-card mx-3 rounded-lg overflow-hidden shadow-md transition duration-300">
6+
<div class="relative">
7+
<img src="{{ speaker.avatar | relative_url }}" alt="{{ speaker.full_name }}" class="w-full h-64 object-cover">
8+
<div class="absolute inset-0 bg-gradient-to-t from-black to-transparent opacity-70"></div>
9+
<div class="absolute bottom-4 left-4">
10+
<h3 class="text-white text-2xl font-bold">{{ speaker.full_name }}</h3>
11+
<p class="text-red-200">{{ speaker.role }}</p>
12+
</div>
13+
</div>
14+
<div class="p-6">
15+
<div class="text-gray-600 mb-4">{{ speaker.description | markdownify }}</div>
16+
<div class="flex space-x-2">
17+
{% for label in speaker.labels %}
18+
<span class="bg-red-100 text-red-800 text-xs px-3 py-1 rounded-full">{{ label }}</span>
19+
{% endfor %}
20+
</div>
21+
</div>
2022
</div>
23+
{% endfor %}
2124
</div>
2225
</div>
23-
{% endfor %}
2426
</div>
2527
{% endcapture %}
2628

2729
{% include section.html
28-
id="speakers"
29-
title="II. &nbsp;Featured speakers"
30-
description="We are humbled by the huge response to our CFP: over 40 submissions! We are currently evaluating them and
31-
will announce the speakers soon."
32-
content=speakers_content
33-
%}
30+
id="speakers"
31+
title="II. &nbsp;Featured speakers"
32+
description="We are humbled by the huge response to our CFP: over 40 submissions! We are currently evaluating them and
33+
will announce the speakers soon."
34+
content=speakers_content
35+
%}
36+
37+
<script>
38+
document.addEventListener('DOMContentLoaded', () => {
39+
gsap.registerPlugin(Draggable);
40+
41+
const track = document.querySelector('.speakers-track');
42+
track.innerHTML += track.innerHTML; //temporary cause few speakers
43+
44+
const contentWidth = track.scrollWidth / 2;
45+
46+
let x = 0;
47+
const speed = 0.8;
48+
let isPaused = false;
49+
50+
function animate() {
51+
if (!isPaused) {
52+
x -= speed;
53+
}
54+
55+
// wrap infinito
56+
if (x <= -contentWidth) x += contentWidth;
57+
if (x >= 0) x -= contentWidth;
58+
59+
gsap.set(track, { x });
60+
61+
requestAnimationFrame(animate);
62+
}
63+
64+
animate();
65+
66+
// DRAG (mouse + touch)
67+
Draggable.create(track, {
68+
type: "x",
69+
allowNativeTouchScrolling: false,
70+
71+
onPress() {
72+
isPaused = true;
73+
},
74+
75+
onDrag() {
76+
x += this.deltaX;
77+
},
78+
79+
onRelease() {
80+
isPaused = false;
81+
}
82+
});
83+
84+
// DESKTOP hover
85+
track.addEventListener("pointerenter", () => isPaused = true);
86+
track.addEventListener("pointerleave", () => isPaused = false);
87+
})
88+
</script>
89+

rubycon.it/_layouts/default.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
{% include footer.html %}
3333

34+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.1/dist/gsap.min.js"></script>
35+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.1/dist/Draggable.min.js"></script>
3436
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
3537
<script>
3638
AOS.init({duration: 500})

rubycon.it/assets/css/style.scss

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,40 @@ header,
4646
section:nth-of-type(even):not(#newsletter) {
4747
color: white;
4848
}
49+
#speakers-wrapper{
50+
mask-image: linear-gradient(
51+
to right,
52+
transparent 0%,
53+
#500011 7%,
54+
#500011 92%,
55+
transparent 100%
56+
);
57+
58+
-webkit-mask-image: linear-gradient(
59+
to right,
60+
transparent 0%,
61+
#500011 7%,
62+
#500011 92%,
63+
transparent 100%
64+
);
65+
}
66+
.speakers-track {
67+
will-change: transform;
68+
cursor: grab;
69+
}
70+
71+
.speakers-track:active {
72+
cursor: grabbing;
73+
}
74+
75+
.speakers-track > * {
76+
flex-shrink: 0;
77+
}
4978

5079
.my-card {
5180
background-color: variables.$background-secondary;
81+
flex-shrink: 0;
82+
width: 350px;
5283
}
5384

5485
.my-card:hover {
@@ -250,4 +281,9 @@ section:nth-of-type(even):not(#newsletter) {
250281
color: inherit;
251282
font-size: 1rem;
252283
padding: 0;
284+
}
285+
@media screen and (max-width: 600px) {
286+
.my-card{
287+
width: 300px;
288+
}
253289
}

0 commit comments

Comments
 (0)