2021-11-26 14:41:34 +01:00
|
|
|
<script>
|
2021-12-06 15:58:12 +01:00
|
|
|
import { onMount } from 'svelte'
|
|
|
|
|
export let baseurl = ''
|
2021-11-26 14:41:34 +01:00
|
|
|
export let title = 'Gancio events'
|
|
|
|
|
export let maxlength = false
|
2021-12-06 15:58:12 +01:00
|
|
|
export let tags = ''
|
|
|
|
|
export let places = ''
|
2022-01-13 21:52:20 +01:00
|
|
|
export let theme = 'light'
|
2021-11-26 14:41:34 +01:00
|
|
|
|
2021-12-06 23:21:16 +01:00
|
|
|
let mounted = false
|
2021-11-26 14:41:34 +01:00
|
|
|
let events = []
|
|
|
|
|
|
2021-12-06 15:58:12 +01:00
|
|
|
function update (v) {
|
2021-12-06 23:21:16 +01:00
|
|
|
if (!mounted) return
|
2021-11-26 14:41:34 +01:00
|
|
|
const params = []
|
|
|
|
|
if (maxlength) {
|
|
|
|
|
params.push(`max=${maxlength}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(tags) {
|
2021-12-06 15:58:12 +01:00
|
|
|
params.push(`tags=${tags}`)
|
2021-11-26 14:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-06 15:58:12 +01:00
|
|
|
if (places) {
|
|
|
|
|
params.push(`places=${places}`)
|
|
|
|
|
}
|
2021-11-26 14:41:34 +01:00
|
|
|
|
2021-12-06 15:58:12 +01:00
|
|
|
fetch(`${baseurl}/api/events?${params.join('&')}`)
|
2021-11-26 14:41:34 +01:00
|
|
|
.then(res => res.json())
|
2021-12-06 15:58:12 +01:00
|
|
|
.then(e => {
|
|
|
|
|
events = e
|
|
|
|
|
})
|
2022-01-13 21:52:20 +01:00
|
|
|
.catch(e => {
|
|
|
|
|
console.error('Error loading Gancio API -> ', e)
|
|
|
|
|
})
|
2021-11-26 14:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-06 15:58:12 +01:00
|
|
|
|
2021-11-26 14:41:34 +01:00
|
|
|
function when (timestamp) {
|
|
|
|
|
return new Date(timestamp*1000)
|
|
|
|
|
.toLocaleDateString(undefined,
|
|
|
|
|
{
|
|
|
|
|
weekday: 'long',
|
|
|
|
|
month: 'short',
|
|
|
|
|
day: 'numeric',
|
|
|
|
|
hour: '2-digit',
|
|
|
|
|
minute: '2-digit'
|
|
|
|
|
})
|
|
|
|
|
}
|
2021-12-06 23:21:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
mounted = true
|
|
|
|
|
update()
|
|
|
|
|
})
|
2022-01-13 21:52:20 +01:00
|
|
|
$: update(maxlength && title && places && tags && theme)
|
2021-11-26 14:41:34 +01:00
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
<svelte:options tag="gancio-events"/>
|
|
|
|
|
{#if events.length}
|
2022-01-13 21:52:20 +01:00
|
|
|
<div id='gancioEvents' class='{theme}'>
|
2021-12-02 10:47:37 +01:00
|
|
|
<a href='{baseurl}' target='_blank'>
|
|
|
|
|
<div class='content'>
|
|
|
|
|
<span id='headerTitle'>{title || 'Gancio'}</span>
|
|
|
|
|
<img id='logo' alt='logo' src='{baseurl}/logo.png'/>
|
|
|
|
|
</div>
|
|
|
|
|
</a>
|
2021-11-26 14:41:34 +01:00
|
|
|
{#each events as event}
|
2022-01-13 21:52:20 +01:00
|
|
|
<a href='{baseurl}/event/{event.slug || event.id}' title='{event.title}' target='_blank'>
|
2021-11-26 14:41:34 +01:00
|
|
|
<div class='content'>
|
|
|
|
|
<div class='subtitle'>
|
|
|
|
|
{when(event.start_datetime)}
|
|
|
|
|
<span class='place'>@{event.place.name}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class='title'>
|
|
|
|
|
{event.title}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</a>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
|
|
#gancioEvents {
|
|
|
|
|
font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
|
|
|
|
|
overflow-x: hidden;
|
|
|
|
|
font-size: 1rem;
|
|
|
|
|
width: 100%;
|
|
|
|
|
max-width: 500px;
|
|
|
|
|
box-sizing: content-box;
|
2022-01-13 21:52:20 +01:00
|
|
|
box-shadow: rgba(60, 64, 67, 0.4) 0px 1px 2px 0px, rgba(60, 64, 67, 0.25) 0px 1px 3px 1px;
|
|
|
|
|
border-radius: 5px;
|
2021-11-26 14:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#logo {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 10px;
|
|
|
|
|
right: 10px;
|
|
|
|
|
height: 40px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#headerTitle {
|
|
|
|
|
line-height: 45px;
|
|
|
|
|
font-size: 1.3rem;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a {
|
|
|
|
|
text-decoration: none;
|
2022-01-13 21:52:20 +01:00
|
|
|
color: var(--text-color);
|
2021-11-26 14:41:34 +01:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
flex: 1 1 100%;
|
|
|
|
|
padding: 8px 20px;
|
|
|
|
|
margin: 0;
|
|
|
|
|
line-height: 1.275rem;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
font-size: .875rem;
|
|
|
|
|
position: relative;
|
|
|
|
|
transition: background-color .3s cubic-bezier(.25,.8,.5,1), padding-left .3s;
|
|
|
|
|
box-sizing: content-box;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-13 21:52:20 +01:00
|
|
|
.dark {
|
|
|
|
|
--bg-odd-color: #161616;
|
|
|
|
|
--bg-even-color: #222;
|
|
|
|
|
--bg-hover-color: #333;
|
|
|
|
|
--text-color: white;
|
|
|
|
|
--title-color: white;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.light {
|
|
|
|
|
--bg-odd-color: #f5f5f5;
|
|
|
|
|
--bg-even-color: #FAFAFA;
|
|
|
|
|
--bg-hover-color: #EEE;
|
|
|
|
|
--text-color: #222;
|
|
|
|
|
--title-color: black;
|
|
|
|
|
}
|
2021-11-26 14:41:34 +01:00
|
|
|
a:nth-child(odd) {
|
2022-01-13 21:52:20 +01:00
|
|
|
background-color: var(--bg-odd-color);
|
2021-11-26 14:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a:nth-child(even) {
|
2022-01-13 21:52:20 +01:00
|
|
|
background-color: var(--bg-even-color);
|
2021-11-26 14:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a:first-child {
|
|
|
|
|
border-radius: 5px 5px 0px 0px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a:last-child {
|
|
|
|
|
border-radius: 0px 0px 5px 5px;
|
|
|
|
|
padding-bottom: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a:hover {
|
2022-01-13 21:52:20 +01:00
|
|
|
background-color: var(--bg-hover-color);
|
2021-11-26 14:41:34 +01:00
|
|
|
padding-left: 23px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.place {
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
color: #ff6e40;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.title {
|
2022-01-13 21:52:20 +01:00
|
|
|
color: var(--title-color);
|
2022-01-26 14:36:15 +01:00
|
|
|
font-weight: bold;
|
2021-11-26 14:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|