dynamic style for favs

This commit is contained in:
ZeKap 2024-02-22 15:59:40 +01:00
parent b8995d8bca
commit a79e8f0cd6
No known key found for this signature in database
GPG Key ID: 8D70E0631DD5792A
3 changed files with 36 additions and 16 deletions

View File

@ -21,7 +21,7 @@
{% set main_artist = album_liked["artists_sort"] %} {% set main_artist = album_liked["artists_sort"] %}
{% set artists = album_liked["artists"] %} {% set artists = album_liked["artists"] %}
{% set album = album_liked["title"] %} {% set album = album_liked["title"] %}
<section class="album"> <section class="album fav">
<span> <span>
<h2>{{album}}</h2> <h2>{{album}}</h2>
by by

View File

@ -1,20 +1,30 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %} {% block title %}Welcome to Frutti!{% endblock %}
{% block title %}Welcome to Frutti!{% endblock %}
{% block body %} {% block body %}
<style> <main>
.example-wrapper { margin: 1em auto; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Welcome to Frutti!</h1> <h1>Welcome to Frutti!</h1>
<p>Frutti is an application to create your own fruit record collection.</p> <p>Frutti is an application to create your own fruit record collection.</p>
<br />
<h2>But what is a fruit record collection? 🤔</h2> <h2>But what is a fruit record collection? 🤔</h2>
<p>A fruit collection is composed of albums which have a link with fruits.</p> <p>
<p>Frutti uses <a href="https://www.discogs.com/" title="Visit Discogs website">Discogs</a> to let you find albums of fruits.</p> A fruit collection is composed of albums which have a link with fruits.
</p>
<p>
Frutti uses
<a href="https://www.discogs.com/" title="Visit Discogs website"
>Discogs</a
>
to let you find albums of fruits.
</p>
<br />
<h2>Start your fruit collection today!</h2> <h2>Start your fruit collection today!</h2>
<p><a href="/register" title="Click to here to create an account">Create an account</a> or to <a href="/login" title="Click here to connect to an existing account">connect to an existing one</a>.</p> <p>
</div> <a href="/register" title="Click to here to create an account"
>Create an account</a
>
or to
<a href="/login" title="Click here to connect to an existing account"
>connect to an existing one</a
>.
</p>
</main>
{% endblock %} {% endblock %}

View File

@ -17,7 +17,10 @@ endblock %} {% block body %}
<div class="results"> <div class="results">
{% for result in results %} {% set array = result['title']|split('-') %} {% for result in results %} {% set array = result['title']|split('-') %}
{% set artist = array[0] %} {% set album = array[1] %} {% set artist = array[0] %} {% set album = array[1] %}
<section class="album" id="id{{result['id']}}"> <section
class="album {% if result['isLiked'] == 'true' %}fav{% endif %}"
id="id{{result['id']}}"
>
<span> <span>
<h2>{{album}}</h2> <h2>{{album}}</h2>
by by
@ -28,9 +31,16 @@ endblock %} {% block body %}
src="{{result['cover_image']}}" src="{{result['cover_image']}}"
alt="{{album ~ ' by ' ~ artist}}" alt="{{album ~ ' by ' ~ artist}}"
/> />
{% if result['isLiked'] == 'true' %}
<p>
<b>Already fav</b>, go to
<a href="{{url('app_favorite')}}">favorites</a>
</p>
{% else %}
<button onclick="addToFavs({{result['id']}})"> <button onclick="addToFavs({{result['id']}})">
Add to favorites Add to favorites
</button> </button>
{% endif %}
</section> </section>
{% endfor %} {% endfor %}
</div> </div>