ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<script lang="ts" setup>
import { computed, unref } from 'vue';
 
import { useAttrs } from '@jnpf/hooks';
 
import { DownOutlined } from '@ant-design/icons-vue';
 
defineOptions({ name: 'BasicArrow' });
 
const props = defineProps({
  /**
   * Arrow down by default
   */
  down: { type: Boolean },
  /**
   * Arrow expand state
   */
  expand: { type: Boolean },
  /**
   * Cancel padding/margin for inline
   */
  inset: { type: Boolean },
  /**
   * Arrow up by default
   */
  up: { type: Boolean },
});
const attrs: any = useAttrs({ excludeDefaultKeys: false });
 
// get component class
const getClass = computed(() => {
  const { down, expand, inset, up } = props;
  return [
    'jnpf-basic-arrow',
    {
      [`jnpf-basic-arrow--active`]: expand,
      down,
      inset,
      up,
    },
  ];
});
const getStyle = computed(() => unref(attrs)?.iconStyle || {});
</script>
<template>
  <span :class="getClass">
    <DownOutlined :style="getStyle" />
  </span>
</template>
<style lang="scss" scoped>
.jnpf-basic-arrow {
  display: inline-block;
  cursor: pointer;
  transform: rotate(0deg);
  transform-origin: center center;
  transition: all 0.3s ease 0.1s;
 
  &.jnpf-basic-arrow--active {
    transform: rotate(0deg);
 
    &.up {
      transform: rotate(0deg);
    }
 
    &.down {
      transform: rotate(-180deg);
    }
  }
 
  &.inset {
    line-height: 0px;
  }
 
  &.up {
    transform: rotate(-180deg);
  }
 
  &.down {
    transform: rotate(0deg);
  }
}
</style>