From bdfcdd3633d06ac9b827281f13d5535caaf588d3 Mon Sep 17 00:00:00 2001 From: atharv-naik Date: Tue, 12 Dec 2023 14:49:53 +0530 Subject: [PATCH] Add hover play functionality to video thumbnails --- play/static/play/styles/history.css | 1 + play/static/play/styles/home.css | 10 ++++++++ play/templates/play/home.html | 39 +++++++++++++++++++++++++++-- play/views.py | 19 +++++++++++--- 4 files changed, 64 insertions(+), 5 deletions(-) diff --git a/play/static/play/styles/history.css b/play/static/play/styles/history.css index fe89e7a..010df3f 100644 --- a/play/static/play/styles/history.css +++ b/play/static/play/styles/history.css @@ -96,6 +96,7 @@ bottom: 0.25em; background-color: black; color: white; + width: -moz-fit-content; width: fit-content; padding: 0 0.2vw; margin-bottom: 0.4rem; diff --git a/play/static/play/styles/home.css b/play/static/play/styles/home.css index ed46763..620d39e 100644 --- a/play/static/play/styles/home.css +++ b/play/static/play/styles/home.css @@ -60,6 +60,7 @@ bottom: 5px; background-color: rgba(0, 0, 0, 0.85); color: white; + width: -moz-fit-content; width: fit-content; padding: 0.2em 0.35em; border-radius: 10%; @@ -82,6 +83,15 @@ border-radius: 3%; } +.thumbnail-hover-play-video { + display: none; + width: 100%; + height: 100%; + object-fit: cover; + object-position: center; + border-radius: 3%; +} + .video-card-bottom-section { display: flex; align-items: flex-start; diff --git a/play/templates/play/home.html b/play/templates/play/home.html index 1efce72..49d617e 100644 --- a/play/templates/play/home.html +++ b/play/templates/play/home.html @@ -26,9 +26,11 @@

PlayTube

{% for video in videos %}
- -
+ +
+ +
@@ -130,7 +132,13 @@

PlayTube

{% endblock %} {% block scripts %} + + {% endblock %} diff --git a/play/views.py b/play/views.py index 498125d..8818c60 100644 --- a/play/views.py +++ b/play/views.py @@ -48,8 +48,12 @@ def home(request): page_number = request.GET.get("page") page_obj = paginator.get_page(page_number) - videos = {'videos': page_obj} - return render(request, 'play/home.html', videos) + info = { + 'videos': page_obj, + 'domain_name': settings.DOMAIN_NAME, + 'http_protocol': 'https' if settings.USE_HTTPS else 'http' + } + return render(request, 'play/home.html', info) else: return render(request, 'play/404.html', {'info': 'No videos found'}, status=404) @@ -122,7 +126,16 @@ def watch(request): t = history.timestamp if t is 0 else t history.save() - return render(request, 'play/watch.html', {'video_id': video_id, 'channel_id': channel_id, 't': t, 'movie': video, 'channel': channel, 'domain_name': settings.DOMAIN_NAME, 'http_protocol': 'https' if settings.USE_HTTPS else 'http'}) + info = { + 'video_id': video_id, + 'channel_id': channel_id, + 't': t, + 'movie': video, + 'channel': channel, + 'domain_name': settings.DOMAIN_NAME, + 'http_protocol': 'https' if settings.USE_HTTPS else 'http' + } + return render(request, 'play/watch.html', info) except Channel.DoesNotExist: info = {'info': 'This video isn\'t available anymore'}