<!--
 * @Author: ChenChanghua
 * @Date: 2023-03-08 14:52:17
 * @Description: file content
-->
<script setup>
import { ref } from "vue";
import NormalFocusBox from "./NormalFocusBox.vue";

const props = defineProps({
  data: Object,
  onAction: Object,
});
const bgImage = "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/DemoForOperator/Focus/Normal/Item/background.png";

const focused = ref(false);

// 注册回调
const onFocus = () => {
  focused.value = true;
};
const onBlur = () => {
  focused.value = false;
};
const onClick = () => {};
props.onAction.register("onFocus", onFocus);
props.onAction.register("onBlur", onBlur);
props.onAction.register("onClick", onClick);
</script>

<template>
  <div
    :style="{
      width: data.width,
      height: data.height,
      transition: 'transform 0.2s',
      transform: focused ? 'scale3d(1.05, 1.05, 1)' : null,
    }"
  >
    <div
      :style="{
        width: data.width,
        height: data.height,
        fontSize: 30,
        color: '#FFFFFF',
        backgroundImage: bgImage,
        lineHeight: data.height,
        textAlign: 'center',
      }"
    >
      普通
    </div>
    <normal-focus-box
      v-if="focused"
      color="#ffffff"
      :layout="{
        width: data.width,
        height: data.height,
      }"
      :borderWidth="5"
      :borderRadius="10"
    />
  </div>
</template>
