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

176 lines
4.6 KiB
Svelte
Raw Normal View History

2023-06-24 04:39:41 +07:00
<svelte:options tag="cooperatives-component" />
<script>
// Import statements
import { onMount } from 'svelte'
2023-07-03 03:07:45 +07:00
import { writable } from 'svelte/store';
2023-06-24 20:44:16 +07:00
import { coops, addMarkersCoops } from '/js/coops.js'
2023-07-03 03:07:45 +07:00
import { loadLocaleContent,getLocale } from "/js/libraries/serverTools.js"
2023-06-24 04:39:41 +07:00
// Import components
2023-06-24 20:44:16 +07:00
import "/js/components/map-component.js"
2023-06-24 04:39:41 +07:00
// Main code
2023-07-03 03:07:45 +07:00
let loaded
let locale = []
let content = writable({})
loadLocaleContent(content,"cooperatives-component",loaded,(lang) => getLocale(locale,lang))
function mapCallbackCoops(createMap,content,locale) {
2023-06-24 20:44:16 +07:00
let map = createMap([51.505, -0.09],3)
2023-07-03 03:07:45 +07:00
addMarkersCoops(map,content,locale)
2023-06-24 20:44:16 +07:00
}
2023-06-24 04:39:41 +07:00
onMount(() => {
})
</script>
2023-07-03 03:07:45 +07:00
{#key loaded}
{#if Object.keys($content).length!=0}
<div id="container">
<div id="text-container">
<h1>{$content.heading}</h1>
<img id="coops-img" src="/img/common/coops.svg" alt="coops">
<p>{$content.p1}</p>
<p>{$content.p2}</p>
<h3>{$content.subheading1}</h3>
<map-component id="map" callback={(createMap) => mapCallbackCoops(createMap,$content,locale)}></map-component>
<h4>{$content.subheading2}</h4>
{#each coops as coop}
<div class="location-info">
<div class="img-general-info">
<div>
<p><b>{$content.name}: </b>{coop.name}</p>
<p><b>{$content.location}: </b>{coop.location[0][locale[0]]}</p>
<p><b>{$content.market}: </b>{coop.market[locale[0]]}</p>
<p><b>{$content.workers}: </b>{coop.workers}</p>
<p><b>{$content.status}: </b>{coop.status[locale[0]]}</p>
<p><b>{$content.website}: </b><a href={"https://www."+coop.website} target="_blank" rel=noreferrer>{coop.website}</a></p>
<p><b>{$content.contact}: </b><a href={coop.contact[0]} target=;_blank; rel=noreferrer>{coop.contact[1][locale[0]]}</a></p>
</div>
<picture>
<source srcset={"/img/coops/"+coop.logo+".webp"}>
<source srcset={"/img/coops/"+coop.logo+".png"}>
<img class="coop-logo" alt="logo">
</picture>
</div>
<p><b>{$content.description}: </b>{coop.description[locale[0]]}</p>
2023-06-24 20:44:16 +07:00
</div>
2023-07-03 03:07:45 +07:00
{/each}
2023-06-24 20:44:16 +07:00
</div>
2023-07-03 03:07:45 +07:00
</div>
{/if}
{/key}
2023-06-24 04:39:41 +07:00
<style>
@import '/css/common.css';
2023-06-25 02:29:07 +07:00
#coops-img {
position: absolute;
width: 10.5rem;
left: 50%;
transform: translate(-50%);
z-index: 0;
opacity: 0.2;
}
#text-container>:nth-child(3) {
margin-top: 8rem;
}
2023-06-27 03:14:59 +07:00
.img-general-info {
2023-06-24 20:44:16 +07:00
display: flex;
align-content: center;
width: 100%;
justify-content: space-between;
gap: 3rem;
align-items: center;
}
2023-06-27 03:14:59 +07:00
.img-general-info>:first-child {
2023-06-24 20:44:16 +07:00
flex:none;
}
.coop-logo {
position: relative;
right: 0;
2023-06-28 21:17:51 +07:00
max-height: 6rem;
2023-06-24 20:44:16 +07:00
max-width: 100%;
}
h4 {
margin-bottom: 2rem;
}
.location-info {
position: relative;
margin-bottom: 2rem;
}
.location-info p {
margin-bottom: 0;
}
a {
color: #DD1C1A;
}
#map {
--height: 30rem;
--width: 100%;
--margin-bottom: 3rem;
}
#text-container {
max-width: calc(100vw - 4rem);
margin: auto;
}
h1 {
margin-bottom: 1rem;
2023-06-28 18:00:41 +07:00
font-size: 2.2rem;
2023-06-24 20:44:16 +07:00
text-align: center;
}
h3 {
margin-bottom: 1rem;
}
#container {
margin: auto;
2023-07-03 03:07:45 +07:00
max-width: 800px;
2023-06-24 20:44:16 +07:00
margin-top: 1rem;
margin-bottom: 4rem;
}
#container>div>p {
margin-bottom: 1rem;
}
#container p {
text-align: justify;
}
2023-06-24 04:39:41 +07:00
2023-06-27 03:14:59 +07:00
@media only screen and (max-width: 600px) {
.img-general-info {
display: flex;
flex-direction: column-reverse;
align-content: left;
width: 100%;
gap: 1rem;
align-items: left;
margin-bottom: 0rem;
}
.img-general-info>:nth-child(2) {
width: max-content;
}
.img-general-info>:nth-child(1) {
width: 100%;
}
}
2023-06-24 04:39:41 +07:00
</style>