Use A instead of a Link component for external links

This commit is contained in:
Zoe Roux 2023-11-05 12:19:21 +01:00
parent 05d8332358
commit 9bfd1a78bd
3 changed files with 14 additions and 5 deletions

Binary file not shown.

View File

@ -23,18 +23,26 @@ import { Platform, Pressable, TextProps, View, PressableProps } from "react-nati
import { TextLink, useLink } from "solito/link";
import { useTheme, useYoshiki } from "yoshiki/native";
import { alpha } from "./themes";
import { NextLink } from "solito/build/link/next-link";
export const A = ({
href,
replace,
children,
target,
...props
}: TextProps & { href?: string; replace?: boolean; children: ReactNode }) => {
}: TextProps & {
href?: string | null;
target?: string;
replace?: boolean;
children: ReactNode;
}) => {
const { css, theme } = useYoshiki();
return (
<TextLink
href={href ?? ""}
target={target}
replace={replace as any}
experimental={
replace
@ -51,6 +59,7 @@ export const A = ({
},
{
selectable: true,
hrefAttrs: { target },
...props,
},
)}

View File

@ -50,7 +50,7 @@ import {
} from "@kyoo/primitives";
import { Fragment } from "react";
import { useTranslation } from "react-i18next";
import { ImageStyle, Platform, View } from "react-native";
import { ImageStyle, Platform, Text, View } from "react-native";
import {
Theme,
md,
@ -430,12 +430,12 @@ export const Header = ({
).map(([name, data]) => (
<Chip
key={name}
as={Link}
as={A}
href={data?.link}
target="_blank"
size="small"
outline
{...css({
{...(css({
m: ts(0.5),
color: (theme: Theme) => theme.contrast,
fover: {
@ -444,7 +444,7 @@ export const Header = ({
bg: (theme: Theme) => theme.accent,
},
},
})}
}) as any)}
>
{data ? name : <Skeleton {...css({ width: rem(3) })} />}
</Chip>