Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
feat(ui): add video animation background (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored Jan 21, 2024
1 parent 316505a commit 8874645
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 1 deletion.
12 changes: 12 additions & 0 deletions pyra/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ def on_change_tray_toggle() -> bool:
extra_class='col-lg-6',
),
),
User_Interface=dict(
type='section',
name=_('User Interface'),
description=_('User interface settings.'),
icon='display',
BACKGROUND_VIDEO=dict(
type='boolean',
name=_('Background video'),
description=_('Enable background video.'),
default=True,
),
),
Updater=dict(
type='section',
name=_('Updater'),
Expand Down
31 changes: 30 additions & 1 deletion pyra/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# lib imports
from flask import Flask, Response
from flask import jsonify, render_template, request, send_from_directory
from flask import jsonify, render_template as flask_render_template, request, send_from_directory
from flask_babel import Babel

# local imports
Expand Down Expand Up @@ -61,6 +61,35 @@
app.logger.addHandler(handler)


def render_template(template_name_or_list, **context):
"""
Render a template, while providing our default context.
This function is a wrapper around ``flask.render_template``.
Our UI config is added to the template context.
In the future, this function may be used to add other default contexts to templates.
Parameters
----------
template_name_or_list : str
The name of the template to render.
**context
The context to pass to the template.
Returns
-------
render_template
The rendered template.
Examples
--------
>>> render_template(template_name_or_list='home.html', title=_('Home'))
"""
context['ui_config'] = pyra.CONFIG['User_Interface'].copy()

return flask_render_template(template_name_or_list=template_name_or_list, **context)


@app.route('/')
@app.route('/home')
def home() -> render_template:
Expand Down
22 changes: 22 additions & 0 deletions web/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,25 @@ li.beta-setting {
.form-check-input:not(:checked):enabled {
background-color: #151515;
}

/* Style the background video */
#backgroundVideo {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
z-index: -1000;
}

/* transparent background video overlay */
.backgroundVideoOverlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: black;
opacity: 0.8;
z-index: -999;
}
10 changes: 10 additions & 0 deletions web/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
<!-- Include navbar -->
{% include 'navbar.html' %}

{% if ui_config['BACKGROUND_VIDEO'] %}
<div class="backgroundVideoContainer">
<video autoplay muted loop id="backgroundVideo" disablePictureInPicture="true" controlsList="nodownload">
<source src="{{ url_for('static', filename='videos/Retro Delorean.mp4') }}" type="video/mp4">
</video>

<div class="backgroundVideoOverlay"></div>
</div>
{% endif %}

<!-- The page template -->
{% block content %}{% endblock content %}
</main>
Expand Down
3 changes: 3 additions & 0 deletions web/videos/Retro Delorean.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Retro Delorean video is under CC license, https://support.google.com/youtube/answer/2797468

https://www.youtube.com/watch?v=97DgTj0NKK0
Binary file added web/videos/Retro Delorean.mp4
Binary file not shown.

0 comments on commit 8874645

Please sign in to comment.