forked from Linho1219/function-plot-GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataList.vue
More file actions
116 lines (102 loc) · 2.45 KB
/
dataList.vue
File metadata and controls
116 lines (102 loc) · 2.45 KB
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
113
114
115
116
<template>
<s-scroll-view ref="scrollView" class="list-view">
<VueDraggable
v-model="profile.datum"
:animation="200"
handle=".datablock-drag"
>
<AnimatedList>
<AnimatedListItem
v-for="(item, i) in profile.datum"
:key="item.key"
class="datumFolder"
>
<DataItem :self="item" :index="i" />
</AnimatedListItem>
</AnimatedList>
</VueDraggable>
<button class="plot-data add-data" @click="addData">
<s-icon name="add" />
{{ t("editor.add") }}
<s-ripple attached></s-ripple>
</button>
</s-scroll-view>
</template>
<script setup lang="ts">
import { useI18n } from "vue-i18n";
import { I18nSchema } from "@/i18n";
const { t } = useI18n<{ message: I18nSchema }>();
import { VueDraggable } from "vue-draggable-plus";
import AnimatedList from "@/ui/animated/animatedList.vue";
import AnimatedListItem from "@/ui/animated/animatedListItem.vue";
import DataItem from "./data.vue";
import { useProfile } from "@/states";
const profile = useProfile();
import "./inputs/inputs.scss";
import { ref } from "vue";
const scrollView = ref<HTMLElementTagNameMap["s-scroll-view"] | null>(null);
function addData() {
profile.addData();
setTimeout(() => {
if (!scrollView.value) return;
const lastInput = (<HTMLInputElement[]>[
...scrollView.value.querySelectorAll(".function-input-real"),
]).at(-1);
if (!lastInput) return;
lastInput.focus();
console.log(lastInput);
}, 250);
}
</script>
<style lang="scss">
.datumFolder {
border-bottom: var(--s-color-outline-variant) 1px solid;
}
.list-view {
display: flex;
align-items: stretch;
flex-direction: column;
}
.plot-data.add-data {
position: relative;
padding-top: 15px;
padding-bottom: 15px;
margin-bottom: 50px;
display: flex;
align-items: center;
gap: 5px;
cursor: pointer;
border-radius: 0;
background: transparent;
border: none;
font-size: inherit;
color: inherit;
line-height: 1;
flex-shrink: 0;
transition: color 0.1s;
&::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: var(--s-color-primary);
opacity: 0;
transition: opacity 0.1s;
}
&:hover ::before {
opacity: 0 !important;
}
&:focus-visible {
outline: none;
color: var(--s-color-primary);
}
&:focus-visible::before {
opacity: 0.1;
}
s-icon {
color: inherit;
}
}
</style>