<script lang="ts">
  import MarkdownIt from 'markdown-it';
  const md = new MarkdownIt({
    html:true,
    xhtmlOut:true,
    typographer:  true,
    breaks: true
  });
  import data from '../model/jobs.json'
  import type { Schema } from 'src/model/job';
  export let currentLanguage = 'it'
  const jobs:Schema[] = data as Schema[];

  export function changeLanguage(language = 'it'){
    currentLanguage = language
  }
</script>
<div class="jobsContainer">
  {#each jobs as job, index }
    <div class="job container">
      <h3>{job.title[currentLanguage]}</h3>
      <div class="job-content">
        <div class="images-container">
          {#each job.images as image }
            <img src="{image}" alt="realtive to the article"/>
          {/each}
        </div>
        <div class="text-content"  id="{index.toString()}">
          {@html md.render(job.content[currentLanguage])}
        </div>
      </div>
      <div class="added-info">
        <div class="added-info">
          {job.year.start} - {job.year.end}
        </div>
        <div>
          {#each job.collaborators as collaborator}
            <a href={collaborator.ref}>{collaborator.name}{collaborator.surname}</a>
          {/each}
        </div>
        <div>
          {#each job.languages as language}
            {language+" "}
          {/each}
        </div>
        <div>
          {#each job.tecnologies as tecnology}
            {tecnology+" "}
          {/each}
        </div>
      </div>
    </div>
  {/each}
</div>
<style  lang="scss">
  @import './static/colors.scss';
  .jobsContainer{
    margin: auto;
    background-color:$steel-blue;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    height: auto;
    font-size: 1.1em;
    border-radius: 10px;
    width: 95%;

    border-radius: 10px;
    box-shadow: -12px 26px 25px -14px $rich-black-fogra-29;
    -webkit-box-shadow: -12px 26px 25px -14px $rich-black-fogra-29;
    -moz-box-shadow: -12px 26px 25px -14px $rich-black-fogra-29;
    padding-top: 1.5vh;
    padding-bottom: 1.5vh;
  }
  .job{
    background-color: $cultured;
    text-align: center;
    width: 90%;
    border-radius: 10px;
    margin-bottom: 10px;
    padding-top: 2vh;
    padding-bottom: 2vh;
    background-color: $cultured;
    border-style: solid;
    border-width: 0.1px;
  }

  .job-content{
    padding: 2vh;
  }
  
  .added-info{
    font-size: 13px;
  }

  .text-content{
    margin: auto;
    text-align: justify;
    width: 80%;
    // -webkit-hyphens: auto;
    // -moz-hyphens: auto;
    // -ms-hyphens: auto;
    // hyphens: auto;
  }

  ul{
    background-color: red;
  }
  

  img{
    max-width: 200px;
    max-height: 500px;
    background-color: $rich-black-fogra-29;
    text-align: center;
  }

  @media screen and (min-width: 600px) {
    .jobsContainer{
      display: flex;
      height: auto;
      max-width: $cv-max-width;
      width: 80vw;
    }

    .job-content{
      flex-wrap: unset;
    }
  }
  
</style>
