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

221 lines
5.9 KiB
Svelte
Raw Normal View History

2023-07-03 03:07:45 +07:00
<svelte:options tag="partners-component" />
<script>
// Import statements
import { onMount } from 'svelte'
import { writable } from 'svelte/store';
2023-07-28 21:49:29 +07:00
import { loadLocaleContent, getData} from "/js/libraries/serverTools.js"
import { addMarkersEntries, translate } from "/js/libraries/mapTools.js"
import { addPartnersPinContent } from "/js/mapFuncs.js"
2023-07-03 03:07:45 +07:00
// Import components
import "/js/components/map-component.js"
// Main code
2023-07-13 18:32:49 +07:00
let loaded = writable(0)
2023-07-03 03:07:45 +07:00
let content = writable({})
2023-07-28 21:49:29 +07:00
let entries
let entriesByCountry
2023-07-03 03:07:45 +07:00
let locale = loadLocaleContent(content,"partners-component",loaded)
2023-07-28 21:49:29 +07:00
loadLocaleContent(content,"countries",loaded)
2023-07-28 21:49:29 +07:00
let callback = (response) => {
entries = JSON.parse(response)
entriesByCountry = {}
for (let g of entries) {
let country = g.country
if (g.contact==null) {
g.contact = "https://discord.gg/Qk8KUk787z"
}
if (country in entriesByCountry) {
entriesByCountry[country].push(g)
}
else {
entriesByCountry[country] = [g]
}
}
loaded.update((val) => {
return val + 1
})
}
2023-07-28 21:49:29 +07:00
getData("/assets/partners.json",callback)
2023-07-28 21:49:29 +07:00
function mapCallback(createMap,content,locale) {
let map = createMap([22, 0],2)
addMarkersEntries(entries,entriesByCountry,map,content,locale,addPartnersPinContent,"blue")
}
function getCountry(x) {
return locale=="en" ? x : translate($content,x)
}
function getAddress(g) {
let location = [g.country,g.state,g.town].filter(x => x!=null)
return location.map(x => locale=="en" ? x : translate($content,x)).join(", ")
}
2023-07-03 03:07:45 +07:00
onMount(() => {
})
</script>
2023-07-13 18:32:49 +07:00
{#key $loaded}
2023-07-28 21:49:29 +07:00
{#if $loaded==3}
2023-07-03 03:07:45 +07:00
<div id="container">
<!--<img src="img/crowd.png" id="crowd" alt="crowd">-->
<div id="text-container">
<h1>{$content.heading}</h1>
<img id="hands-img" src="/img/common/handshake.svg" alt="hands">
<p>{$content.p1}</p>
<h3>{$content.subheading1}</h3>
2023-07-28 21:49:29 +07:00
<map-component id="map" callback={(createMap) => mapCallback(createMap,$content,locale)}></map-component>
<p id="add-prompt">{$content["map-prompt"]}</p>
{#each Object.entries(entriesByCountry) as [name,entries]}
<h4 class="country-name">{getCountry(name)}</h4>
2023-07-13 18:32:49 +07:00
<div class="country-block">
2023-07-28 21:49:29 +07:00
{#each entries as entry}
2023-07-13 18:32:49 +07:00
<div class="location-info">
<div class="img-general-info">
<picture>
2023-07-28 21:49:29 +07:00
<source srcset={"/img/partners/"+entry.logo+".webp"}>
<source srcset={"/img/partners/"+entry.logo+".jpg"}>
2023-07-13 18:32:49 +07:00
<img class="partner-logo" alt="logo">
</picture>
<div>
2023-07-28 21:49:29 +07:00
<p><b>{$content.name}: </b>{entry.name}</p>
<p><b>{$content.location}: </b>{getAddress(entry)}</p>
<p><b>{$content.website}: </b><a href={entry.website} target=;_blank; rel=noreferrer>{entry.website}</a></p>
2023-07-30 17:30:18 +07:00
<p><b>{$content.contact}: </b><a href={entry.contact} target=;_blank; rel=noreferrer>{entry.contact}</a></p>
2023-07-13 18:32:49 +07:00
</div>
2023-07-03 03:07:45 +07:00
</div>
2023-07-28 21:49:29 +07:00
<p><b>{$content.description}: </b>{entry.description}</p>
2023-07-03 03:07:45 +07:00
</div>
2023-07-13 18:32:49 +07:00
{/each}
2023-07-03 03:07:45 +07:00
</div>
{/each}
</div>
</div>
{/if}
{/key}
<style>
@import '/css/common.css';
#hands-img {
position: absolute;
width: 10.5rem;
left: 50%;
transform: translate(-50%);
z-index: 0;
opacity: 0.2;
margin-top: -2rem;
}
#text-container>:nth-child(3) {
margin-top: 6rem;
}
.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.5rem;
2023-07-03 03:07:45 +07:00
}
.img-general-info>:nth-child(2) {
flex:none;
}
.partner-logo {
position: relative;
right: 0;
2023-07-13 18:32:49 +07:00
max-height: 6.5rem;
2023-07-03 03:07:45 +07:00
max-width: 100%;
border-radius: 1rem;
}
h4 {
margin-bottom: 2rem;
}
2023-07-13 18:32:49 +07:00
.country-name {
margin-bottom: 0.5rem;
}
.country-block {
margin-bottom: 2rem;
}
2023-07-03 03:07:45 +07:00
.location-info {
position: relative;
2023-07-13 18:32:49 +07:00
margin-bottom: 0.5rem;
2023-07-03 03:07:45 +07:00
}
.location-info p {
margin-bottom: 0;
}
a {
color: #DD1C1A;
}
#map {
--height: 30rem;
--width: 100%;
2023-07-28 21:49:29 +07:00
--margin-bottom: 0.5rem;
2023-07-03 03:07:45 +07:00
}
#text-container {
max-width: calc(100vw - 4rem);
margin: auto;
}
h1 {
margin-bottom: 1rem;
font-size: 2.2rem;
text-align: center;
}
h3 {
2023-07-28 21:49:29 +07:00
margin-bottom: 1rem;
2023-07-03 03:07:45 +07:00
}
#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>