on main help sign in
redefine X button behavior in sigil input tool
commitf385d34a125d1e4a82b28d617c1edab6b1c1851e authorJohn Hyde <johnhydefour@gmail.com> dateTue 4 Oct 2022, 11:30 (4 years ago) parent1014ab6
4 files changed+21−7
desk/doc/usr/astrolabe.udon+2−1 ui/src/components/search/sigil/SymbolInputModeSelector.svelte+6−3 ui/src/components/search/sigil/SymbolInputNavButtons.svelte+8−3 ui/src/lib/sigil.ts+5
desk/doc/usr/astrolabe.udon+2−1
@@ -36,7 +36,8 @@ Select component catogeries on the right, and then tap the options on the sigil
3636to add them to your search.
3737
3838The ^ button goes up a level so you can select another category.
39−The X button will clear sigil components based on what type you're inputting.
39+The X button will clear sigil components from the current symbol,
40+except the basic shape. If only the basic shape remains, the X button will clear that.
4041At the top level, the X button will clear all inputs.
4142
4243Your contacts will be searched for any search.
ui/src/components/search/sigil/SymbolInputModeSelector.svelte+6−3
@@ -98,10 +98,13 @@
9898 }
9999
100100 function clear() {
101− if (modes.length) {
102− symbolQuery = symbolQuery.clearPartType(modes[0] as PartType);
103− } else {
101+ // If a geon is present it should be preserved, unless it's the only component
102+ // If there's only 1 component, it should be removed
103+ // Otherwise, at least one component might be a geon and should be preserved
104+ if (symbolQuery.components.length === 1) {
104105 symbolQuery = symbolQuery.clear();
106+ } else {
107+ symbolQuery = symbolQuery.clearExceptPartType('geon');
105108 }
106109 }
107110</script>
ui/src/components/search/sigil/SymbolInputNavButtons.svelte+8−3
@@ -4,6 +4,11 @@
44
55 export let onDone: () => void = null;
66 export let onClear: () => void = null;
7+ export let hideDoneButton = false;
8+ export let hideClearButton = false;
9+
10+ $: showDoneButton = (onDone && !hideDoneButton);
11+ $: showClearButton = (onClear && !hideClearButton);
712
813 let buttonClasses = 'cursor-pointer border border-gray-500 rounded-md aspect-square w-[48px]';
914</script>
@@ -14,11 +19,11 @@
1419 }
1520</style>
1621
17−<div class="grid gap-1 self-start justify-center mr-1 xs:mr-0 xs:mb-1 xs:self-stretch {(onDone && onClear) ? 'grid-cols-custom' : ''}">
18− {#if onDone}
22+<div class="grid gap-1 self-start justify-center mr-1 xs:mr-0 xs:mb-1 xs:self-stretch {(showDoneButton && showClearButton) ? 'grid-cols-custom' : ''}">
23+ {#if showDoneButton}
1924 <img src={upArrow} alt="done" class={buttonClasses} on:click={onDone}/>
2025 {/if}
21− {#if onClear}
26+ {#if showClearButton}
2227 <img src={xIcon} alt="clear" class={buttonClasses} on:click={onClear}/>
2328 {/if}
2429 </div>
ui/src/lib/sigil.ts+5
@@ -343,6 +343,11 @@ export class SymbolQuery {
343343 return this;
344344 }
345345
346+ clearExceptPartType(partType: PartType) {
347+ this.components = this.components.filter(c => c[0] === partType[0]);
348+ return this;
349+ }
350+
346351 clear() {
347352 this.components = [];
348353 return this;