diff --git a/front/packages/primitives/src/chip.tsx b/front/packages/primitives/src/chip.tsx index a4930fb7..32096f2d 100644 --- a/front/packages/primitives/src/chip.tsx +++ b/front/packages/primitives/src/chip.tsx @@ -18,7 +18,7 @@ * along with Kyoo. If not, see . */ -import type { TextProps } from "react-native"; +import { View, type TextProps } from "react-native"; import { type Theme, px, rem, useYoshiki } from "yoshiki/native"; import { Link } from "./links"; import { Skeleton } from "./skeleton"; @@ -63,6 +63,7 @@ export const Chip = ({ pX: ts(2.5 * sizeMult), borderRadius: ts(3), overflow: "hidden", + justifyContent: "center", }, outline && { borderColor: color ?? ((theme: Theme) => theme.accent), @@ -102,3 +103,40 @@ export const Chip = ({ ); }; + +Chip.Loader = ({ + color, + size = "medium", + outline = false, + ...props +}: { color?: string; size?: "small" | "medium" | "large"; outline?: boolean }) => { + const { css } = useYoshiki(); + const sizeMult = size === "medium" ? 1 : size === "small" ? 0.5 : 1.5; + + return ( + theme.accent), + borderStyle: "solid", + borderWidth: px(1), + }, + !outline && { + bg: color ?? ((theme: Theme) => theme.accent), + }, + ], + props, + )} + > + + + ); +}; diff --git a/front/packages/primitives/src/image/image.tsx b/front/packages/primitives/src/image/image.tsx index 288a892f..21538afe 100644 --- a/front/packages/primitives/src/image/image.tsx +++ b/front/packages/primitives/src/image/image.tsx @@ -19,7 +19,7 @@ */ import { getCurrentToken } from "@kyoo/models"; -import { useState } from "react"; +import { ReactElement, useState } from "react"; import { type FlexStyle, type ImageStyle, View, type ViewStyle } from "react-native"; import { Blurhash } from "react-native-blurhash"; import FastImage from "react-native-fast-image"; @@ -94,9 +94,9 @@ export const Image = ({ ); }; -Image.Loader = ({ layout, ...props }: { layout: ImageLayout }) => { +Image.Loader = ({ layout, ...props }: { layout: ImageLayout; children?: ReactElement }) => { const { css } = useYoshiki(); const border = { borderRadius: 6, overflow: "hidden" } satisfies ViewStyle; - return ; + return ; }; diff --git a/front/packages/primitives/src/image/image.web.tsx b/front/packages/primitives/src/image/image.web.tsx index 7a459e55..e810d053 100644 --- a/front/packages/primitives/src/image/image.web.tsx +++ b/front/packages/primitives/src/image/image.web.tsx @@ -19,7 +19,7 @@ */ import NextImage from "next/image"; -import { useState } from "react"; +import { ReactElement, useState } from "react"; import { type ImageStyle, View, type ViewStyle } from "react-native"; import { useYoshiki } from "yoshiki/native"; import { imageBorderRadius } from "../constants"; @@ -74,9 +74,9 @@ export const Image = ({ ); }; -Image.Loader = ({ layout, ...props }: { layout: ImageLayout }) => { +Image.Loader = ({ layout, ...props }: { layout: ImageLayout, children?: ReactElement }) => { const { css } = useYoshiki(); const border = { borderRadius: 6, overflow: "hidden" } satisfies ViewStyle; - return ; + return ; }; diff --git a/front/packages/primitives/src/image/index.tsx b/front/packages/primitives/src/image/index.tsx index ca793d31..9b775f15 100644 --- a/front/packages/primitives/src/image/index.tsx +++ b/front/packages/primitives/src/image/index.tsx @@ -19,7 +19,7 @@ */ import { LinearGradient, type LinearGradientProps } from "expo-linear-gradient"; -import type { ComponentProps, ComponentType, ReactNode } from "react"; +import type { ComponentProps, ComponentType, ReactElement, ReactNode } from "react"; import { type ImageStyle, View, type ViewProps, type ViewStyle } from "react-native"; import { percent } from "yoshiki/native"; import { imageBorderRadius } from "../constants"; @@ -43,6 +43,7 @@ Poster.Loader = ({ layout, ...props }: { + children?: ReactElement; layout: YoshikiEnhanced<{ width: ImageStyle["width"] } | { height: ImageStyle["height"] }>; }) => ; diff --git a/front/packages/primitives/src/skeleton.tsx b/front/packages/primitives/src/skeleton.tsx index d6336b75..3470a75d 100644 --- a/front/packages/primitives/src/skeleton.tsx +++ b/front/packages/primitives/src/skeleton.tsx @@ -19,11 +19,10 @@ */ import { LinearGradient as LG } from "expo-linear-gradient"; -import { AnimatePresence, MotiView, motify } from "moti"; +import { MotiView, motify } from "moti"; import { useState } from "react"; import { Platform, View, type ViewProps } from "react-native"; import { em, percent, px, rem, useYoshiki } from "yoshiki/native"; -import { hiddenIfNoJs } from "./utils/nojs"; const LinearGradient = motify(LG)(); @@ -99,71 +98,59 @@ export const Skeleton = ({ props, )} > - - {children} - {(forcedShow || !children || children === true) && - [...Array(lines)].map((_, i) => ( - setWidth(e.nativeEvent.layout.width)} - {...css( - [ - { - bg: (theme) => theme.overlay0, - }, - lines === 1 && { - position: "absolute", - top: 0, - bottom: 0, - left: 0, - right: 0, - }, - lines !== 1 && { - width: i === lines - 1 ? percent(40) : percent(100), - height: rem(1.2), - marginBottom: rem(0.5), - overflow: "hidden", - borderRadius: px(6), - }, - ], - hiddenIfNoJs, - )} - > - - - ))} - + {(forcedShow || !children || children === true) && + [...Array(lines)].map((_, i) => ( + setWidth(e.nativeEvent.layout.width)} + {...css([ + { + bg: (theme) => theme.overlay0, + }, + lines === 1 && { + position: "absolute", + top: 0, + bottom: 0, + left: 0, + right: 0, + }, + lines !== 1 && { + width: i === lines - 1 ? percent(40) : percent(100), + height: rem(1.2), + marginBottom: rem(0.5), + overflow: "hidden", + borderRadius: px(6), + }, + ])} + > + + + ))} + {children} ); }; diff --git a/front/packages/primitives/src/skeleton.web.tsx b/front/packages/primitives/src/skeleton.web.tsx index f322cac0..318e9aa7 100644 --- a/front/packages/primitives/src/skeleton.web.tsx +++ b/front/packages/primitives/src/skeleton.web.tsx @@ -21,7 +21,6 @@ import { LinearGradient } from "expo-linear-gradient"; import { View, type ViewProps } from "react-native"; import { em, percent, px, rem, useYoshiki } from "yoshiki/native"; -import { hiddenIfNoJs } from "./utils/nojs"; export const SkeletonCss = () => (