@artsy/palette-mobile 17.22.0 → 17.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,12 @@
1
1
  import { ImgHTMLAttributes } from "react";
2
2
  export type AvatarSize = "xxs" | "xs" | "sm" | "md";
3
3
  export interface AvatarProps extends ImgHTMLAttributes<any> {
4
- src?: string;
4
+ blurhash?: string | null;
5
5
  /** If an image is missing, show initials instead */
6
6
  initials?: string;
7
7
  /** The size of the Avatar */
8
8
  size?: AvatarSize;
9
+ src?: string;
9
10
  }
10
11
  /** A circular Avatar component containing an image or initials */
11
- export declare const Avatar: ({ src, initials, size }: AvatarProps) => JSX.Element;
12
+ export declare const Avatar: ({ src, initials, size, blurhash }: AvatarProps) => JSX.Element;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useState } from "react";
3
- import { Image } from "react-native";
4
- import Animated, { useAnimatedStyle, useSharedValue, withTiming, Easing, withDelay, } from "react-native-reanimated";
2
+ import { MotiView } from "moti";
3
+ import { FadeIn } from "react-native-reanimated";
5
4
  import { useColor } from "../../utils/hooks";
6
5
  import { Box } from "../Box";
7
6
  import { Flex } from "../Flex";
7
+ import { Image } from "../Image/Image";
8
8
  import { Text } from "../Text";
9
9
  const DEFAULT_SIZE = "md";
10
10
  const VARIANTS = {
@@ -26,24 +26,11 @@ const VARIANTS = {
26
26
  },
27
27
  };
28
28
  /** A circular Avatar component containing an image or initials */
29
- export const Avatar = ({ src, initials, size = DEFAULT_SIZE }) => {
29
+ export const Avatar = ({ src, initials, size = DEFAULT_SIZE, blurhash }) => {
30
30
  const color = useColor();
31
- const [loading, setLoading] = useState(true);
32
- const opacity = useSharedValue(0);
33
- useEffect(() => {
34
- opacity.set(() => withDelay(100, withTiming(1, {
35
- duration: 200,
36
- easing: Easing.sin,
37
- })));
38
- }, [loading]);
39
- const style = useAnimatedStyle(() => {
40
- return {
41
- opacity: loading ? 0 : opacity.get(),
42
- };
43
- }, [loading]);
44
31
  const { diameter, textSize } = VARIANTS[size];
45
32
  if (src) {
46
- return (_jsx(Box, { width: diameter, height: diameter, borderRadius: diameter / 2, overflow: "hidden", borderColor: color("mono0"), borderWidth: 1, children: _jsx(Animated.View, { style: style, children: _jsx(Image, { onLoadStart: () => setLoading(true), onLoadEnd: () => setLoading(false), resizeMode: "cover", source: { uri: src }, accessibilityLabel: "AvatarImage", style: {
33
+ return (_jsx(MotiView, { entering: FadeIn, children: _jsx(Box, { width: diameter, height: diameter, borderRadius: diameter / 2, overflow: "hidden", borderColor: color("mono0"), borderWidth: 1, children: _jsx(Image, { blurhash: blurhash, resizeMode: "cover", src: src, height: diameter, width: diameter, accessibilityLabel: "AvatarImage", style: {
47
34
  width: diameter,
48
35
  height: diameter,
49
36
  } }) }) }));
@@ -2,7 +2,7 @@
2
2
  import { AvatarProps } from "./Avatar";
3
3
  declare const _default: {
4
4
  title: string;
5
- component: ({ src, initials, size }: AvatarProps) => JSX.Element;
5
+ component: ({ src, initials, size, blurhash }: AvatarProps) => JSX.Element;
6
6
  };
7
7
  export default _default;
8
8
  export declare function Variants(): JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "17.22.0",
3
+ "version": "17.24.0",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "android": "RCT_METRO_PORT=8082 react-native run-android --port 8082 --terminal terminal",