diff --git a/front/apps/mobile/app/_layout.tsx b/front/apps/mobile/app/_layout.tsx index e910fc65..3c96d1a1 100644 --- a/front/apps/mobile/app/_layout.tsx +++ b/front/apps/mobile/app/_layout.tsx @@ -19,17 +19,18 @@ */ import { Stack } from "expo-router"; -import { ThemeSelector } from "@kyoo/primitives"; +import { Avatar, ThemeSelector } from "@kyoo/primitives"; import { useTheme } from "yoshiki/native"; import { NavbarTitle } from "@kyoo/ui"; const ThemedStack = () => { - const theme = useTheme(); + const theme = useTheme(); return ( , + headerRight: () => , headerStyle: { backgroundColor: theme.appbar, }, diff --git a/front/apps/mobile/app/index.tsx b/front/apps/mobile/app/index.tsx index 2fb3e34e..47d23c48 100644 --- a/front/apps/mobile/app/index.tsx +++ b/front/apps/mobile/app/index.tsx @@ -18,8 +18,7 @@ * along with Kyoo. If not, see . */ -import { View } from "react-native"; -import { Navbar } from "@kyoo/ui"; +import { Text, View } from "react-native"; import { useYoshiki } from "yoshiki/native"; const App = () => { @@ -27,7 +26,8 @@ const App = () => { return ( theme.background })}> - + {/* */} + toto ); }; diff --git a/front/apps/mobile/package.json b/front/apps/mobile/package.json index ae6be659..d8d8c328 100644 --- a/front/apps/mobile/package.json +++ b/front/apps/mobile/package.json @@ -21,7 +21,7 @@ "react-native-safe-area-context": "4.4.1", "react-native-screens": "~3.18.0", "react-native-svg": "13.4.0", - "yoshiki": "0.2.4" + "yoshiki": "0.2.7" }, "devDependencies": { "@babel/core": "^7.19.3", diff --git a/front/apps/web/next.config.js b/front/apps/web/next.config.js index b9462834..320870e3 100755 --- a/front/apps/web/next.config.js +++ b/front/apps/web/next.config.js @@ -84,6 +84,7 @@ const nextConfig = { "solito", "react-native", "react-native-web", + "react-native-svg", "yoshiki", "@expo/vector-icons", "@expo/html-elements", diff --git a/front/apps/web/package.json b/front/apps/web/package.json index b05fe26a..61086978 100644 --- a/front/apps/web/package.json +++ b/front/apps/web/package.json @@ -34,7 +34,7 @@ "react-native-web": "^0.18.10", "solito": "^2.0.5", "superjson": "^1.11.0", - "yoshiki": "0.2.4", + "yoshiki": "0.2.7", "zod": "^3.19.1" }, "devDependencies": { diff --git a/front/packages/primitives/src/avatar.tsx b/front/packages/primitives/src/avatar.tsx index d9329db0..2beb3e99 100644 --- a/front/packages/primitives/src/avatar.tsx +++ b/front/packages/primitives/src/avatar.tsx @@ -19,15 +19,28 @@ */ import { View, ViewStyle } from "react-native"; -import { Image } from "./"; +import { Image } from "./image"; import { useYoshiki, px } from "yoshiki/native"; +import { Icon } from "./icons"; -export const Avatar = ({ src, alt, size = px(24) }: { src: string; alt: string; size: number }) => { +export const Avatar = ({ + src, + alt, + size = px(24), +}: { + src?: string; + alt: string; + size?: number; +}) => { const { css } = useYoshiki(); return ( - {alt} + {src ? ( + {alt} + ) : ( + + )} ); }; diff --git a/front/packages/primitives/src/icons.tsx b/front/packages/primitives/src/icons.tsx index b62056dc..71fb941a 100644 --- a/front/packages/primitives/src/icons.tsx +++ b/front/packages/primitives/src/icons.tsx @@ -29,7 +29,7 @@ export type IconProps = { }; export const Icon = ({ icon, size, color }: IconProps) => { - return ; + return ; }; export const IconButton = ({ diff --git a/front/packages/primitives/src/image.tsx b/front/packages/primitives/src/image.tsx index d29a4eb1..6c7816c0 100644 --- a/front/packages/primitives/src/image.tsx +++ b/front/packages/primitives/src/image.tsx @@ -19,15 +19,11 @@ */ import { useState } from "react"; -import { - View, - Image as Img, - ImageSourcePropType, -} from "react-native"; -import type { Property } from "csstype"; +import { View, Image as Img, ImageSourcePropType, ImageStyle } from "react-native"; +import { percent, useYoshiki } from "yoshiki/native"; type ImageOptions = { - radius?: string; + radius?: number; fallback?: string | ImageSourcePropType; }; @@ -40,8 +36,8 @@ type ImagePropsWithLoading = | (ImageProps & { loading?: boolean }) | (Partial & { loading: true }); -type Width = Property.Width<(string & {}) | 0>; -type Height = Property.Height<(string & {}) | 0>; +type Width = ImageStyle["width"]; +type Height = ImageStyle["height"]; export const Image = ({ src, @@ -55,9 +51,10 @@ export const Image = ({ ...others }: ImagePropsWithLoading & ( - | { aspectRatio?: string; width: Width; height: Height } - | { aspectRatio: string; width?: Width; height?: Height } + | { aspectRatio?: number; width: Width; height: Height } + | { aspectRatio: number; width?: Width; height?: Height } )) => { + const { css } = useYoshiki(); const [showLoading, setLoading] = useState(loading); const [source, setSource] = useState(src); /* const imgRef = useRef(null); */ @@ -70,16 +67,18 @@ export const Image = ({ return ( *": { width: "100%", height: "100%" }, - }} - {...others} + {...css( + { + aspectRatio, + width, + height, + /* backgroundColor: "grey.300", */ + borderRadius: radius, + overflow: "hidden", + /* "& > *": { width: "100%", height: "100%" }, */ + }, + others, + )} > {/* {showLoading && } */} {!loading && source && ( @@ -91,7 +90,12 @@ export const Image = ({ if (fallback) setSource(fallback); else setLoading(false); }} - css={{ objectFit: "cover", display: showLoading ? "hidden" : undefined }} + {...css({ + height: percent(100), + width: percent(100), + resizeMode: "cover", + /* display: showLoading ? "hidden" : undefined, */ + })} /> )} @@ -99,5 +103,5 @@ export const Image = ({ }; export const Poster = (props: ImagePropsWithLoading & { width?: Width; height?: Height }) => ( - + ); diff --git a/front/packages/ui/src/navbar/icon.tsx b/front/packages/ui/src/navbar/icon.tsx index a5ead79b..3662c05e 100644 --- a/front/packages/ui/src/navbar/icon.tsx +++ b/front/packages/ui/src/navbar/icon.tsx @@ -36,9 +36,11 @@ import Svg, { SvgProps, Path } from "react-native-svg"; /* */ /* ); */ -export const KyooLongLogo = (props: SvgProps) => - ( - +export const KyooLongLogo = ({ + height = 24, + ...props +}: Omit & { height?: number }) => ( + ({}); -export const NavbarTitle = (props: Stylable) => { - const { css } = useYoshiki(); - const { t } = useTranslation("common"); - - return ( - - {/* */} -

- Kyoo -

- - ); -}; +export const NavbarTitle = KyooLongLogo; export const Navbar = () => { const { css } = useYoshiki(); @@ -70,8 +40,19 @@ export const Navbar = () => {
theme.appbar, + paddingX: ts(2), + height: { xs: 48, sm: 64 }, flexDirection: "row", + justifyContent: { xs: "space-between", sm: "flex-start" }, alignItems: "center", + shadowColor: "#000", + shadowOffset: { + width: 0, + height: 4, + }, + shadowOpacity: 0.3, + shadowRadius: 4.65, + elevation: 8, })} > { color="white" {...css({ display: { xs: "flex", sm: "none" } })} /> - {/* */} - - {/* */} - + + { /*isSuccess ? data.items.map((library) => */ true @@ -111,8 +97,8 @@ export const Navbar = () => { ) } - - {/* */} + + {/* {isError && } */}
diff --git a/front/packages/ui/src/navbar/navbar.tsx b/front/packages/ui/src/navbar/navbar.tsx deleted file mode 100644 index 6924b06e..00000000 --- a/front/packages/ui/src/navbar/navbar.tsx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 . - */ - -import { Paragraph } from "@kyoo/primitives"; -import { View } from "react-native"; -import { KyooLongLogo } from "./icon"; - -export const Navbar = () => { - /* const { t } = useTranslation("common"); */ - /* const { data, error, isSuccess, isError } = useFetch(Navbar.query()); */ - - return ( - ({ backgroundColor: theme.appbar })}> - - Toto - {/* */} - {/* {isSuccess */} - {/* ? data.items.map((library) => ( */} - {/* */} - {/* {library.name} */} - {/* */} - {/* )) */} - {/* : [...Array(4)].map((_, i) => ( */} - {/* */} - {/* */} - {/* */} - {/* ))} */} - {/* */} - {/* */} - {/* {isError && } */} - - ); -}; - -/* Navbar.query = (): QueryIdentifier> => ({ */ -/* parser: Paged(LibraryP), */ -/* path: ["libraries"], */ -/* }); */ diff --git a/front/yarn.lock b/front/yarn.lock index 1485930e..c94b216b 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -9459,7 +9459,7 @@ __metadata: react-native-screens: ~3.18.0 react-native-svg: 13.4.0 typescript: ^4.6.3 - yoshiki: 0.2.4 + yoshiki: 0.2.7 languageName: unknown linkType: soft @@ -12935,7 +12935,7 @@ __metadata: superjson: ^1.11.0 typescript: ^4.9.3 webpack: ^5.75.0 - yoshiki: 0.2.4 + yoshiki: 0.2.7 zod: ^3.19.1 languageName: unknown linkType: soft @@ -13260,9 +13260,9 @@ __metadata: languageName: node linkType: hard -"yoshiki@npm:0.2.4": - version: 0.2.4 - resolution: "yoshiki@npm:0.2.4" +"yoshiki@npm:0.2.7": + version: 0.2.7 + resolution: "yoshiki@npm:0.2.7" dependencies: "@types/node": 18.x.x "@types/react": 18.x.x @@ -13277,7 +13277,7 @@ __metadata: optional: true react-native-web: optional: true - checksum: 7046d777a5726661ed7a4a0f6e67600740ccbbb23c833f5cb6a2f5029d6bbd3357426dd02a2b1c759b89faf832fec9ee712c8b10fbdb846dec4a2bd32f229ca4 + checksum: 5589cde181d2825a9c25d0ec51b99873a335869989314c3cee3a4503444344a546ccc4705e1a0f76a4ec4faaa14433ae96fa8e2024d6550498b61b193c0fba5f languageName: node linkType: hard