summaryrefslogtreecommitdiff
path: root/src/components/jet/action/ExternalUrlAction.svelte
diff options
context:
space:
mode:
authorrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
committerrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
commitbce557cc2dc767628bed6aac87301a1be7c5431b (patch)
treeb51a051228d01fe3306cd7626d4a96768aadb944 /src/components/jet/action/ExternalUrlAction.svelte
init commit
Diffstat (limited to 'src/components/jet/action/ExternalUrlAction.svelte')
-rw-r--r--src/components/jet/action/ExternalUrlAction.svelte52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/components/jet/action/ExternalUrlAction.svelte b/src/components/jet/action/ExternalUrlAction.svelte
new file mode 100644
index 0000000..e8a2ad6
--- /dev/null
+++ b/src/components/jet/action/ExternalUrlAction.svelte
@@ -0,0 +1,52 @@
+<script lang="ts">
+ import type { HTMLAnchorAttributes } from 'svelte/elements';
+ import type { ExternalUrlAction } from '@jet-app/app-store/api/models';
+ import ArrowIcon from '@amp/web-app-components/assets/icons/arrow.svg';
+ import { getJetPerform } from '~/jet';
+
+ type AllowedAnchorAttributes = Omit<
+ HTMLAnchorAttributes,
+ // The `href` attribute is not allowed because it will be provided
+ // by the `ExternalUrlAction`
+ 'href'
+ >;
+
+ interface $$Props extends AllowedAnchorAttributes {
+ destination: ExternalUrlAction;
+ includeArrowIcon?: boolean;
+ }
+
+ const perform = getJetPerform();
+
+ export let destination: ExternalUrlAction;
+ export let includeArrowIcon: boolean = true;
+
+ function handleClickAction() {
+ perform(destination);
+ }
+</script>
+
+<a
+ {...$$restProps}
+ data-test-id="external-link"
+ href={destination.url}
+ target="_blank"
+ rel="nofollow noopener noreferrer"
+ on:click={handleClickAction}
+>
+ <slot />
+ {#if includeArrowIcon}
+ <ArrowIcon class="external-link-arrow" aria-hidden="true" />
+ {/if}
+</a>
+
+<style lang="scss">
+ @use '@amp/web-shared-styles/sasskit-stylekit/ac-sasskit-config';
+ @use 'ac-sasskit/core/locale' as *;
+
+ a :global(.external-link-arrow) {
+ @include rtl {
+ transform: rotate(-90deg);
+ }
+ }
+</style>