diff --git a/app.py b/app.py index 4022bb6..e3d1b75 100644 --- a/app.py +++ b/app.py @@ -102,6 +102,13 @@ def get_calendar(person_id): return render_template('calendar.html', person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, previous_date=previous_date, start_date=start_date, end_date=end_date) +@ app.route("/person//workout//modal", methods=['GET']) +@ validate_workout +def get_workout_modal(person_id, workout_id): + workout = db.get_workout(person_id, workout_id) + return render_template('partials/workout_modal.html', workout=workout) + + @ app.route("/person//workout", methods=['POST']) @ validate_person def create_workout(person_id): diff --git a/static/css/style.css b/static/css/style.css index 66b26e0..5c8ee17 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -1,4 +1,106 @@ tr.htmx-swapping td { opacity: 0; transition: opacity 0.5s ease-out; +} + +#modal { + /* Underlay covers entire screen. */ + position: fixed; + top: 0px; + bottom: 0px; + left: 0px; + right: 0px; + background-color: rgba(0,0,0,0.9); + z-index: 1000; + /* Flexbox centers the .modal-content vertically and horizontally */ + display: flex; + flex-direction: column; + align-items: center; + /* Animate when opening */ + animation-name: fadeIn; + animation-duration: 150ms; + animation-timing-function: ease; +} + + #modal > .modal-underlay { + /* underlay takes up the entire viewport. This is only + required if you want to click to dismiss the popup */ + position: absolute; + z-index: -1; + top: 0px; + bottom: 0px; + left: 0px; + right: 0px; + } + + #modal > .modal-content { + /* Position visible dialog near the top of the window */ + margin-top: 5vh; + /* Sizing for visible dialog */ + max-width: 80%; + max-height:90%; + /* Display properties for visible dialog*/ + border: solid 1px #999; + border-radius: 8px; + box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.3); + background-color: white; + padding: 20px; + /* Animate when opening */ + animation-name: zoomIn; + animation-duration: 150ms; + animation-timing-function: ease; + } + + #modal.closing { + /* Animate when closing */ + animation-name: fadeOut; + animation-duration: 150ms; + animation-timing-function: ease; + } + + #modal.closing > .modal-content { + /* Aniate when closing */ + animation-name: zoomOut; + animation-duration: 150ms; + animation-timing-function: ease; + } + +@keyframes fadeIn { + 0% { + opacity: 0; + } + + 100% { + opacity: 1; + } +} + +@keyframes fadeOut { + 0% { + opacity: 1; + } + + 100% { + opacity: 0; + } +} + +@keyframes zoomIn { + 0% { + transform: scale(0.9); + } + + 100% { + transform: scale(1); + } +} + +@keyframes zoomOut { + 0% { + transform: scale(1); + } + + 100% { + transform: scale(0.9); + } } \ No newline at end of file diff --git a/templates/partials/page/calendar.html b/templates/partials/page/calendar.html index 8a7d04f..33ed151 100644 --- a/templates/partials/page/calendar.html +++ b/templates/partials/page/calendar.html @@ -87,8 +87,8 @@ date) %}
+ hx-get="{{ url_for('get_workout_modal', person_id=person['PersonId'], workout_id=workout['WorkoutId']) }}" + hx-target='body' hx-swap='beforeend' {% endif %}>
{{ date.day }}
@@ -143,10 +143,10 @@ 'StartDate', day_date) %} {% set is_in_month = day_date.month == first_day_of_month.month%} -
+ hx-get="{{ url_for('get_workout_modal', person_id=person['PersonId'], workout_id=workout['WorkoutId']) }}" + hx-target='body' hx-swap='beforeend' {% endif %}> {% if is_in_month %} {{ day_date.day }} {% endif %}
{% endfor %} diff --git a/templates/partials/workout_modal.html b/templates/partials/workout_modal.html new file mode 100644 index 0000000..c077a49 --- /dev/null +++ b/templates/partials/workout_modal.html @@ -0,0 +1,147 @@ + \ No newline at end of file