@artsy/palette-mobile 13.0.36 → 13.1.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,9 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.Avatar = void 0;
|
|
4
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
const react_1 = require("react");
|
|
5
29
|
const react_native_1 = require("react-native");
|
|
30
|
+
const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
6
31
|
const hooks_1 = require("../../utils/hooks");
|
|
32
|
+
const Box_1 = require("../Box");
|
|
7
33
|
const Flex_1 = require("../Flex");
|
|
8
34
|
const Text_1 = require("../Text");
|
|
9
35
|
const DEFAULT_SIZE = "md";
|
|
@@ -28,15 +54,23 @@ const VARIANTS = {
|
|
|
28
54
|
/** A circular Avatar component containing an image or initials */
|
|
29
55
|
const Avatar = ({ src, initials, size = DEFAULT_SIZE }) => {
|
|
30
56
|
const color = (0, hooks_1.useColor)();
|
|
57
|
+
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
58
|
+
const opacity = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
59
|
+
opacity.value = (0, react_native_reanimated_1.withDelay)(100, (0, react_native_reanimated_1.withTiming)(1, {
|
|
60
|
+
duration: 200,
|
|
61
|
+
easing: react_native_reanimated_1.Easing.sin,
|
|
62
|
+
}));
|
|
63
|
+
const style = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
64
|
+
return {
|
|
65
|
+
opacity: loading ? 0 : opacity.value,
|
|
66
|
+
};
|
|
67
|
+
}, [loading]);
|
|
31
68
|
const { diameter, textSize } = VARIANTS[size];
|
|
32
69
|
if (src) {
|
|
33
|
-
return ((0, jsx_runtime_1.jsx)(react_native_1.Image, { resizeMode: "cover", style: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
borderColor: color("white100"),
|
|
38
|
-
borderWidth: 1,
|
|
39
|
-
}, source: { uri: src }, accessibilityLabel: "AvatarImage" }));
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)(Box_1.Box, { width: diameter, height: diameter, borderRadius: diameter / 2, overflow: "hidden", borderColor: color("white100"), borderWidth: 1, children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: style, children: (0, jsx_runtime_1.jsx)(react_native_1.Image, { onLoadStart: () => setLoading(true), onLoadEnd: () => setLoading(false), resizeMode: "cover", source: { uri: src }, accessibilityLabel: "AvatarImage", style: {
|
|
71
|
+
width: diameter,
|
|
72
|
+
height: diameter,
|
|
73
|
+
} }) }) }));
|
|
40
74
|
}
|
|
41
75
|
return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { width: diameter, height: diameter, borderColor: "black10", borderWidth: 1, borderRadius: diameter, overflow: "hidden", alignItems: "center", justifyContent: "center", accessibilityLabel: "Avatar", children: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: textSize, children: initials }) }));
|
|
42
76
|
};
|