From 432bba3dee1d9be25b9626ac45115929a6422961 Mon Sep 17 00:00:00 2001 From: Jonathan Tschanter Date: Fri, 21 Jan 2022 15:13:35 +0100 Subject: Add layout based on list entries --- public/css/style.css | 62 +++++++++++++++++++++++++++++++++++++--- src/Controller/Home.php | 6 +++- src/Model/Artwork.php | 6 ++-- templates/base.twig | 8 +++++- templates/card/card.twig | 8 ++++-- templates/card/card_add.twig | 18 ++++++++++++ templates/card/card_display.twig | 51 ++++++++++++++++++++++++--------- templates/card/card_edit.twig | 40 ++++++++++++++++---------- templates/card/card_list.twig | 56 ++++++++++++++++++------------------ templates/dashboard.twig | 40 ++++++++++++++++++++++---- 10 files changed, 221 insertions(+), 74 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index 8cb9dca..bdb53f8 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -1,7 +1,6 @@ :root { - --bg: #fff; - --accent-bg: #f5f7ff; - --bg-header: #212121; + --bg: #f5f7ff; + --accent-bg: #fff; --text-header: #dcdcdc; --text: #212121; --text-light: #585858; @@ -26,11 +25,66 @@ main h3 { } main h4 { - margin-top: 2.5rem; + margin-top: 1rem; margin-bottom: 0rem } main p { margin-top: 0.25rem; margin-bottom: 0.25rem; +} + +.vote { + background: none; + color: var(--accent); +} + +input:disabled { + cursor: default; +} + +.content { + background: var(--accent-bg); + border: 1px solid var(--border); + border-radius: 5px; + align-content: center; + text-align: center; + margin: 15px 0 15px 0; + padding: 15px; +} + +.content-header { + margin-top: 50px; +} + +.row:after { + content: ""; + display: table; + clear: both +} + +.column { + float: left; +} + +.column-5 { + width: 5%; +} + +.column-90 { + width: 90%; +} + +.column-95 { + width: 95%; +} + +.image { + max-width: 100%; + max-height:300px; +} + +.image-preview { + max-width: 100%; + max-height:300px; } \ No newline at end of file diff --git a/src/Controller/Home.php b/src/Controller/Home.php index 7eda5ee..36879e0 100644 --- a/src/Controller/Home.php +++ b/src/Controller/Home.php @@ -30,7 +30,11 @@ class Home public static function dashboard() { - return Template::render('dashboard.twig', []); + $cards = DB::$entityManager->getRepository(Card::class)->findAll(); + $cardOfTheDay = $cards[array_rand($cards)]; + return Template::render('dashboard.twig', [ + 'cardOfTheDay' => $cardOfTheDay, + ]); } } diff --git a/src/Model/Artwork.php b/src/Model/Artwork.php index 25f6ee5..6380f62 100644 --- a/src/Model/Artwork.php +++ b/src/Model/Artwork.php @@ -88,9 +88,9 @@ class Artwork { $result = DB::$entityManager ->createQuery( - 'SELECT sum(v.value) as total - FROM Elements\Model\VoteArtwork v - WHERE v.artwork = :artwork' + 'SELECT sum(v.value) as total + FROM Elements\Model\VoteArtwork v + WHERE v.artwork = :artwork' ) ->setParameter('artwork', $this) ->getOneOrNullResult(); diff --git a/templates/base.twig b/templates/base.twig index a27b5d7..758b6f8 100644 --- a/templates/base.twig +++ b/templates/base.twig @@ -2,9 +2,13 @@ {% block css %} {{ parent() }} + + + + {% endblock %} {% block body %} @@ -12,7 +16,9 @@

Elements

{% block subtitle %}{% endblock %}

diff --git a/templates/card/card.twig b/templates/card/card.twig index 9a91bfa..fcf6bd0 100644 --- a/templates/card/card.twig +++ b/templates/card/card.twig @@ -4,9 +4,11 @@ Cards {% endblock %} {% block main %} -
- - +
+ + +
+

{% block pagetitle %}{% endblock %}

diff --git a/templates/card/card_add.twig b/templates/card/card_add.twig index ef01632..db91fc4 100644 --- a/templates/card/card_add.twig +++ b/templates/card/card_add.twig @@ -1,5 +1,23 @@ {% extends 'card/card.twig' %} +{% block pagetitle %} + Edit Card +{% endblock %} +{% block pagecontent %} +
+
+ {% for meta in card.meta %} +

+
+ +

+ {% endfor %} + + +
+
+{% endblock %} + {% block pagetitle %} Add Card {% endblock %} diff --git a/templates/card/card_display.twig b/templates/card/card_display.twig index 27d5bea..7b2ed3e 100644 --- a/templates/card/card_display.twig +++ b/templates/card/card_display.twig @@ -4,22 +4,45 @@ Show Card {% endblock %} {% block pagecontent %} - {% for meta in card.meta %} -

-
- -

- {% endfor %} +
+ +
+ +
+
+
+ + {{ card.getVotesTotal() }} + +
+
+ {% for meta in card.meta %} +

+
+ +

+ {% endfor %} +
+
+
- +
+

Artworks

+
-

Artworks

{% for artwork in card.artworks %} -

- - - - -

+
+
+
+ + {{ artwork.getVotesTotal() }} + +
+
+ + +
+
+
{% endfor %} {% endblock %} diff --git a/templates/card/card_edit.twig b/templates/card/card_edit.twig index a7f9aa7..b066437 100644 --- a/templates/card/card_edit.twig +++ b/templates/card/card_edit.twig @@ -4,23 +4,33 @@ Edit Card {% endblock %} {% block pagecontent %} -
- {% for meta in card.meta %} -

-
- -

- {% endfor %} +
+ + {% for meta in card.meta %} +

+
+ +

+ {% endfor %} - - + + +
+ +
+

Edit Artworks

+
+ +
+ +
-

Artworks

{% for artwork in card.artworks %} -

- +

+ - -

+ +
{% endfor %} -{% endblock %} + +{% endblock %} \ No newline at end of file diff --git a/templates/card/card_list.twig b/templates/card/card_list.twig index 1714fc8..b6d8bbe 100644 --- a/templates/card/card_list.twig +++ b/templates/card/card_list.twig @@ -4,35 +4,35 @@ List {% endblock %} {% block pagecontent %} - - - - - {% for meta in cards[0].getAllMeta() %} - - {% endfor %} - - - - - - {% for card in cards %} - - - {% for meta in card.getAllMeta() %} - - {% endfor %} - - - - {% endfor %} - -
ID{{ meta.key }}Votes
{{ card.id }}{{ meta.value }} + {% for card in cards %} +
+
+
+ {{ card.getVotesTotal() }} - - -
+ + +
+ + + + {% for meta in card.getAllMeta() %} + + {% endfor %} + + + + + {% for meta in card.getAllMeta() %} + + {% endfor %} + + +
{{ meta.key }}
{{ meta.value }}
-
+
+ + + {% endfor %} {% endblock %} diff --git a/templates/dashboard.twig b/templates/dashboard.twig index 31f2353..97534bf 100644 --- a/templates/dashboard.twig +++ b/templates/dashboard.twig @@ -4,9 +4,39 @@ Dashboard {% endblock %} {% block main %} -

Home?

-

Updates to own cards?

-

Card of the day?

-

Events?

-

News?

+
+

Hello World

+
+
+

Cards

+
+
+

Card of the day

+
+
+ + {{ cardOfTheDay.getVotesTotal() }} + +
+
+ {% for meta in cardOfTheDay.meta %} +

+
+ +

+ {% endfor %} +
+ + +
+
+
+

Updates to my cards

+
+
+

Events

+
+
+

News

+
{% endblock %} -- cgit v1.2.3