From 1023cf0120307302185732985f407d2be78704fc Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 4 Feb 2024 21:42:27 +0100 Subject: [PATCH] Add account logo on the avatar component --- front/packages/primitives/src/avatar.tsx | 43 ++++++++++-------------- front/packages/ui/src/navbar/index.tsx | 5 +-- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/front/packages/primitives/src/avatar.tsx b/front/packages/primitives/src/avatar.tsx index 4953c785..c247a3e7 100644 --- a/front/packages/primitives/src/avatar.tsx +++ b/front/packages/primitives/src/avatar.tsx @@ -18,14 +18,13 @@ * along with Kyoo. If not, see . */ -import { View, ViewStyle } from "react-native"; -import { Image, ImageProps } from "./image"; +import { View, ViewStyle, Image } from "react-native"; import { useYoshiki, px, Stylable } from "yoshiki/native"; import { Icon } from "./icons"; import { P } from "./text"; import AccountCircle from "@material-symbols/svg-400/rounded/account_circle-fill.svg"; import { YoshikiStyle } from "yoshiki"; -import { ComponentType, forwardRef, RefAttributes } from "react"; +import { ComponentType, forwardRef, RefAttributes, useEffect, useState } from "react"; const stringToColor = (string: string) => { let hash = 0; @@ -46,10 +45,9 @@ const stringToColor = (string: string) => { export const Avatar = forwardRef< View, { - src?: ImageProps["src"]; - quality?: ImageProps["quality"]; + src?: string; alt?: string; - size?: YoshikiStyle; + size?: number; placeholder?: string; color?: string; isLoading?: boolean; @@ -57,18 +55,7 @@ export const Avatar = forwardRef< as?: ComponentType<{ style?: ViewStyle } & RefAttributes>; } & Stylable >(function Avatar( - { - src, - quality = "low", - alt, - size = px(24), - color, - placeholder, - isLoading = false, - fill = false, - as, - ...props - }, + { src, alt, size = px(24), color, placeholder, isLoading = false, fill = false, as, ...props }, ref, ) { const { css, theme } = useYoshiki(); @@ -89,18 +76,14 @@ export const Avatar = forwardRef< fill && { bg: col, }, - placeholder && - !src && - !isLoading && { - bg: stringToColor(placeholder), - }, + placeholder && { + bg: stringToColor(placeholder), + }, ], props, )} > - {src || isLoading ? ( - {alt} - ) : placeholder ? ( + {placeholder ? (

)} + {alt} ); }); diff --git a/front/packages/ui/src/navbar/index.tsx b/front/packages/ui/src/navbar/index.tsx index 50439e3a..23c9ae6d 100644 --- a/front/packages/ui/src/navbar/index.tsx +++ b/front/packages/ui/src/navbar/index.tsx @@ -18,7 +18,7 @@ * along with Kyoo. If not, see . */ -import { logout, useAccount, useAccounts } from "@kyoo/models"; +import { imageFn, logout, useAccount, useAccounts } from "@kyoo/models"; import { Input, IconButton, @@ -100,6 +100,7 @@ export const NavbarProfile = () => {

{ } + left={} selected={x.selected} onSelect={() => x.select()} />