<template>
  <div class="demo">
    <h2 class="h2">{{ translate('basic') }}</h2>
    <text
    class="iconfont icon-checked"
     style="font-size: 40rpx;color: #f0250f;" ></text>
     
     <text
     class="nutui-iconfont nut-icon nut-icon-JD"
     ></text>
     
    <nut-cell>
      <nut-icon name="dongdong"></nut-icon>
      <nut-icon name="JD"></nut-icon>
    </nut-cell>
    <h2 class="h2">{{ translate('imageLink') }}</h2>
    <nut-cell>
      <nut-icon
        size="40"
        name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
      >
      </nut-icon>
    </nut-cell>
    <h2 class="h2">{{ translate('iconColor') }}</h2>
    <nut-cell>
      <nut-icon name="dongdong" color="#fa2c19"></nut-icon>
      <nut-icon name="dongdong" color="#64b578"></nut-icon>
      <nut-icon name="JD" color="#fa2c19"></nut-icon>
    </nut-cell>

    <h2 class="h2">{{ translate('iconSize') }}</h2>
    <nut-cell>
      <nut-icon name="dongdong"></nut-icon>
      <nut-icon name="dongdong" size="24"></nut-icon>
      <nut-icon name="dongdong" size="26"></nut-icon>
    </nut-cell>

    <nut-cell-group v-for="item in icons.data" :title="currentLang == 'zh-CN' ? item.name : item.nameEn" :key="item">
        <nut-grid>
          <nut-grid-item 
          :key="item"
          v-for="item in item.icons"
          :icon="item" :text="item"></nut-grid-item>
        </nut-grid>
      <nut-cell>
      </nut-cell>
    </nut-cell-group>
    <nut-cell-group v-for="item in icons.style" :title="currentLang == 'zh-CN' ? item.name : item.nameEn" :key="item">
        <nut-grid>
          <nut-grid-item 
          :key="it"
          v-for="it in item.icons"
          :icon="it['animation-name']" :text="it['animation-name']"></nut-grid-item>
        </nut-grid>
    </nut-cell-group>
  </div>
</template>

<script lang="ts">
import { useTranslate, currentLang } from '../../../sites/assets/util/useTranslate';
const initTranslate = () =>
  useTranslate({
    'zh-CN': {
      basic: '基本用法',
      imageLink: '图片链接',
      iconColor: '图标颜色',
      iconSize: '图标大小'
    },
    'en-US': {
      basic: 'Basic Usage',
      imageLink: 'Image Link',
      iconColor: 'Icon Color',
      iconSize: 'Icon Size'
    }
  });
// import icons from '../../styles/font/iconfont.json';
import icons from '../../styles/font/config.json';
import { createComponent } from '../../utils/create';
const { createDemo, translate } = createComponent('icon');
export default createDemo({
  props: {},
  setup() {
    initTranslate();
    return { icons, translate, currentLang };
  }
});
</script>

<style lang="scss" scoped>
.nut-cell {
  > .nutui-iconfont {
    margin-right: 10px;
  }
}
ul {
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  width: 100%;
  li {
    flex: 0 0 25%;
    max-width: 25%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    span {
      height: 40px;
      font-size: 12px;
      text-align: center;
    }
    .nutui-iconfont {
      margin: 16px 0 16px;
    }
  }
}
</style>
