<template>
  <div class="component-wrapper">
    <hgroup class="component-hgroup">
      <h1 class="component-title">Previewer (图片预览器)</h1>
      <h2 class="component-subtitle">图片预览器非常常见</h2>
      <h3 class="component-notice">交互能力强</h3>
    </hgroup>

    <section class="component-item">
      <hgroup class="component-item-hgroup">
        <h1 class="component-item-title">代码示例</h1>
      </hgroup>

      <sv-example>
        <h2 slot="title">基本用法</h2>
        <h2 slot="subtitle">最简单定义一个九宫格的用法</h2>
        <template slot="preview">
          <sv-button @click="visible = true">图片预览</sv-button>
         <sv-previewer :data="images" v-model="visible"></sv-previewer>
        </template>
        <template slot="code">
          <sv-code>
            <sv-code-item code='<sv-grid>'></sv-code-item>
            <sv-code-item code='<sv-grid-cell>昨天</sv-grid-cell>' :level="2"></sv-code-item>
            <sv-code-item code='<sv-grid-cell>今天</sv-grid-cell>' :level="2"></sv-code-item>
            <sv-code-item code='<sv-grid-cell>明天</sv-grid-cell>' :level="2"></sv-code-item>
            <sv-code-item code='<sv-grid-cell>后天</sv-grid-cell>' :level="2"></sv-code-item>
            <sv-code-item code='</sv-grid>'></sv-code-item>
          </sv-code>
        </template>
      </sv-example>

    </section>

    <section class="component-item api">
      <hgroup class="component-item-hgroup">
        <h1 class="component-item-title">API</h1>
      </hgroup>

      <div class="component-item-content">
        <div class="component-item-content-header">
          <h1 class="component-item-content-title">Grid</h1>
          <h1 class="component-item-content-subtitle"></h1>
        </div>
        <div class="component-item-content-main api">
          <sv-tabs stripe position="top">
            <sv-tab :value="0" title="Props">
              <sv-table :data="apiData.grid.props">
                <sv-table-column prop="name" title="名称" width="100"></sv-table-column>
                <sv-table-column prop="description" title="描述" width="200"></sv-table-column>
                <sv-table-column prop="type" title="类型"></sv-table-column>
                <sv-table-column prop="optional" title="可选值"></sv-table-column>
                <sv-table-column prop="default" title="默认值"></sv-table-column>
              </sv-table>
            </sv-tab>
            <sv-tab :value="1" title="Slots">
              <sv-table :data="apiData.grid.slots">
                <sv-table-column prop="name" title="名称"></sv-table-column>
                <sv-table-column prop="description" title="描述"></sv-table-column>
              </sv-table>
            </sv-tab>
            <sv-tab :value="2" title="Events">
              <sv-table :data="apiData.grid.events">
                <sv-table-column prop="name" title="事件名称" width="100"></sv-table-column>
                <sv-table-column prop="description" title="描述" width="200"></sv-table-column>
                <sv-table-column prop="param" title="回调参数" width="300"></sv-table-column>
              </sv-table>
            </sv-tab>
          </sv-tabs>
        </div>
      </div>
    </section>
  </div>
</template>

<script type="text/ecmascript-6">
  import image1 from '../images/previewer/image1.jpg'
  import image2 from '../images/previewer/image2.jpg'
  import image3 from '../images/previewer/image3.jpg'
  import image4 from '../images/previewer/image4.jpg'
  import Code from '../components/Code.vue'
  import CodeItem from '../components/CodeItem.vue'
  export default {
    components: {
      svCode: Code,
      svCodeItem: CodeItem
    },
    data () {
      return {
        visible: false,
        images: [image1, image2, image3, image4],
        apiData: {
          grid: {
            props: [
              {
                name: 'cols',
                description: '每行单元格数量，即列数',
                type: 'number',
                optional: '-',
                default: '3'
              },
              {
                name: 'has-border',
                description: '是否有边框',
                type: 'Boolean',
                optional: 'true,false',
                default: 'true'
              }
            ],
            slots: [
//              {
//                name: 'time',
//                description: '时间'
//              }
            ],
            events: [
//              {
//                name: 'click',
//                description: '点击按钮时的回调，回调参数为当前被点击按钮的索引'
//              }
            ]
          },
          gridCell: {
            props: [
              {
                name: 'icon',
                description: '方格中显示的Icon，取值为Icon组件的值',
                type: 'string',
                optional: '-',
                default: '-'
              }
            ],
            slots: [
              {
                name: 'icon',
                description: '方格中的icon，常使用Icon组件'
              }
            ],
            events: []
          },
        }
      }
    },
    methods: {
      handleTap () {
        console.log('双击')
      }
    }
  }
</script>

<style lang="scss" rel="stylesheet/scss">
  @import "../../src/styles/base";
  @import "../styles/components";
</style>
