{% extends "templates/base.html" %}
{% block title %}{{ hackathon }}{% endblock %}
{% from "www/hackathons/macros/hero.html" import hero %}
{% from "www/hackathons/macros/card.html" import null_card %}
{% from "www/hackathons/macros/navbar.html" import navbar %}
{% from "www/hackathons/macros/user.html" import show_user %}

{% block head_include %}
	<style>
		div.card-hero-img {
			height: 220px;
			background-size: cover;
			background-repeat: no-repeat;
			background-position: center;
			background-color: rgb(250, 251, 252);
		}

		.card-image-wrapper {
			display: flex;
			overflow: hidden;
			height: 220px;
			background-color: rgb(250, 251, 252);
			justify-content: center;
		}

		.image-body {
			align-self: center;
			color: #d1d8dd;
			font-size: 24px;
			font-weight: 600;
			line-height: 1;
			padding: 20px;
		}

		section {
			padding: 5rem 0 5rem 0;
		}
	</style>
{% endblock %}


{% macro card(project) %}
<div class="col-sm-4 mb-4 text-left">
	<a href="/hackathons/{{ hackathon }}/{{ project.name }}" class="no-decoration no-underline">
	<div class="card h-100">
		<div class='card-body'>
			<h5 class='card-title'>{{ project.name }}</h5>
			<div class="text-muted">{{ project.project_short_intro }}</div>
		</div>
	</div>
	</a>
</div>
{% endmacro %}

{% macro card_talk(talk) %}
<div class="col-sm-4 mb-4 text-left">
	<a href="{{talk.video_link}}" class="no-decoration no-underline">
		<div class="card h-100">
			<div class='card-body'>
				<h5 class='card-title'>{{ talk.topic }}</h5>
				<div class="text-muted">{{ talk.speaker }}</div>
				<div class="text-muted">{{ frappe.utils.format_datetime(talk.date_and_time, "medium") }}</div>
			</div>
		</div>
	</a>
</div>
{% endmacro %}

{% macro card_update(update) %}
<div class="col-sm-4 mb-4 text-left">
	<div class="card h-100">
		<div class='card-body'>
			<p>{{ frappe.utils.md_to_html(update.project_update) }}</p>
			<div>
				<a href="/hackathons/{{hackathon}}/{{update.project}}">{{ update.project}}</a>
				by {{ show_user(update.owner) }}
				<div class="text-muted">{{ frappe.utils.format_datetime(update.creation, "medium") }}</div>
			</div>
		</div>
	</div>
</div>
{% endmacro %}

{% block content %}
<section class="section">
	{{ hero(hackathon, {'name': 'Home', 'url': '/hackathons'}) }}
	<div class='container'>
		{{ navbar(hackathon) }}
		<div class="tab-content">
			<div class="tab-pane fade py-4 show active" role="tabpanel" id="home">
				<div class="row mt-5">
					{% for project in projects %}
						{{ card(project) }}
					{% endfor %}
					{% if projects %}
						{% for n in range( (3 - (projects|length)) %3) %}
							{{ null_card() }}
						{% endfor %}
					{% endif %}
				</div>
			</div>
			<div class="tab-pane fade py-4" role="tabpanel" id="talks">
				<div class="row mt-5">
					{% for talk in talks %}
						{{ card_talk(talk) }}
					{% endfor %}
					{% if talks %}
						{% for n in range( (3 - (talks|length)) %3) %}
							{{ null_card() }}
						{% endfor %}
					{% endif %}
				</div>
			</div>
			<div class="tab-pane fade py-4" role="tabpanel" id="updates">
				<div class="row mt-5">
					{% for update in updates %}
						{{ card_update(update) }}
					{% endfor %}
					{% if updates %}
						{% for n in range( (3 - (updates|length)) %3) %}
							{{ null_card() }}
						{% endfor %}
					{% endif %}
				</div>
			</div>
		</div>
	</div>
</section>
{% endblock %}
