Skip to content

Commit

Permalink
Display aliases on Explore page (#177)
Browse files Browse the repository at this point in the history
* Display aliases on Explore page

* lint

* typeset aliases

* add property aliases to formula suggestions

* only sort by ID when no text filter is given

* only search names/aliases, decrease threshold

* lint 🧹
  • Loading branch information
StevenClontz authored Nov 1, 2024
1 parent 743812b commit 49fd2f9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/viewer/src/components/Search/Results/Found.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
export let text: string | undefined
export let formula: F.Formula<Property> | undefined
export let results: Space[]
let sortedResults: Space[]
$: if (text !== undefined && text.length > 0) {
sortedResults = results
} else {
sortedResults = results.sort((a, b) => a.id - b.id)
}
</script>

{results.length} spaces
Expand All @@ -18,6 +24,6 @@
{/if}

<Table
spaces={results.sort((a, b) => a.id - b.id)}
spaces={sortedResults}
properties={formula ? [...F.properties(formula)] : []}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
on:keydown={() => onClick(i)}
>
<Typeset body={property.name} />
{#if property.aliases.length > 0}
<br />
<small class={i === selected ? 'active' : 'text-muted'}>
{#each property.aliases as alias, i}
{#if i > 0},{' '}{/if}
<Typeset body={alias} />
{/each}
</small>
{/if}
</div>
</li>
{/each}
Expand Down
13 changes: 12 additions & 1 deletion packages/viewer/src/components/Traits/Table.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { Link } from '../Shared'
import Value from './Value.svelte'
import Typeset from '../Shared/Typeset.svelte'
export let properties: Property[]
export let spaces: Space[]
Expand All @@ -30,7 +31,17 @@
<Link.Space {space}>S{space.id}</Link.Space>
</td>
<td>
<Link.Space {space} />
<div><Link.Space {space} /></div>
{#if space.aliases.length > 0}
<div>
<small class="text-muted">
{#each space.aliases as alias, i}
{#if i > 0}, {/if}
<Typeset body={alias} />
{/each}
</small>
</div>
{/if}
</td>
{#each properties as property (property.id)}
<td>
Expand Down
2 changes: 1 addition & 1 deletion packages/viewer/src/stores/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export default function create({
keys: [
{ name: 'name', weight: 0.7 },
{ name: 'aliases', weight: 0.7 },
{ name: 'description', weight: 0.3 },
],
threshold: 0.3,
}),
)

Expand Down

0 comments on commit 49fd2f9

Please sign in to comment.