mirror of
https://github.com/rxliuli/apps.apple.com.git
synced 2025-11-10 01:30:33 +00:00
init commit
This commit is contained in:
52
src/components/jet/action/ExternalUrlAction.svelte
Normal file
52
src/components/jet/action/ExternalUrlAction.svelte
Normal file
@@ -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>
|
||||
Reference in New Issue
Block a user