<script lang="ts">
    import { apiBaseURL } from "../../../config"
    import { mediaLibrary } from "../../store"

    export let pageId: string
    export let col: Column
    console.log("icons:", col.iconBlocks, $mediaLibrary, $mediaLibrary[col.iconBlocks[0].icon])
</script>

<div class="iconBlock">
    {#each col.iconBlocks as icon}
        <div class="icon">
            <img
                alt="{$mediaLibrary[icon.icon]?.alt || ''}"
                title="{$mediaLibrary[icon.icon]?.title || ''}"
                src="{`${apiBaseURL}medialib/${icon.icon}/${$mediaLibrary?.[icon?.icon]?.file?.src}`}"
            />
            <div class="text">
                <em>{icon.bigText}</em>
                <p>{icon.smallText}</p>
            </div>
        </div>
    {/each}
</div>

<style lang="less">
    @import "../../assets/css/main.less";
    .iconBlock {
        display: flex;
        justify-content: start;
        flex-wrap: wrap;
        .icon {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 150px;
            gap: 10px;
            max-width: 45%;
            flex-grow: 1;
            font-size: 0.9rem;
            margin: 20px 0px;
            @media @tablet {
                max-width: initial;
                flex-grow: initial;
                width: 160px;
            }
            @media @desktop {
                width: 213px;
            }
            img {
                width: 75%;
                height: auto;
            }
            .text {
                display: flex;
                flex-direction: column;

                em {
                    text-align: center;
                    font-size: 2.2rem;
                    font-family: "Libre Caslon Text", serif;
                    font-style: normal;
                }
                p {
                    text-align: center;
                    font-weight: bold;
                    font-size: 1rem;
                    @media (max-width: 1050px) {
                        font-size: 0.7rem;
                    }
                }
            }
        }
    }
</style>
