feat: Hide tooltip based on domain
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user