<template>
  <div class="toolbar">
    <div class="toolbar-header">
      <div class="toolbar-header-title">家具列表</div>
      <div class="toolbar-header-extra"><slot name="extra"></slot></div>
    </div>

    <div class="toolbar-content">
      <div class="toolbar-content-item">
        <div class="toolbar-content-item-header">客厅</div>
        <furniture-list :icons="livingroomIcons" @add="add"></furniture-list>
      </div>

      <div class="toolbar-content-item">
        <div class="toolbar-content-item-header">餐厅</div>
        <furniture-list :icons="diningroomIcons" @add="add"></furniture-list>
      </div>

      <div class="toolbar-content-item">
        <div class="toolbar-content-item-header">卧室</div>
        <furniture-list :icons="bedroomIocns" @add="add"></furniture-list>
      </div>

      <div class="toolbar-content-item">
        <div class="toolbar-content-item-header">卫生间</div>
        <furniture-list :icons="bathroomIocns" @add="add"></furniture-list>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import type { FurnitureIconType } from '@/types/furniture'

defineOptions({
  name: 'furnitureCard',
})

const emit = defineEmits<{
  (e: 'add', value: FurnitureIconType): void
  (e: 'update:isEdit', value: boolean): void
}>()

// const props = withDefaults(
//   defineProps<{
//     isEdit: boolean
//   }>(),
//   {
//     isEdit: false,
//   }
// )

// 客厅图标
const livingroomIcons = [
  'living_sofa',
  'living_sofa_single',
  'living_tea_table',
  'living_bookcase',
  'living_tv_stand',
  'bath_door',
  // 'dining_floor',
]

// 餐厅图标
const diningroomIcons = [
  'dining_table',
  'dining_table_rect',
  'dining_fridge',
  'dining_chair',
  'bath_door',
  // 'dining_floor',
]

// 卧室图标
const bedroomIocns = [
  'bed',
  'bed_table',
  'bed_dressing_chair',
  'bed_dressing_mirror',
  'bed_cabinet',
  // 'bed_floor',
]

// 卫生间图标
const bathroomIocns = [
  'bath_basin',
  'bath_shower',
  'bath_toilet',
  'bath_floor',
  // 'bath_door'
]

// 添加家具
const add = (icon: FurnitureIconType) => {
  emit('add', icon)
}
</script>

<style scoped lang="less">
.toolbar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;

  &-header {
    flex-grow: 1;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 600;
  }

  &-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-gap: 10px;
    &-item {
      background-color: #f5f5f5;
      border-radius: 10px;
      padding: 12px;
      &-header {
        font-size: 14px;
        margin-bottom: 10px;
        font-weight: 600;
      }
    }
  }
}
</style>
