Skip to content

Commit

Permalink
revert: remove banners relative code
Browse files Browse the repository at this point in the history
  • Loading branch information
Quorafind committed Sep 18, 2023
1 parent 8908ebb commit d55b277
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 885 deletions.
32 changes: 30 additions & 2 deletions src/components/UI/Picker/IconPicker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,48 @@
import { createEventDispatcher } from "svelte";
import { ICON_LIST } from "../../../IconList";
import Icon from "./IconRenderer.svelte";
import { prepareFuzzySearch } from "obsidian";
import type { SearchResult } from "obsidian";
let emojiRef;
const dispatch = createEventDispatcher();
const iconList = ICON_LIST;
let searchTerm: string = "";
let filteredIconList = [...ICON_LIST];
function select(icon: any) {
dispatch('iconSelect', icon.detail);
}
function search() {
if (searchTerm) {
const fuzzy = prepareFuzzySearch(searchTerm.toLowerCase());
filteredIconList = filteredIconList = ICON_LIST.filter(icon => {
const result: SearchResult | null = fuzzy(icon);
if (!result) {
return false;
}
if (result.score * -1 > 0.02) {
return false;
}
return true;
});
} else {
filteredIconList = filteredIconList = [...ICON_LIST];
}
}
</script>

<div class="file-property-enhancer-icon-picker">
<div class="icon-picker-search-container">
<input class="icon-picker-search" type="search" bind:value={searchTerm} on:input={search}
placeholder="Search for an icon..."/>
<span class="icon loupe flex"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path
d="M12.9 14.32a8 8 0 1 1 1.41-1.41l5.35 5.33-1.42 1.42-5.33-5.34zM8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12z"></path></svg></span>
</div>
<div class="file-property-enhancer-icon-picker-container">
{#each iconList as icon, idx}
{#each filteredIconList as icon, idx}
<Icon idx={idx} iconName={icon} on:iconClick={select}/>
{/each}
</div>
Expand Down
18 changes: 15 additions & 3 deletions src/components/UI/Picker/IconRenderer.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<script lang="ts">
import { createEventDispatcher, onMount } from "svelte";
import { setIcon } from "obsidian";
import { afterUpdate, createEventDispatcher, onMount } from "svelte";
import { setIcon, setTooltip } from "obsidian";
export let iconName: string;
export let idx: number;
let iconRef: HTMLSpanElement;
const dispatch = createEventDispatcher();
let prevIconName: string;
onMount(() => {
setIcon(iconRef, iconName);
})
setTooltip(iconRef, iconName);
prevIconName = iconName;
});
afterUpdate(() => {
if (prevIconName !== iconName) {
setIcon(iconRef, iconName);
setTooltip(iconRef, iconName);
prevIconName = iconName;
}
});
function handleClick() {
iconClick({
Expand Down
43 changes: 0 additions & 43 deletions src/styles/_spinner.scss

This file was deleted.

Loading

0 comments on commit d55b277

Please sign in to comment.