-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
773 additions
and
341 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 26 additions & 10 deletions
36
...uttons/QueryInfoButtonComponent.wc.svelte → ...nts/buttons/InfoButtonComponent.wc.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,58 @@ | ||
<svelte:options | ||
customElement={{ | ||
tag: "lens-info-button", | ||
props: {}, | ||
props: { | ||
showQuery: {type: "Boolean"}, | ||
}, | ||
}} | ||
/> | ||
|
||
<script lang="ts"> | ||
import { iconStore } from "../../stores/icons"; | ||
import { getHumanReadableQuery } from "../../stores/negotiate"; | ||
export let message: string = ""; | ||
export let noQueryMessage: string = "Search for all results"; | ||
export let iconUrl: string | null = null; | ||
$: query = ""; | ||
export let showQuery: boolean = false; | ||
export let infoIconUrl: string | null = null; | ||
iconStore.update((store) => { | ||
if (infoIconUrl){ | ||
store.set("info", infoIconUrl); | ||
} | ||
return store; | ||
}); | ||
$: iconUrl = $iconStore.get("info"); | ||
/** | ||
* handles the toggling of the tooltip | ||
*/ | ||
let tooltipOpen: boolean = false; | ||
const onFocusOut = () => { | ||
tooltipOpen = false; | ||
}; | ||
const displayQueryInfo = () => { | ||
query = getHumanReadableQuery(); | ||
if(showQuery){ | ||
message = getHumanReadableQuery().length > 0 ? getHumanReadableQuery() : noQueryMessage; | ||
} | ||
tooltipOpen = !tooltipOpen; | ||
}; | ||
const onFocusOut = () => { | ||
displayQueryInfo(); | ||
tooltipOpen = false; | ||
}; | ||
</script> | ||
|
||
<button part="info-button" on:click={displayQueryInfo} on:focusout={onFocusOut}> | ||
{#if iconUrl} | ||
<img part="info-button-icon" src={iconUrl} alt="info icon" /> | ||
{:else} | ||
<span part="info-button-icon"> | ||
ⓘ | ||
</span> | ||
{/if} | ||
{#if tooltipOpen} | ||
<div part="info-button-dialogue"> | ||
{query.length > 0 ? query : noQueryMessage} | ||
{message} | ||
</div> | ||
{/if} | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.