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

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

export default defineComponent({
  props: {
    data: any(),
    activeKey: string(),
  },
  setup(props, { emit }) {
    const router = useRouter();
    const route = useRoute();
    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({ path: route.path, query: { cid: e._id } });
                  }}
                >
                  {e.name}
                </div>
              );
            })}
        </div>
      );
    };
  },
});
const page = css`
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fff;
  margin-bottom: 50px;
  .tabs_item {
    position: relative;
    margin: 0 30px;
    height: 46px;
    line-height: 46px;
    font-size: 14px;
    font-weight: 400;
    color: #666666;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    &.cur {
      font-weight: 600;
      color: #333;
    }
  }
`;
