summaryrefslogtreecommitdiff
path: root/src/views/PowerSupplies/Specification/PowerSwitch.vue
blob: 824c25491bf7dca627ed75a031415ca3ca6f72cf (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<template>
  <div
    ref="content"
    class="memory-switch"
    @wheel.prevent="wheelItBetter($event)"
  >
    <span
      v-for="item in slots"
      :key="item.id"
      class="medium-12px scale-item"
      :class="{ 'switch-active': currentMemory === item.id }"
      @click="switchMemory(item.id)"
      >{{ $t(item.name) }}</span
    >
    <div
      class="slider"
      :style="`width: 68px; left: ${
        ((currentMemory ? currentMemory : 1) - 1) * 100 + 30
      }px`"
    />
  </div>
</template>

<script>
export default {
  props: {
    slots: {
      type: Array,
      default: null,
    },
    currentMemory: {
      type: Number,
      default: 1,
    },
    switchMemory: {
      type: Function,
      required: true,
    },
  },
  data() {
    return {
      upHere: false,
      container: this.$refs.content,
    };
  },
  methods: {
    wheelItBetter(event) {
      if (event.deltaY < 0) {
        this.$refs.content.scrollLeft -= 25;
      } else {
        this.$refs.content.scrollLeft += 25;
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.memory-switch {
  position: relative;
  width: calc(100vw - 320px);
  height: 50px;
  padding: 0 16px 0 32px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100px;
  grid-template-rows: 32px;
  align-items: end;
  border-bottom: 1px solid $faint-secondary-primary-10;
  overflow-x: auto;
  white-space: nowrap;
  &::-webkit-scrollbar {
    height: 2px;
  }
  &::-webkit-scrollbar-thumb {
    background: rgba(26, 62, 91, 0.2);
    border-radius: 16px;
    background-clip: content-box;
    height: 10px;
  }
}

.switch-active {
  color: $red-brand-primary;
  transition: ease-in 0.15s;
}

.slider {
  position: absolute;
  height: 0px;
  border-bottom: 4px solid $red-brand-primary;
  transition: ease-in 0.2s;
  bottom: 0px;
}

.scale-item {
  display: inline-block;
  width: 100px;
  margin-right: 6px;
  cursor: pointer;
}

.date-picker {
  display: flex;
  align-items: center;
  gap: 9px;
}

.date-clear {
  margin-left: auto;
  cursor: pointer;
}
</style>