import { css, cx } from "@linaria/core";
import { IconMore } from "@queenjs/icons";
import { Image, View } from "@queenjs/ui";
import { Divider, Dropdown, Menu, Tag } from "ant-design-vue";
import { defineComponent } from "vue";
import { any } from "vue-types";

export default defineComponent({
  props: {
    record: any(),
  },
  emits: [],
  setup(props) {
    return () => {
      const { record } = props;

      return (
        <div class={cx(itemStyles, "relative")}>
          <View ratio={1.4} class="overflow-hidden relative">
            <Image class="h-1/1 w-1/1" src={record?.thumbnail?.url} />
            <Tag
              color="#E88B00"
              // color="rgba(0, 0, 0, 0.4)"
              class="absolute top-0 left-0 z-1 !rounded-none"
            >
              未发布
            </Tag>
            <div class="absolute inset-0 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity">
              <div class="text-white icon_action w-60px leading-60px orange cursor-pointer rounded-1/2 text-center">
                编辑
              </div>
              <div class="text-white icon_action w-60px leading-60px ml-10px cursor-pointer rounded-1/2 text-center">
                预览
              </div>
            </div>
          </View>
          <div class="item_footer rounded-b-4px flex items-center justify-between p-15px">
            <div>
              <div class="text-white text-bold">皮革2</div>
              <div class="flex items-center text-opacity-60 text-white text-12px mt-5px">
                2021.09.09发布 <Divider type="vertical"></Divider> 23次浏览
              </div>
            </div>
            <Dropdown
              placement="bottom"
              overlay={
                <Menu class="w-90px">
                  <Menu.Item>复制</Menu.Item>
                  <Menu.Item>分享</Menu.Item>
                  <Menu.Item>重命名</Menu.Item>
                  <Menu.Item>删除</Menu.Item>
                </Menu>
              }
            >
              <IconMore class="text-26px cursor-pointer" />
            </Dropdown>
          </div>
        </div>
      );
    };
  },
});

const itemStyles = css`
  .item_footer {
    background: #414141;
  }
  .icon_action {
    background-color: rgba(0, 0, 0, 0.5);
    &.orange {
      background-color: rgba(232, 139, 0, 0.5);
    }
  }
`;
