<template>
  <div class="demo full">
    <h4>基本用法</h4>
    <div>
      <nut-cell>
        <nut-progress percentage="30" />
      </nut-cell>
    </div>

    <p>线形进度条-设置颜色高度</p>
    <div>
      <nut-cell>
        <nut-progress
          percentage="30"
          stroke-color=" rgba(250,44,25,0.47)"
          stroke-width="20"
          text-color="red"
        />
      </nut-cell>
    </div>
    <p>线形进度条-百分比不显示</p>
    <div>
      <nut-cell>
        <nut-progress percentage="50" :show-text="false" stroke-height="24" />
      </nut-cell>
    </div>
    <p>线形进度条-百分比外显</p>
    <div>
      <nut-cell>
        <nut-progress percentage="30" />
      </nut-cell>
    </div>
    <p>线形进度条-百分比内显</p>
    <div>
      <nut-cell>
        <nut-progress percentage="60" :text-inside="true" />
      </nut-cell>
    </div>
    <p>线形进度条-自定义尺寸(内置"small","base","large"三种规格)</p>
    <div>
      <nut-cell>
        <nut-progress percentage="30" :text-inside="true" size="small">
        </nut-progress>
      </nut-cell>
      <nut-cell>
        <nut-progress percentage="50" :text-inside="true" size="base">
        </nut-progress>
      </nut-cell>
      <nut-cell>
        <nut-progress percentage="70" :text-inside="true" size="large">
        </nut-progress>
      </nut-cell>
    </div>
    <p>线形进度条-状态显示</p>
    <div>
      <nut-cell>
        <nut-progress
          percentage="30"
          stroke-color="linear-gradient(270deg, rgba(18,126,255,1) 0%,rgba(32,147,255,1) 32.815625%,rgba(13,242,204,1) 100%)"
          status="active"
        />
      </nut-cell>
      <nut-cell>
        <nut-progress
          percentage="50"
          :stroke-width="strokeWidth"
          status="icon"
        />
      </nut-cell>
      <nut-cell>
        <nut-progress
          percentage="100"
          stroke-color="linear-gradient(90deg, rgba(180,236,81,1) 0%,rgba(66,147,33,1) 100%)"
          stroke-width="15"
          status="icon"
          icon-name="issue"
          icon-color="red"
        />
      </nut-cell>
    </div>
    <h4>设置百分比</h4>
    <div>
      <nut-cell>
        <nut-progress :percentage="val" />
      </nut-cell>
      <nut-cell>
        <nut-button type="default" @click="setReduceVal">减少</nut-button>
        <nut-button type="danger" @click="setAddVal">增加</nut-button>
      </nut-cell>
    </div>
  </div>
</template>

<script lang="ts">
import { ref } from 'vue';
import { createComponent } from '../../utils/create';
const { createDemo } = createComponent('progress');
export default createDemo({
  props: {},
  setup() {
    const val = ref(0);
    const setAddVal = () => {
      if (val.value >= 100) {
        return false;
      }
      val.value += 10;
    };
    const setReduceVal = () => {
      if (val.value <= 0) {
        return false;
      }
      val.value -= 10;
    };
    return {
      val,
      setAddVal,
      setReduceVal
    };
  }
});
</script>

<style lang="scss" scoped>
.nut-button {
  margin-right: 10px;
}
</style>
