Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maybe-controversial ui improvements #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export class SiliconView extends ItemView {
this.update(this.embeds)
}

async update(embeds: { path: string, similarity: number }[]) {
async update(rawEmbeds: { path: string, similarity: number }[]) {
const embeds = rawEmbeds.filter(embed => !isNaN(embed.similarity));

// console.log("Updating view")
// THis is called when the view is opened, or when the user switches to another file
// We want to search again, and update the view
Expand All @@ -47,17 +49,16 @@ export class SiliconView extends ItemView {
return;
}
// Create a link for each path
outerDiv.createEl("div", { cls: "outgoing-link-header", text: "⛰" });
outerDiv.createEl("br")
const resultsDiv = outerDiv.createEl("div", { cls: "search-result-container" });
// get the top value
const topValue = embeds[0].similarity;
for (const embed of embeds) {
const [path, similarity] = [embed.path, embed.similarity];

const opacity = sCurve(similarity, this.threshold, topValue);
const link = resultsDiv.createEl("a", { href: path, cls: "tree-item-self is-clickable outgoing-link-item", attr: { "data-path": path } });
link.createEl("span", {
text: path.split("/").pop()?.split(".md")[0],
text: path.split("/").pop()?.split(".md")[0] + " (" + similarity.toPrecision(2) + ")",
cls: "tree-item-inner",
// show similarity in hover tooltip
attr: { title: `Similarity: ${similarity.toPrecision(2)}, Opacity: ${opacity.toPrecision(2)}`, style: `opacity: ${opacity}` }
Expand Down Expand Up @@ -91,4 +92,4 @@ function sCurve(x: number, bottomThreshold: number, topThreshold: number =0.95)
const b = -a * bottomThreshold;
const y = a * x + b;
return 0.4 + 0.6 * y;
}
}
12 changes: 12 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,15 @@ available in the app when your plugin is enabled.
If your plugin does not need CSS, delete this file.

*/

.outgoing-link-pane {
padding: 0;
}

.tree-item-self {
text-decoration: none;
}

.tree-item-self:hover {
text-decoration: none;
}