<template>
    <div class="allproduct">
        <div class="product">
            <div class="product-img position-relative" v-for="item, index in allList" :key="index"
                @click="goPage(`/productcenter/${item.name}`)">
                <img :src="item.url" :alt="item.name" loading="lazy">
                <span class="imgtitle position-absolute color-fff">{{ item.name }}</span>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import router from '../router';

let allList = Array<any>(
    { url: new URL("../assets/img/center01.jpg", import.meta.url).href, name: 'Door'},
    { url: new URL("../assets/img/center02.jpg", import.meta.url).href, name: 'Window' },
    { url: new URL("../assets/img/center03.jpg", import.meta.url).href, name: 'Railing' },
    { url: new URL("../assets/img/center04.jpg", import.meta.url).href, name: 'Building Materials' },
    { url: new URL("../assets/img/center05.jpg", import.meta.url).href, name: 'Kitchen Cabinets with Customization' },
    { url: new URL("../assets/img/center06.jpg", import.meta.url).href, name: 'Kitchen faucet and sink' },
    { url: new URL("../assets/img/center07.jpg", import.meta.url).href, name: 'Sanitary Ware' },
)

const goPage = (url: any) => {
    document.documentElement.scrollTop = 0
    router.push(url)
}
</script>

<style scoped lang="less">
.allproduct {
    width: 100%;
    margin-top: 1rem;

    .product {
        box-sizing: border-box;
        padding: 1rem;
        width: 100%;
        display: flex;
        flex-wrap: wrap;

        .product-img {
            width: 23%;
            height: 35vw;
            overflow: hidden;
            margin-right: 2rem;
            margin-bottom: 2rem;

            img {
                width: 100%;
                height: 100%;
                transition: 0.5s linear;
            }

            .imgtitle {
                width: 100%;
                bottom: 0;
                left: 0;
                height: 5rem;
                background: rgba(0, 0, 0, 0.3);
                font-size: 26px;
                display: flex;
                align-items: center;
                justify-content: center;
            }

            img:hover {
                scale: 1.2;
            }

            img:hover+.imgtitle {
                background: #fa8106;
            }
        }
    }
}

@media screen and (max-width: 960px) {
    .allproduct {
        margin-top: 2rem;

        .product {
            display: flex;
            flex-direction: column;

            .product-img {
                width: 100%;
                height: 125vw;

                img {
                    width: 100%;
                    height: 100%;
                }
            }
        }
    }
}</style>