Skip to content

Commit

Permalink
Fix more fallback icon handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseleite committed Nov 13, 2023
1 parent d5e7254 commit b1c74c4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
30 changes: 27 additions & 3 deletions resources/js/components/fieldtypes/replicator/SetPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
<div class="p-1 max-h-[21rem] overflow-auto">
<div v-for="(item, i) in items" :key="item.handle" class="cursor-pointer rounded" :class="{ 'bg-gray-200': selectionIndex === i }" @mouseover="selectionIndex = i">
<div v-if="item.type === 'group'" @click="selectGroup(item.handle)" class="flex items-center group px-2 py-1.5 rounded-md">
<svg-icon :name="item.icon" :directory="iconDirectory" class="h-9 w-9 rounded bg-white border border-gray-600 mr-2 p-2 text-gray-800" />
<svg-icon :name="groupIconName(item.icon)" :directory="iconBaseDirectory" class="h-9 w-9 rounded bg-white border border-gray-600 mr-2 p-2 text-gray-800" />
<div class="flex-1">
<div class="text-md font-medium text-gray-800 truncate w-52">{{ __(item.display || item.handle) }}</div>
<div v-if="item.instructions" class="text-2xs text-gray-700 truncate w-52">{{ __(item.instructions) }}</div>
</div>
<svg-icon name="micro/chevron-right-thin" class="text-gray-600 group-hover:text-gray-800" />
</div>
<div v-if="item.type === 'set'" @click="addSet(item.handle)" class="flex items-center group px-2 py-1.5 rounded-md">
<svg-icon :name="item.icon" :directory="iconDirectory" class="h-9 w-9 rounded bg-white border border-gray-600 mr-2 p-2 text-gray-800" />
<svg-icon :name="setIconName(item.icon)" :directory="iconBaseDirectory" class="h-9 w-9 rounded bg-white border border-gray-600 mr-2 p-2 text-gray-800" />
<div class="flex-1">
<div class="text-md font-medium text-gray-800 truncate w-52">{{ __(item.display || item.handle) }}</div>
<div v-if="item.instructions" class="text-2xs text-gray-700 truncate w-52">{{ __(item.instructions) }}</div>
Expand Down Expand Up @@ -137,6 +137,14 @@ export default {
return this.search && this.visibleSets.length === 0;
},
iconBaseDirectory() {
return this.$config.get('setIconsDirectory');
},
iconSubFolder() {
return this.$config.get('setIconsFolder');
},
iconDirectory() {
let iconDirectory = this.$config.get('setIconsDirectory');
let iconFolder = this.$config.get('setIconsFolder');
Expand Down Expand Up @@ -228,7 +236,23 @@ export default {
if (! this.hasMultipleSets) {
this.addSet(this.sets[0].sets[0].handle);
}
}
},
groupIconName(name) {
if (! name) return 'folder-generic';
return this.iconSubFolder
? this.iconSubFolder+'/'+name
: name;
},
setIconName(name) {
if (! name) return 'light/add';
return this.iconSubFolder
? this.iconSubFolder+'/'+name
: name;
},
}
Expand Down
2 changes: 0 additions & 2 deletions src/Fieldtypes/Sets.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ public function preProcessConfig($sets)
return collect($sets)->map(function ($group, $groupHandle) {
return array_merge($group, [
'handle' => $groupHandle,
'icon' => $group['icon'] ?? 'regular/folder-generic',
'sets' => collect($group['sets'])
->map(function ($config, $name) {
return array_merge($config, [
'handle' => $name,
'id' => $name,
'fields' => (new NestedFields)->preProcessConfig(array_get($config, 'fields', [])),
'icon' => $config['icon'] ?? 'light/add',
]);
})
->values()
Expand Down

0 comments on commit b1c74c4

Please sign in to comment.