wm-fontis-tibi-2023/frontend/src/lib/components/widgets/iconCycleBox.svelte

69 lines
1.9 KiB
Svelte
Raw Normal View History

2023-07-16 13:50:53 +02:00
<script lang="ts">
import { apiBaseURL } from "../../../config"
export let col: Column
export let pageId: string
let active = -1
setInterval(() => {
active += 1
if (active == col.iconCycleSquare.boxes.length) active = 0
}, 1000)
</script>
<div class="iconCycleSquares">
2023-07-16 23:31:08 +02:00
{#each col?.iconCycleSquare?.boxes as box, i}
2023-07-16 13:50:53 +02:00
<div class="box" id="box{i}" class:active="{i == active}">
<div class="content">
<div class="icon">
<svg stroke="{i == active ? 'black' : 'white'}" data-src="{apiBaseURL}page/{pageId}/{box.icon?.src}"
></svg>
</div>
<div class="text">
{box.text}
</div>
</div>
</div>
{/each}
</div>
<style lang="less">
@import "../../assets/css/main.less";
.iconCycleSquares {
display: flex;
flex-wrap: wrap;
gap: 10px;
@media @tablet {
gap: 20px;
}
.box {
border: 4px solid @bg-color-secondary;
background-color: @bg-color-secondary;
display: flex;
align-items: center;
justify-content: center;
color: @font-color-secondary;
&.active {
background-color: @bg-color;
color: @font-color;
}
width: 150px;
height: 150px;
.content {
display: flex;
flex-direction: column;
align-items: center;
.text {
width: 100%;
display: flex;
justify-content: center;
text-align: center;
}
}
@media @tablet {
width: 260px;
height: 260px;
}
}
}
</style>