Front: Define and apply Image's border radius constant

This commit is contained in:
Arthur Jamet 2023-12-08 18:34:59 +01:00 committed by Zoe Roux
parent e6ac7e502c
commit c475691939
7 changed files with 53 additions and 6 deletions

View File

@ -0,0 +1,21 @@
/*
* Kyoo - A portable and vast media library solution.
* Copyright (c) Kyoo.
*
* See AUTHORS.md and LICENSE file in the project root for full license information.
*
* Kyoo is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Kyoo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
*/
export const ImageBorderRadius = 10;

View File

@ -0,0 +1,21 @@
/*
* Kyoo - A portable and vast media library solution.
* Copyright (c) Kyoo.
*
* See AUTHORS.md and LICENSE file in the project root for full license information.
*
* Kyoo is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Kyoo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
*/
export * from './image-border-radius';

View File

@ -25,6 +25,7 @@ import { Props, ImageLayout } from "./base-image";
import { BlurhashContainer } from "./blurhash.web"; import { BlurhashContainer } from "./blurhash.web";
import { Skeleton } from "../skeleton"; import { Skeleton } from "../skeleton";
import NextImage from "next/image"; import NextImage from "next/image";
import { ImageBorderRadius } from "../constants";
export const Image = ({ export const Image = ({
src, src,
@ -40,7 +41,7 @@ export const Image = ({
typeof window === "undefined" ? "finished" : "loading", typeof window === "undefined" ? "finished" : "loading",
); );
const border = { borderRadius: 6 } satisfies ViewStyle; const border = { borderRadius: ImageBorderRadius } satisfies ViewStyle;
if (forcedLoading) return <Skeleton variant="custom" {...css([layout, border], props)} />; if (forcedLoading) return <Skeleton variant="custom" {...css([layout, border], props)} />;
if (!src || state === "errored") { if (!src || state === "errored") {

View File

@ -25,6 +25,7 @@ import { ComponentProps, ComponentType, ReactNode } from "react";
import { LinearGradient, LinearGradientProps } from "expo-linear-gradient"; import { LinearGradient, LinearGradientProps } from "expo-linear-gradient";
import { ContrastArea } from "../themes"; import { ContrastArea } from "../themes";
import { percent } from "yoshiki/native"; import { percent } from "yoshiki/native";
import { ImageBorderRadius } from "../constants";
export { BlurhashContainer } from "./blurhash"; export { BlurhashContainer } from "./blurhash";
export { type Props as ImageProps, Image }; export { type Props as ImageProps, Image };
@ -84,7 +85,7 @@ export const ImageBackground = <AsProps = ViewProps,>({
{({ css, theme }) => ( {({ css, theme }) => (
<Container <Container
{...(css( {...(css(
[layout, !hideLoad && { borderRadius: 6, overflow: "hidden" }], [layout, !hideLoad && { borderRadius: ImageBorderRadius, overflow: "hidden" }],
asProps, asProps,
) as AsProps)} ) as AsProps)}
> >

View File

@ -38,3 +38,4 @@ export * from "./button";
export * from "./chip"; export * from "./chip";
export * from "./utils"; export * from "./utils";
export * from "./constants";

View File

@ -29,6 +29,7 @@ import {
Heading, Heading,
Icon, Icon,
PosterBackground, PosterBackground,
ImageBorderRadius
} from "@kyoo/primitives"; } from "@kyoo/primitives";
import { useState } from "react"; import { useState } from "react";
import { View } from "react-native"; import { View } from "react-native";
@ -71,10 +72,10 @@ export const ItemList = ({
onPressIn={() => setHovered((i) => i + 1)} onPressIn={() => setHovered((i) => i + 1)}
onPressOut={() => setHovered((i) => i - 1)} onPressOut={() => setHovered((i) => i - 1)}
containerStyle={{ containerStyle={{
borderRadius: px(6), borderRadius: px(ImageBorderRadius),
}} }}
imageStyle={{ imageStyle={{
borderRadius: px(6), borderRadius: px(ImageBorderRadius),
}} }}
{...css( {...css(
{ {
@ -82,7 +83,7 @@ export const ItemList = ({
justifyContent: "space-evenly", justifyContent: "space-evenly",
flexDirection: "row", flexDirection: "row",
height: ItemList.layout.size, height: ItemList.layout.size,
borderRadius: px(6), borderRadius: px(ImageBorderRadius),
marginX: ItemList.layout.gap, marginX: ItemList.layout.gap,
}, },
props, props,

View File

@ -33,6 +33,7 @@ import {
H3, H3,
Icon, Icon,
IconFab, IconFab,
ImageBorderRadius,
Link, Link,
P, P,
PosterBackground, PosterBackground,
@ -89,7 +90,7 @@ export const ItemDetails = ({
height: ItemDetails.layout.size, height: ItemDetails.layout.size,
flexDirection: "row", flexDirection: "row",
bg: (theme) => theme.variant.background, bg: (theme) => theme.variant.background,
borderRadius: 6, borderRadius: 12, // to make the border stick to the poster
overflow: "hidden", overflow: "hidden",
borderColor: (theme) => theme.background, borderColor: (theme) => theme.background,
borderWidth: ts(0.25), borderWidth: ts(0.25),