<script lang="ts">
	import MarkdownIt from 'markdown-it';
	import data from '../model/training.json';
	import type { Job } from '../model/job';
	import type { CurrentLanguage } from '$lib/types';

	const md = new MarkdownIt({
		html: true,
		xhtmlOut: true,
		typographer: true
	});
	export let currentLanguage: CurrentLanguage = 'it';
	const training: Job[] = data as Job[];
</script>

<div>
	{#each training as school}
		<div class="element">
			<img src={school.images[0]} alt="school logo" />
			<div>
				<h3>{school.title[currentLanguage]}</h3>
				<p>{school.content[currentLanguage]}</p>
				<p>{school.year.start} {#if school.year.end} - {school.year.end}{/if}</p>
			</div>
		</div>
	{/each}
</div>

<style lang="scss">
	@import '../../app.scss';
	.element {
		border-radius: $default-border-radius;
		background-color: $basecolor2;
		padding: 45px;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-content: center;
		margin-top: 30px;
		img {
			max-width: 100%;
			max-height: 150px;
			object-fit: scale-down;
		}
		div {
			width: 80%;
			margin: auto;
		}
	}

	@media (min-width: $min-tablet) {
		.element {
			flex-direction: row;
			div {
				width: 50%;
				margin-right: 0;
			}
			img {
				margin: auto;
			}
		}
	}
</style>
