<template>
  <section class="kf-pub-button">
    <span class="kf-pub-copy-label" v-if="label !== '' ? true : false">
      {{label}}
    </span>
    <button class="kf-publish-btn" @click="doClick" :style="btnStyle">
      <span>{{ name }}</span>
    </button>
    <slot></slot>
  </section>
</template>

<script setup>
import { onMounted, reactive, toRefs ,defineEmits} from "vue";
let props = defineProps({
    label: {
        type: String,
        default: () => "",
    },
    name: {
        type: String,
        default: () => Kf.t('Button'),
    },
    bgColor: {
        type: String,
        default: () => "#2978ec",
    },
    width: {
        type: String,
        default: () => "49%",
    },
    cickHandle: {
        type: Function,
        default: () => {
            console.log("button 默认事件");
        },
    },
    disabled: {
        type: Boolean,
        default: () => false,
    },
});
const state = reactive({
  btnStyle: {
    "background-color": props.bgColor,
    width: props.width,
    cursor: props.disabled ? "not-allowed" : "",
  },
});
const { btnStyle } = toRefs(state);



const emits = defineEmits(["clickHandle"]);

const doClick = () => {
  emits("clickHandle");
};
</script>

<style lang="scss" scoped>
.kf-pub-button {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  position: relative;
  font-family: Alibaba PuHuiTi;

  .kf-pub-copy-label {
    color: #aaa;
    font-weight: 500;
    letter-spacing: 1.5px;
  }
}
</style>

<style lang="scss">
.kf-publish-btn {
    min-width: 80px;
    padding: 6px 10px;
    margin: 0;
    outline: none;
    border: none;
    color: #ddd;
    border-radius: 3px;
    font-size: 12px;
    background-color: rgba(41, 120, 236, 1);
    transition: all 0.5s;
    letter-spacing: 1px;
  }

  .kf-publish-btn:hover {
    color: #fff;
    cursor: pointer;
  }
</style>