sprintify-ui 0.0.147 → 0.0.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sprintify-ui.es.js +2887 -2867
- package/package.json +1 -1
- package/src/components/BaseIconPicker.stories.js +1 -1
- package/src/components/BaseIconPicker.vue +59 -12
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<select
|
|
5
5
|
v-model="suffix"
|
|
6
6
|
class="max-w-[80px] shrink-0 rounded-l border-r-0 border-slate-300 text-xs focus:border-slate-300 focus:outline-none focus:ring-0"
|
|
7
|
-
@change="scrollTop"
|
|
8
7
|
>
|
|
9
8
|
<option v-for="(label, key) in suffixes" :key="key" :value="key">
|
|
10
9
|
{{ label }}
|
|
@@ -24,6 +23,7 @@
|
|
|
24
23
|
<li v-for="icon in filteredIcons" :key="icon">
|
|
25
24
|
<button
|
|
26
25
|
type="button"
|
|
26
|
+
:data-icon="icon"
|
|
27
27
|
:class="[
|
|
28
28
|
modelValue == icon
|
|
29
29
|
? 'bg-primary-600 text-white'
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
</template>
|
|
42
42
|
|
|
43
43
|
<script lang="ts" setup>
|
|
44
|
-
import { BaseIcon
|
|
44
|
+
import { BaseIcon } from '..';
|
|
45
45
|
|
|
46
46
|
const props = withDefaults(
|
|
47
47
|
defineProps<{
|
|
@@ -114,20 +114,67 @@ const filteredIcons = computed(() => {
|
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
function fetchIcons() {
|
|
117
|
-
|
|
118
|
-
.
|
|
119
|
-
.then((
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
fetch('https://api.iconify.design/collection?prefix=' + props.collection)
|
|
118
|
+
.then((response) => response.json())
|
|
119
|
+
.then((data) => {
|
|
120
|
+
// Set icons
|
|
121
|
+
icons.value = data.uncategorized;
|
|
122
|
+
|
|
123
|
+
// Set suffix list
|
|
124
|
+
suffixes.value = data.suffixes;
|
|
125
|
+
|
|
126
|
+
// Set suffix
|
|
127
|
+
selectCurrentSuffix();
|
|
128
|
+
|
|
129
|
+
// Scroll to icon
|
|
130
|
+
|
|
131
|
+
nextTick(() => {
|
|
132
|
+
scrollToIcon();
|
|
133
|
+
});
|
|
123
134
|
});
|
|
124
135
|
}
|
|
125
136
|
|
|
126
|
-
|
|
137
|
+
function selectCurrentSuffix() {
|
|
138
|
+
if (!props.modelValue) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
127
141
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
142
|
+
const suffixesOrderedByLength = Object.keys(suffixes.value).sort((a, b) => {
|
|
143
|
+
return b.length - a.length;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
for (let i = 0; i < suffixesOrderedByLength.length; i++) {
|
|
147
|
+
const s = suffixesOrderedByLength[i];
|
|
148
|
+
|
|
149
|
+
if (props.modelValue.endsWith(s)) {
|
|
150
|
+
suffix.value = s;
|
|
151
|
+
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
131
154
|
}
|
|
132
155
|
}
|
|
156
|
+
|
|
157
|
+
function scrollToIcon() {
|
|
158
|
+
if (!drawer.value) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (!props.modelValue) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const icon = drawer.value.querySelector(
|
|
167
|
+
'button[data-icon="' + props.modelValue + '"]'
|
|
168
|
+
) as HTMLElement | null;
|
|
169
|
+
|
|
170
|
+
if (!icon) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
drawer.value.scrollTop = icon.offsetTop - 10;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
onMounted(() => {
|
|
178
|
+
fetchIcons();
|
|
179
|
+
});
|
|
133
180
|
</script>
|