site-libsoc/Server/app/svelte/src/parties-component.svelte

185 lines
4.6 KiB
Svelte
Raw Normal View History

2023-07-13 01:25:28 +07:00
<svelte:options tag="parties-component" />
<script>
// Import statements
import { onMount } from 'svelte'
import { writable } from 'svelte/store';
2023-07-13 18:32:49 +07:00
import { partiesByCountry, addMarkersParties } from '/js/parties.js'
2023-07-13 01:25:28 +07:00
import { loadLocaleContent } from "/js/libraries/serverTools.js"
// Import components
import "/js/components/map-component.js"
// Main code
2023-07-13 18:32:49 +07:00
let loaded = writable(0)
2023-07-13 01:25:28 +07:00
let content = writable({})
2023-07-13 18:32:49 +07:00
loadLocaleContent(content,"countries",loaded)
loadLocaleContent(content,"parties-component",loaded)
2023-07-13 01:25:28 +07:00
function mapCallbackParties(createMap,content) {
let map = createMap([22, 0],2)
addMarkersParties(map,content)
}
onMount(() => {
})
</script>
2023-07-13 18:32:49 +07:00
{#key $loaded}
{#if $loaded==2}
2023-07-13 01:25:28 +07:00
<div id="container">
<!--<img src="img/crowd.png" id="crowd" alt="crowd">-->
<div id="text-container">
<h1>{$content.heading}</h1>
<img id="party-img" src="/img/common/parties.svg" alt="party">
<p>{$content.p1}</p>
<h3>{$content.subheading1}</h3>
<map-component id="map" callback={(createMap) => mapCallbackParties(createMap,$content)}></map-component>
2023-07-13 18:32:49 +07:00
{#each Object.entries(partiesByCountry) as [name,parties]}
2023-07-13 18:34:45 +07:00
<h4 class="country-name">{$content[name]}</h4>
2023-07-13 18:32:49 +07:00
<div class="country-block">
{#each parties as party}
<div class="location-info">
<div class="img-general-info">
<picture>
<source srcset={"/img/parties/"+party.logo+".webp"}>
<source srcset={"/img/parties/"+party.logo+".jpg"}>
<img class="party-logo" alt="logo">
</picture>
<div>
<p><b>{$content.name}: </b>{party.name}</p>
<p><b>{$content.location}: </b>{$content[party.location[0]]}</p>
<p><b>{$content.link}: </b><a href={party.link} target=;_blank; rel=noreferrer>{party.link}</a></p>
</div>
2023-07-13 01:25:28 +07:00
</div>
2023-07-13 18:32:49 +07:00
<p><b>{$content.description}: </b>{$content[party.description]}</p>
2023-07-13 01:25:28 +07:00
</div>
2023-07-13 18:32:49 +07:00
{/each}
2023-07-13 01:25:28 +07:00
</div>
{/each}
</div>
</div>
{/if}
{/key}
<style>
@import '/css/common.css';
#party-img {
position: absolute;
width: 11.5rem;
left: 50%;
transform: translate(-50%);
z-index: 0;
opacity: 0.2;
}
#text-container>:nth-child(3) {
margin-top: 8rem;
}
h4 {
margin-bottom: 2rem;
}
2023-07-13 18:32:49 +07:00
.country-name {
margin-bottom: 1rem;
}
.country-block {
margin-bottom: 2rem;
}
2023-07-13 01:25:28 +07:00
.location-info {
position: relative;
2023-07-13 18:32:49 +07:00
margin-bottom: 1rem;
2023-07-13 01:25:28 +07:00
}
.location-info p {
margin-bottom: 0;
}
.img-general-info {
display: flex;
align-content: center;
width: 100%;
gap: 1.5rem;
align-items: center;
2023-07-13 18:32:49 +07:00
margin-bottom: 0.75rem;
2023-07-13 01:25:28 +07:00
}
.img-general-info>:nth-child(2) {
flex:none;
}
.party-logo {
position: relative;
right: 0;
2023-07-13 18:32:49 +07:00
max-height: 5.5rem;
2023-07-13 01:25:28 +07:00
max-width: 100%;
border-radius: 1rem;
}
a {
color: #DD1C1A;
}
#map {
--height: 30rem;
--width: 100%;
--margin-bottom: 3rem;
}
#text-container {
max-width: calc(100vw - 4rem);
margin: auto;
}
h1 {
margin-bottom: 1rem;
font-size: 2.2rem;
text-align: center;
}
h3 {
margin-bottom: 1rem;
}
#container {
margin: auto;
max-width: 800px;
margin-top: 1rem;
margin-bottom: 4rem;
}
#container>div>p {
margin-bottom: 1rem;
}
#container p {
text-align: justify;
}
@media only screen and (max-width: 500px) {
.img-general-info {
display: flex;
flex-direction: column;
align-content: left;
width: 100%;
gap: 1rem;
align-items: left;
margin-bottom: 0rem;
}
.img-general-info>:nth-child(1) {
width: max-content;
}
.img-general-info>:nth-child(2) {
width: 100%;
}
}
</style>