import { css } from "@linaria/core";

import { defineComponent } from "vue";
import { useRouter } from "vue-router";
import { any, string } from "vue-types";

export default defineComponent({
  props: {
    data: any(),
    activeKey: string(),
  },
  setup(props) {
    const router = useRouter();
    return () => {
      return (
        <div class={page}>
          {props.data &&
            props.data.map((e: CategoryItem) => {
              return (
                <div
                  class={["tabs_item", e._id == props.activeKey ? "cur" : ""]}
                  key={e._id}
                  onClick={() => {
                    router.push(`/detail/${e._id}`);
                  }}
                >
                  {e.name}
                </div>
              );
            })}
        </div>
      );
    };
  },
});
const page = css`
  display: flex;
  justify-content: center;
  align-items: center;
  .tabs_item {
    position: relative;
    margin: 0 30px;
    height: 64px;
    line-height: 64px;
    font-size: 16px;
    font-weight: 400;
    color: #666666;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    &::after {
      content: "";
      position: absolute;
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
      width: 0;
      border-bottom: 2px solid var(--vt-c-primary);
      transition: width 0.2s ease-in-out;
    }
    &.cur {
      font-weight: 500;
      color: #333;
      &::after {
        width: 48px;
      }
    }
  }
`;
