sprintify-ui 0.0.148 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.0.148",
3
+ "version": "0.0.149",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -9,7 +9,7 @@ export default {
9
9
  const Template = (args) => ({
10
10
  components: { BaseIconPicker, ShowValue },
11
11
  setup() {
12
- const value = ref(null);
12
+ const value = ref('heroicons:user-group-solid');
13
13
  return { args, value };
14
14
  },
15
15
  template: `
@@ -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, config } from '..';
44
+ import { BaseIcon } from '..';
45
45
 
46
46
  const props = withDefaults(
47
47
  defineProps<{
@@ -117,17 +117,64 @@ function fetchIcons() {
117
117
  fetch('https://api.iconify.design/collection?prefix=' + props.collection)
118
118
  .then((response) => response.json())
119
119
  .then((data) => {
120
+ // Set icons
120
121
  icons.value = data.uncategorized;
122
+
123
+ // Set suffix list
121
124
  suffixes.value = data.suffixes;
122
- suffix.value = Object.keys(suffixes.value)[0] as string;
125
+
126
+ // Set suffix
127
+ selectCurrentSuffix();
128
+
129
+ // Scroll to icon
130
+
131
+ nextTick(() => {
132
+ scrollToIcon();
133
+ });
123
134
  });
124
135
  }
125
136
 
126
- fetchIcons();
137
+ function selectCurrentSuffix() {
138
+ if (!props.modelValue) {
139
+ return;
140
+ }
127
141
 
128
- function scrollTop() {
129
- if (drawer.value) {
130
- drawer.value.scrollTop = 0;
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>