Blame view

src/components/color-picker/color-picker.vue 2.8 KB
c6faec44   梁灏   init ColorPicker
1
  <template>
b6bda1dc   梁灏   update ColorPicker
2
3
4
5
6
7
8
9
10
11
12
13
14
15
      <Dropdown trigger="click" :transfer="transfer" :placement="placement">
          <div :class="wrapClasses">
              <i class="ivu-icon ivu-icon-arrow-down-b ivu-input-icon ivu-input-icon-normal"></i>
              <div :class="inputClasses">
                  <div :class="[prefixCls + '-color']" style="background-color: rgb(32, 160, 255);"></div>
              </div>
          </div>
          <Dropdown-menu slot="list">
              <p>常用于各种自定义下拉内容的场景。</p>
              <div style="text-align: right;margin:10px;">
                  <Button type="primary">关闭</Button>
              </div>
          </Dropdown-menu>
      </Dropdown>
c6faec44   梁灏   init ColorPicker
16
17
  </template>
  <script>
b6bda1dc   梁灏   update ColorPicker
18
19
20
21
22
23
24
      import Dropdown from '../dropdown/dropdown.vue';
      import DropdownMenu from '../dropdown/dropdown-menu.vue';
      import { oneOf } from '../../utils/assist';
  
      const prefixCls = 'ivu-color-picker';
      const inputPrefixCls = 'ivu-input';
  
c6faec44   梁灏   init ColorPicker
25
      export default {
b6bda1dc   梁灏   update ColorPicker
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
          name: 'ColorPicker',
          components: { Dropdown, DropdownMenu },
          props: {
              value: {
                  type: String
              },
              alpha: {
                  type: Boolean,
                  default: false
              },
              format: {
                  validator (value) {
                      return oneOf(value, ['hsl', 'hsv', 'hex', 'rgb']);
                  }
              },
              disabled: {
                  type: Boolean,
                  default: false
              },
              size: {
                  validator (value) {
                      return oneOf(value, ['small', 'large', 'default']);
                  }
              },
              placement: {
                  validator (value) {
                      return oneOf(value, ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end']);
                  },
                  default: 'bottom'
              },
              transfer: {
                  type: Boolean,
                  default: false
              }
          },
c6faec44   梁灏   init ColorPicker
61
          data () {
b6bda1dc   梁灏   update ColorPicker
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
              return {
                  prefixCls: prefixCls,
                  currentValue: this.value
              };
          },
          computed: {
              wrapClasses () {
                  return [
                      `${prefixCls}-rel`,
                      `${inputPrefixCls}-wrapper`,
                      `${inputPrefixCls}-wrapper-${this.size}`
                  ];
              },
              inputClasses () {
                  return [
                      `${prefixCls}-input`,
                      `${inputPrefixCls}`,
                      `${inputPrefixCls}-${this.size}`,
                      {
                          [`${inputPrefixCls}-disabled`]: this.disabled
                      }
                  ];
              }
c6faec44   梁灏   init ColorPicker
85
          },
b6bda1dc   梁灏   update ColorPicker
86
87
88
          methods: {
  
          }
c6faec44   梁灏   init ColorPicker
89
90
      };
  </script>