<template>
  <div class="room">
    <div class="room-title">
      你的房间: 4
    </div>
    <div class="room-content">
      <template
        v-for="(item, index) in roomList"
        :key="index"
      >
        <div
          class="room-content-item"
          @click="change('/list')"
        >
          <div>
            <p>客厅</p>
            <div>
              <Icon
                name="10"
                :size="20"
              />
              4个设备
            </div>
          </div>
        </div>
      </template>
    </div>
    <div class="room-bar">
      <span>创建你的房间</span>
      <n-button
        type="warning"
        @click="change('/create')"
      >
        创建
      </n-button>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const roomList = ref([
  { 1: 1 },
  { 1: 1 },
  { 1: 1 },
  { 1: 1 },
  { 1: 1 },
  { 1: 1 },
  { 1: 1 },
  { 1: 1 }
])

function change(url:string) {
  router.push(url)
}
</script>
<style lang="scss" scoped>
.room {
  height: 100%;
  padding: 40px 4% 0 4%;
  min-width: 327px;

  &-title {
    font-size: 18px;
  }

  &-content {
    margin-top: 20px;
    padding-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    height: calc(100% - 96px);
    overflow-y: auto;
    gap: 15px;

    &-item {
      /* 增长1 不缩小 基础宽度200px */
      flex: 1 0 286px;
      height: 180px;
      padding: 10px 20px;
      background: radial-gradient(circle at right, #40464d00, #40464d75 35%), url(./img/1.png) no-repeat right;
      background-size: contain;
      background-blend-mode: overlay;
      box-shadow: 0px 4px 20px -2px rgba(50, 50, 71, 0.02), 0px 0px 5px 0px rgba(12, 26, 75, 0.04);
      border-radius: 12px;
      cursor: pointer;
      overflow: hidden;
      position: relative;

      &>div>div {
        display: flex;
        align-items: center;

        svg {
          margin-right: 5px;
          color: var(--n-text-color);
        }
      }

      &:hover {
        background-color: rgba(99, 226, 183, 0.15);
      }
    }

  }

  &-bar {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    :deep(.n-button) {
      --n-width: 30%;
      max-width: 200px;
      --n-border-radius: 10px;
    }
  }
}
</style>
