feat: Hide tooltip based on domain

This commit is contained in:
Sidharth Vinod
2026-01-28 11:52:30 +05:30
parent 7f551dbbe6
commit 9946dff29d
3 changed files with 35 additions and 24 deletions
+24 -20
View File
@@ -11,7 +11,8 @@
side = 'bottom',
labelPrefix = 'Opens your diagram in',
isVisible = true,
sharesData = true
sharesData = true,
showPopup = true
}: {
children: Snippet;
domain: string;
@@ -20,6 +21,7 @@
labelPrefix?: string;
isVisible?: boolean;
sharesData?: boolean;
showPopup?: boolean;
} = $props();
let shouldDisableComponent = $derived(
@@ -35,25 +37,27 @@
{@render children()}
</div>
</Tooltip.Trigger>
<Tooltip.Content {side} class="bg-secondary shadow-xl">
<div
class="flex cursor-help items-center gap-2"
title={sharesData
? 'Your diagram will be sent to the external service'
: 'Your diagram is not shared'}>
{#if shouldDisableComponent}
<div class="text-muted-foreground">
This diagram type is not supported in {domain}
</div>
{:else}
<ExternalLinkIcon />
<span class="flex items-center gap-1">
{labelPrefix}
<div class="text-accent">{domain}</div>
</span>
{/if}
</div>
</Tooltip.Content>
{#if showPopup}
<Tooltip.Content {side} class="bg-secondary shadow-xl">
<div
class="flex cursor-help items-center gap-2"
title={sharesData
? 'Your diagram will be sent to the external service'
: 'Your diagram is not shared'}>
{#if shouldDisableComponent}
<div class="text-muted-foreground">
This diagram type is not supported in {domain}
</div>
{:else}
<ExternalLinkIcon />
<span class="flex items-center gap-1">
{labelPrefix}
<div class="text-accent">{domain}</div>
</span>
{/if}
</div>
</Tooltip.Content>
{/if}
</Tooltip.Root>
</Tooltip.Provider>
{/if}
+10 -3
View File
@@ -6,12 +6,19 @@
let {
children,
...props
}: Omit<ComponentProps<typeof ExternalLinkWrapper>, 'isVisible' | 'domain'> = $props();
}: Omit<
ComponentProps<typeof ExternalLinkWrapper>,
'isVisible' | 'domain' | 'showPopup'
> = $props();
const mermaidChartDomain = 'mermaid.ai';
const isMermaidAiDomain = env.domain === mermaidChartDomain;
</script>
<ExternalLinkWrapper
{...props}
domain="MermaidChart.com"
isVisible={env.isEnabledMermaidChartLinks}>
domain={mermaidChartDomain}
isVisible={env.isEnabledMermaidChartLinks}
showPopup={!isMermaidAiDomain}>
{@render children()}
</ExternalLinkWrapper>
+1 -1
View File
@@ -35,7 +35,7 @@ export const initHandler = async (): Promise<void> => {
export const isMac = navigator.platform.toUpperCase().includes('MAC');
export const cmdKey = isMac ? 'Cmd' : 'Ctrl';
export const MCBaseURL = env.isEnabledMermaidChartLinks
? 'https://mermaidchart.com' // 'http://localhost:5174'
? 'https://mermaid.ai' // 'http://localhost:5174'
: 'https://example.com';
let count = 0;