@artsy/palette-mobile 23.14.0 → 24.0.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.
- package/dist/Theme.js +16 -11
- package/dist/animation/CssTransition.js +71 -26
- package/dist/animation/index.js +17 -1
- package/dist/constants.js +12 -8
- package/dist/elements/ArtsyKeyboardAvoidingView/ArtsyKeyboardAvoidingView.js +116 -69
- package/dist/elements/ArtsyKeyboardAvoidingView/index.js +17 -1
- package/dist/elements/Autocomplete/Autocomplete.js +32 -23
- package/dist/elements/Autocomplete/Autocomplete.tests.js +128 -56
- package/dist/elements/Autocomplete/index.js +17 -1
- package/dist/elements/Avatar/Avatar.js +20 -15
- package/dist/elements/Avatar/Avatar.stories.js +29 -15
- package/dist/elements/Avatar/Avatar.tests.js +12 -10
- package/dist/elements/Avatar/index.js +17 -1
- package/dist/elements/BackButton/BackButton.js +16 -9
- package/dist/elements/BackButton/BackButton.stories.js +12 -8
- package/dist/elements/BackButton/index.js +17 -1
- package/dist/elements/Banner/Banner.js +45 -18
- package/dist/elements/Banner/Banner.stories.js +12 -8
- package/dist/elements/Banner/index.js +17 -1
- package/dist/elements/BorderBox/BorderBox.js +16 -11
- package/dist/elements/BorderBox/index.js +17 -1
- package/dist/elements/Box/Box.js +16 -14
- package/dist/elements/Box/Box.stories.js +21 -15
- package/dist/elements/Box/index.js +17 -1
- package/dist/elements/Button/Button.js +85 -64
- package/dist/elements/Button/Button.stories.js +48 -23
- package/dist/elements/Button/CTAButton.js +18 -3
- package/dist/elements/Button/FollowButton.js +38 -11
- package/dist/elements/Button/LinkButton.js +19 -4
- package/dist/elements/Button/colors.js +7 -3
- package/dist/elements/Button/index.js +20 -4
- package/dist/elements/ButtonNew/Button.js +114 -49
- package/dist/elements/ButtonNew/Button.stories.js +64 -38
- package/dist/elements/ButtonNew/Button.tests.js +23 -21
- package/dist/elements/ButtonNew/CTAButton.js +18 -3
- package/dist/elements/ButtonNew/FollowButton.js +36 -9
- package/dist/elements/ButtonNew/LinkButton.js +19 -4
- package/dist/elements/ButtonNew/colors.js +7 -3
- package/dist/elements/ButtonNew/index.js +20 -4
- package/dist/elements/Checkbox/Check.js +83 -46
- package/dist/elements/Checkbox/Checkbox.js +83 -47
- package/dist/elements/Checkbox/Checkbox.stories.js +10 -9
- package/dist/elements/Checkbox/index.js +18 -2
- package/dist/elements/Chip/Chip.js +23 -18
- package/dist/elements/Chip/Chip.stories.js +12 -8
- package/dist/elements/Chip/index.js +17 -1
- package/dist/elements/ClassTheme/ClassTheme.js +10 -5
- package/dist/elements/ClassTheme/index.js +17 -1
- package/dist/elements/Collapse/Collapse.js +9 -4
- package/dist/elements/Collapse/Collapse.stories.js +13 -9
- package/dist/elements/Collapse/index.js +17 -1
- package/dist/elements/CollapsibleMenuItem/CollapsibleMenuItem.js +32 -27
- package/dist/elements/CollapsibleMenuItem/CollapsibleMenuItem.stories.js +62 -37
- package/dist/elements/CollapsibleMenuItem/index.js +17 -1
- package/dist/elements/Dialog/Dialog.js +52 -26
- package/dist/elements/Dialog/Dialog.stories.js +41 -22
- package/dist/elements/Dialog/Dialog.tests.js +33 -31
- package/dist/elements/Dialog/index.js +17 -1
- package/dist/elements/EntityHeader/EntityHeader.js +42 -15
- package/dist/elements/EntityHeader/EntityHeader.stories.js +26 -18
- package/dist/elements/EntityHeader/index.js +17 -1
- package/dist/elements/Flex/Flex.js +32 -4
- package/dist/elements/Flex/index.js +17 -1
- package/dist/elements/Header/ArtsyLogoHeader.js +15 -8
- package/dist/elements/Header/index.js +17 -1
- package/dist/elements/Histogram/Histogram.js +19 -14
- package/dist/elements/Histogram/index.js +17 -1
- package/dist/elements/Image/Image.js +60 -28
- package/dist/elements/Image/Image.stories.js +35 -23
- package/dist/elements/Image/__tests__/getImageURL.tests.js +10 -8
- package/dist/elements/Image/helpers/getImageURL.js +13 -8
- package/dist/elements/Image/index.js +17 -1
- package/dist/elements/Input/Input.js +216 -168
- package/dist/elements/Input/Input.stories.js +15 -11
- package/dist/elements/Input/Input.tests.js +85 -39
- package/dist/elements/Input/InputTitle.js +9 -4
- package/dist/elements/Input/helpers.js +35 -27
- package/dist/elements/Input/index.js +19 -3
- package/dist/elements/Input/maskValue.js +25 -9
- package/dist/elements/Input/maskValue.tests.js +19 -17
- package/dist/elements/Join/Join.js +14 -9
- package/dist/elements/Join/index.js +17 -1
- package/dist/elements/LazyFlatlist/LazyFlatlist.js +11 -8
- package/dist/elements/LazyFlatlist/index.js +18 -2
- package/dist/elements/LazyFlatlist/useHasSeenItem.js +19 -12
- package/dist/elements/LegacyScreen/LegacyScreen.js +124 -83
- package/dist/elements/LegacyScreen/index.js +17 -1
- package/dist/elements/LegacyTabs/ContentTabs.js +18 -12
- package/dist/elements/LegacyTabs/NavigationalTabs.js +21 -15
- package/dist/elements/LegacyTabs/StepTabs.js +25 -19
- package/dist/elements/LegacyTabs/Tab.js +31 -19
- package/dist/elements/LegacyTabs/TabBarContainer.js +48 -39
- package/dist/elements/LegacyTabs/index.js +38 -9
- package/dist/elements/List/BulletedItem.js +34 -7
- package/dist/elements/List/List.stories.js +12 -8
- package/dist/elements/List/index.js +17 -1
- package/dist/elements/MeasuredView/MeasuredView.js +18 -12
- package/dist/elements/MeasuredView/index.js +17 -1
- package/dist/elements/MenuItem/MenuItem.js +14 -9
- package/dist/elements/MenuItem/MenuItem.stories.js +9 -5
- package/dist/elements/MenuItem/index.js +17 -1
- package/dist/elements/Message/Message.js +35 -19
- package/dist/elements/Message/Message.stories.d.ts +1 -1
- package/dist/elements/Message/Message.stories.js +23 -17
- package/dist/elements/Message/Message.tests.js +38 -36
- package/dist/elements/Message/index.js +17 -1
- package/dist/elements/Pill/Pill.js +116 -138
- package/dist/elements/Pill/Pill.stories.js +28 -20
- package/dist/elements/Pill/Pill.tests.js +15 -13
- package/dist/elements/Pill/index.js +17 -1
- package/dist/elements/PopIn/PopIn.js +13 -8
- package/dist/elements/PopIn/index.js +17 -1
- package/dist/elements/Popover/Popover.js +45 -15
- package/dist/elements/Popover/Popover.stories.js +25 -19
- package/dist/elements/Popover/index.js +17 -1
- package/dist/elements/ProgressBar/ProgressBar.js +68 -23
- package/dist/elements/ProgressBar/ProgressBar.stories.js +11 -7
- package/dist/elements/ProgressBar/ProgressBar.tests.js +48 -23
- package/dist/elements/ProgressBar/index.js +17 -1
- package/dist/elements/Radio/RadioButton.js +80 -44
- package/dist/elements/Radio/RadioButton.stories.js +17 -13
- package/dist/elements/Radio/RadioDot.js +31 -15
- package/dist/elements/Radio/index.js +7 -2
- package/dist/elements/Screen/Background.js +10 -3
- package/dist/elements/Screen/Body.js +37 -10
- package/dist/elements/Screen/BottomView.js +17 -9
- package/dist/elements/Screen/FloatingHeader.js +36 -9
- package/dist/elements/Screen/FullWidthDivider.js +20 -5
- package/dist/elements/Screen/FullWidthItem.js +20 -5
- package/dist/elements/Screen/Header.js +79 -26
- package/dist/elements/Screen/Screen.stories.js +46 -30
- package/dist/elements/Screen/ScreenBase.js +39 -11
- package/dist/elements/Screen/ScreenFlatList.js +26 -9
- package/dist/elements/Screen/ScreenScrollContext.js +21 -15
- package/dist/elements/Screen/ScreenScrollView.js +27 -9
- package/dist/elements/Screen/StickySubHeader.js +62 -23
- package/dist/elements/Screen/constants.js +8 -5
- package/dist/elements/Screen/hooks/useListenForScreenScroll.js +13 -9
- package/dist/elements/Screen/hooks/useShowLargeTitle.js +19 -14
- package/dist/elements/Screen/hooks/useTitleStyles.js +14 -10
- package/dist/elements/Screen/index.js +48 -31
- package/dist/elements/SearchInput/RoundSearchInput.js +79 -46
- package/dist/elements/SearchInput/SearchInput.js +43 -14
- package/dist/elements/SearchInput/index.js +18 -2
- package/dist/elements/Separator/Separator.js +20 -12
- package/dist/elements/Separator/Separator.stories.js +10 -6
- package/dist/elements/Separator/ShadowSeparator.js +14 -7
- package/dist/elements/Separator/index.js +18 -2
- package/dist/elements/SimpleMessage/SimpleMessage.js +47 -11
- package/dist/elements/SimpleMessage/index.js +17 -1
- package/dist/elements/Skeleton/Skeleton.js +50 -19
- package/dist/elements/Skeleton/Skeleton.stories.js +14 -10
- package/dist/elements/Skeleton/index.js +17 -1
- package/dist/elements/Spacer/Spacer.js +32 -3
- package/dist/elements/Spacer/Spacer.stories.js +35 -19
- package/dist/elements/Spacer/index.js +17 -1
- package/dist/elements/Spinner/Spinner.js +62 -33
- package/dist/elements/Spinner/index.js +17 -1
- package/dist/elements/Switch/Switch.js +50 -17
- package/dist/elements/Switch/Switch.stories.js +31 -14
- package/dist/elements/Switch/index.js +17 -1
- package/dist/elements/Tabs/SubTabBar.js +29 -20
- package/dist/elements/Tabs/TabFlashList.js +24 -12
- package/dist/elements/Tabs/TabFlatList.js +24 -12
- package/dist/elements/Tabs/TabMasonry.js +24 -12
- package/dist/elements/Tabs/TabScrollView.js +27 -14
- package/dist/elements/Tabs/Tabs.js +27 -24
- package/dist/elements/Tabs/Tabs.stories.js +93 -46
- package/dist/elements/Tabs/TabsContainer.js +62 -38
- package/dist/elements/Tabs/TabsWithHeader.js +41 -13
- package/dist/elements/Tabs/hooks/useListenForTabContentScroll.js +13 -9
- package/dist/elements/Tabs/index.js +17 -1
- package/dist/elements/Text/LinkText.js +32 -3
- package/dist/elements/Text/Text.js +61 -23
- package/dist/elements/Text/Text.stories.js +37 -28
- package/dist/elements/Text/Text.tests.js +7 -5
- package/dist/elements/Text/helpers.js +13 -7
- package/dist/elements/Text/index.js +19 -3
- package/dist/elements/ToolTip/ToolTip.js +67 -53
- package/dist/elements/ToolTip/ToolTip.stories.js +21 -14
- package/dist/elements/ToolTip/ToolTip.tests.js +15 -13
- package/dist/elements/ToolTip/ToolTipFlyout.js +68 -28
- package/dist/elements/ToolTip/index.js +17 -1
- package/dist/elements/Touchable/Touchable.js +41 -13
- package/dist/elements/Touchable/Touchable.stories.js +13 -9
- package/dist/elements/Touchable/TouchableHighlightColor.js +38 -12
- package/dist/elements/Touchable/TouchableWithScale.js +38 -11
- package/dist/elements/Touchable/index.js +19 -3
- package/dist/elements/VisualClue/VisualClue.stories.js +11 -7
- package/dist/elements/VisualClue/VisualClueDot.js +24 -14
- package/dist/elements/VisualClue/VisualClueText.js +26 -15
- package/dist/elements/VisualClue/index.js +18 -2
- package/dist/elements/index.js +62 -46
- package/dist/index.js +24 -8
- package/dist/setupJest.js +11 -6
- package/dist/storybook/decorators.js +36 -27
- package/dist/storybook/helpers.js +40 -22
- package/dist/tokens.js +28 -67
- package/dist/types.js +10 -5
- package/dist/utils/Wrap.js +16 -8
- package/dist/utils/colors.stories.js +31 -25
- package/dist/utils/createGeminiUrl.js +28 -22
- package/dist/utils/flattenChildren.js +20 -7
- package/dist/utils/formatLargeNumber.js +8 -4
- package/dist/utils/formatLargeNumbers.tests.js +15 -13
- package/dist/utils/hooks/index.js +20 -4
- package/dist/utils/hooks/useColor.js +6 -2
- package/dist/utils/hooks/useMeasure.js +40 -14
- package/dist/utils/hooks/useScreenDimensions.js +31 -20
- package/dist/utils/hooks/useSpace.js +6 -2
- package/dist/utils/hooks/useTheme.js +31 -23
- package/dist/utils/normalizeText.js +11 -6
- package/dist/utils/space.stories.js +15 -10
- package/dist/utils/tests/flattenChildren.tests.js +8 -6
- package/dist/utils/tests/isTestEnvironment.js +5 -1
- package/dist/utils/tests/renderWithWrappers.js +15 -7
- package/dist/utils/text.js +13 -9
- package/dist/utils/types.js +2 -0
- package/dist/utils/webTokensToMobile.js +16 -10
- package/package.json +30 -36
|
@@ -1,22 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.EntityHeader = void 0;
|
|
26
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
+
var native_1 = require("@artsy/icons/native");
|
|
28
|
+
var react_1 = require("react");
|
|
29
|
+
var react_native_1 = require("react-native");
|
|
30
|
+
var text_1 = require("../../utils/text");
|
|
31
|
+
var Avatar_1 = require("../Avatar");
|
|
32
|
+
var Flex_1 = require("../Flex");
|
|
33
|
+
var Text_1 = require("../Text");
|
|
34
|
+
var EntityHeader = function (_a) {
|
|
35
|
+
var _b = _a.avatarSize, avatarSize = _b === void 0 ? "xs" : _b, FollowButton = _a.FollowButton, RightButton = _a.RightButton, imageUrl = _a.imageUrl, initials = _a.initials, meta = _a.meta, name = _a.name, _c = _a.smallVariant, smallVariant = _c === void 0 ? false : _c, displayPrivateIcon = _a.displayPrivateIcon, _d = _a.theme, theme = _d === void 0 ? "light" : _d, restProps = __rest(_a, ["avatarSize", "FollowButton", "RightButton", "imageUrl", "initials", "meta", "name", "smallVariant", "displayPrivateIcon", "theme"]);
|
|
36
|
+
var rightButton = (RightButton || FollowButton) && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { ml: smallVariant ? 0.5 : 1, flexDirection: "row", alignItems: "center", justifyContent: "flex-end", children: RightButton || FollowButton }));
|
|
37
|
+
var headerName = ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flexDirection: "row", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { ellipsizeMode: "tail", numberOfLines: 1, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: theme === "light" ? "mono100" : "mono0", variant: "sm", lineHeight: "18px", style: { flexShrink: 1 }, children: name }) }), displayPrivateIcon && ((0, jsx_runtime_1.jsx)(native_1.LockIcon, { ml: "2px", width: 16, height: 16, testID: "lock-icon", fill: theme === "light" ? "mono100" : "mono0" }))] }));
|
|
38
|
+
var headerMeta = (0, react_1.useMemo)(function () {
|
|
13
39
|
if (meta) {
|
|
14
|
-
if (isValidElement(meta)) {
|
|
40
|
+
if ((0, react_1.isValidElement)(meta)) {
|
|
15
41
|
return meta;
|
|
16
42
|
}
|
|
17
|
-
return (
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(Text_1.Text, { ellipsizeMode: "tail", numberOfLines: 1, variant: "xs", color: theme === "light" ? "mono60" : "mono0", style: { flexShrink: 1 }, children: meta }));
|
|
18
44
|
}
|
|
19
45
|
return null;
|
|
20
46
|
}, [meta, theme]);
|
|
21
|
-
return (
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, __assign({ flexDirection: "row", flexWrap: "nowrap" }, restProps, { children: [!!(imageUrl || initials) && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { mr: 1, justifyContent: "center", children: (0, jsx_runtime_1.jsx)(Avatar_1.Avatar, { size: avatarSize, src: imageUrl, initials: initials, color: theme === "light" ? "mono100" : "mono0" }) })), smallVariant ? ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flexDirection: "row", justifyContent: "flex-start", flexGrow: 1, alignItems: "center", children: [headerName, (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "sm", ml: "0.5", color: theme === "light" ? "mono100" : "mono0", children: text_1.bullet }), rightButton] })) : ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { justifyContent: "space-between", width: 0, flexGrow: 1, flexDirection: "row", children: [(0, jsx_runtime_1.jsxs)(Flex_1.Flex, { alignSelf: "center", flexShrink: 1, children: [headerName, headerMeta] }), rightButton] }))] })));
|
|
22
48
|
};
|
|
49
|
+
exports.EntityHeader = EntityHeader;
|
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WithPrivateIcon = exports.WithRightButton = exports.VariantSmall = exports.Image = exports.Initials = void 0;
|
|
4
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
var EntityHeader_1 = require("./EntityHeader");
|
|
6
|
+
var Box_1 = require("../Box");
|
|
7
|
+
var Button_1 = require("../Button");
|
|
8
|
+
var Text_1 = require("../Text");
|
|
9
|
+
exports.default = {
|
|
7
10
|
title: "EntityHeader",
|
|
8
|
-
component: EntityHeader,
|
|
11
|
+
component: EntityHeader_1.EntityHeader,
|
|
9
12
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
+
var avatarSizes = ["xxs", "xs", "sm", "md"];
|
|
14
|
+
var Initials = function () {
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(Box_1.Box, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "md", children: "Avatar Sizes" }), (0, jsx_runtime_1.jsx)(Box_1.Box, { mx: 2, children: avatarSizes.map(function (size) { return ((0, jsx_runtime_1.jsxs)(Box_1.Box, { mb: 1, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { children: size }), (0, jsx_runtime_1.jsx)(EntityHeader_1.EntityHeader, { name: "Artist Name", initials: "AN", meta: "Meta stuff", avatarSize: size })] })); }) })] }));
|
|
13
16
|
};
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
exports.Initials = Initials;
|
|
18
|
+
var Image = function () {
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)(Box_1.Box, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "md", children: "Avatar Sizes" }), (0, jsx_runtime_1.jsx)(Box_1.Box, { mx: 2, children: avatarSizes.map(function (size) { return ((0, jsx_runtime_1.jsxs)(Box_1.Box, { mb: 1, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { children: size }), (0, jsx_runtime_1.jsx)(EntityHeader_1.EntityHeader, { imageUrl: "https://picsum.photos/200/200", name: "Artist Name", initials: "AN", meta: "Meta stuff", avatarSize: size })] })); }) })] }));
|
|
16
20
|
};
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
exports.Image = Image;
|
|
22
|
+
var VariantSmall = function () {
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(Box_1.Box, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "md", children: "Avatar Sizes" }), (0, jsx_runtime_1.jsx)(Box_1.Box, { mx: 2, children: avatarSizes.map(function (size) { return ((0, jsx_runtime_1.jsxs)(Box_1.Box, { mb: 1, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { children: size }), (0, jsx_runtime_1.jsx)(EntityHeader_1.EntityHeader, { imageUrl: "https://picsum.photos/200/200", name: "Artist Name", initials: "AN", meta: "Meta stuff", avatarSize: size, smallVariant: true })] })); }) })] }));
|
|
19
24
|
};
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
exports.VariantSmall = VariantSmall;
|
|
26
|
+
var WithRightButton = function () {
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(Box_1.Box, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "md", children: "Avatar Sizes" }), (0, jsx_runtime_1.jsx)(Box_1.Box, { mx: 2, children: avatarSizes.map(function (size) { return ((0, jsx_runtime_1.jsxs)(Box_1.Box, { mb: 1, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { children: size }), (0, jsx_runtime_1.jsx)(EntityHeader_1.EntityHeader, { imageUrl: "https://picsum.photos/200/200", name: "Artist Name", initials: "AN", meta: "Meta stuff", avatarSize: size, RightButton: (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", children: "Right Button" }) })] })); }) })] }));
|
|
22
28
|
};
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
exports.WithRightButton = WithRightButton;
|
|
30
|
+
var WithPrivateIcon = function () {
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)(Box_1.Box, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "md", children: "Avatar Sizes" }), (0, jsx_runtime_1.jsx)(Box_1.Box, { mx: 2, children: avatarSizes.map(function (size) { return ((0, jsx_runtime_1.jsxs)(Box_1.Box, { mb: 1, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { children: size }), (0, jsx_runtime_1.jsx)(EntityHeader_1.EntityHeader, { imageUrl: "https://picsum.photos/200/200", name: "Artist Name", initials: "AN", meta: "Meta stuff", avatarSize: size, displayPrivateIcon: true })] })); }) })] }));
|
|
25
32
|
};
|
|
33
|
+
exports.WithPrivateIcon = WithPrivateIcon;
|
|
@@ -1 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./EntityHeader"), exports);
|
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.Flex = void 0;
|
|
26
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
+
var react_1 = require("react");
|
|
28
|
+
var Box_1 = require("../Box");
|
|
29
|
+
exports.Flex = (0, react_1.forwardRef)(function (_a, ref) {
|
|
30
|
+
var backgroundColor = _a.backgroundColor, restProps = __rest(_a, ["backgroundColor"]);
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(Box_1.Box, __assign({ backgroundColor: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : "transparent" }, restProps, { ref: ref })));
|
|
32
|
+
});
|
|
@@ -1 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Flex"), exports);
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArtsyLogoHeader = void 0;
|
|
4
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
var native_1 = require("@artsy/icons/native");
|
|
6
|
+
var react_native_1 = require("react-native");
|
|
7
|
+
var Box_1 = require("../Box");
|
|
8
|
+
var Flex_1 = require("../Flex");
|
|
9
|
+
var Spacer_1 = require("../Spacer");
|
|
10
|
+
var ArtsyLogoHeader = function (_a) {
|
|
11
|
+
var _b = _a.shadow, shadow = _b === void 0 ? false : _b;
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Box_1.Box, { mt: 2, mb: 1, style: shadow ? styles.boxShadowStyle : {}, children: [(0, jsx_runtime_1.jsx)(Flex_1.Flex, { alignItems: "center", children: (0, jsx_runtime_1.jsx)(native_1.ArtsyLogoIcon, { height: 32, width: 94 }) }), (0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { x: 1 })] }), (0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { x: 2 })] }));
|
|
13
|
+
};
|
|
14
|
+
exports.ArtsyLogoHeader = ArtsyLogoHeader;
|
|
15
|
+
var styles = react_native_1.StyleSheet.create({
|
|
9
16
|
boxShadowStyle: {
|
|
10
17
|
shadowColor: "black",
|
|
11
18
|
shadowOffset: { width: 0, height: 4 },
|
|
@@ -1 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ArtsyLogoHeader"), exports);
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Histogram = void 0;
|
|
4
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
var Box_1 = require("../Box");
|
|
6
|
+
var Flex_1 = require("../Flex");
|
|
7
|
+
var BAR_WIDTH = 2;
|
|
8
|
+
var BAR_ROUNDNESS = 10;
|
|
9
|
+
var isSelected = function (value, min, max) {
|
|
7
10
|
return value >= min && value <= max;
|
|
8
11
|
};
|
|
9
|
-
|
|
12
|
+
var getPercentByEntity = function (maxValue, entityCount) {
|
|
10
13
|
if (maxValue === 0) {
|
|
11
14
|
return 100;
|
|
12
15
|
}
|
|
13
16
|
return (100 / maxValue) * entityCount;
|
|
14
17
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
var Histogram = function (_a) {
|
|
19
|
+
var bars = _a.bars, selectedRange = _a.selectedRange;
|
|
20
|
+
var maxValue = Math.max.apply(Math, bars.map(function (bar) { return bar.count; }));
|
|
21
|
+
var min = selectedRange[0], max = selectedRange[1];
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { height: 110, flexDirection: "row", justifyContent: "space-between", alignItems: "flex-end", children: bars.map(function (entity, index) {
|
|
23
|
+
var percent = getPercentByEntity(maxValue, entity.count);
|
|
24
|
+
var selected = isSelected(entity.value, min, max);
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(Box_1.Box, { height: "".concat(percent, "%"), bg: selected ? "blue100" : "mono15", width: BAR_WIDTH, borderTopLeftRadius: BAR_ROUNDNESS, borderTopRightRadius: BAR_ROUNDNESS }, "bar-".concat(index)));
|
|
22
26
|
}) }));
|
|
23
27
|
};
|
|
28
|
+
exports.Histogram = Histogram;
|
|
@@ -1 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Histogram"), exports);
|
|
@@ -1,35 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.ImageSkeleton = exports.Image = void 0;
|
|
29
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
30
|
+
var react_native_fast_image_1 = __importDefault(require("@d11/react-native-fast-image"));
|
|
31
|
+
var react_1 = require("react");
|
|
32
|
+
var react_native_blurhash_1 = require("react-native-blurhash");
|
|
33
|
+
var getImageURL_1 = require("./helpers/getImageURL");
|
|
34
|
+
var hooks_1 = require("../../utils/hooks");
|
|
35
|
+
var useScreenDimensions_1 = require("../../utils/hooks/useScreenDimensions");
|
|
36
|
+
var Flex_1 = require("../Flex");
|
|
37
|
+
var Skeleton_1 = require("../Skeleton");
|
|
38
|
+
exports.Image = (0, react_1.memo)(function (_a) {
|
|
39
|
+
var aspectRatio = _a.aspectRatio, width = _a.width, height = _a.height, _b = _a.performResize, performResize = _b === void 0 ? true : _b, src = _a.src, style = _a.style, resizeMode = _a.resizeMode, geminiResizeMode = _a.geminiResizeMode, _c = _a.showLoadingState, showLoadingState = _c === void 0 ? false : _c, blurhash = _a.blurhash, flexProps = __rest(_a, ["aspectRatio", "width", "height", "performResize", "src", "style", "resizeMode", "geminiResizeMode", "showLoadingState", "blurhash"]);
|
|
40
|
+
var _d = (0, react_1.useState)(true), isLoading = _d[0], setIsLoading = _d[1];
|
|
41
|
+
var dimensions = useImageDimensions({ aspectRatio: aspectRatio, width: width, height: height });
|
|
42
|
+
var color = (0, hooks_1.useColor)();
|
|
14
43
|
if (showLoadingState) {
|
|
15
44
|
// Keep logic as small as possible here to save on performance
|
|
16
|
-
return
|
|
45
|
+
return (0, jsx_runtime_1.jsx)(Flex_1.Flex, __assign({ backgroundColor: "mono10" }, dimensions, { style: { position: "absolute" } }));
|
|
17
46
|
}
|
|
18
|
-
return (
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, __assign({ position: "relative" }, flexProps, { style: __assign({}, dimensions), children: [(0, jsx_runtime_1.jsx)(react_native_fast_image_1.default, { style: [
|
|
19
48
|
dimensions,
|
|
20
49
|
style,
|
|
21
50
|
// If we have a blurhash, we don't want to show a background color
|
|
22
51
|
// That might flash before the image loads
|
|
23
52
|
{ backgroundColor: blurhash ? "transparent" : color("mono30") },
|
|
24
|
-
], resizeMode: resizeMode, onLoadEnd: ()
|
|
25
|
-
priority:
|
|
26
|
-
uri: getImageURL({ src, dimensions, geminiResizeMode, performResize }),
|
|
27
|
-
} }), isLoading && (
|
|
53
|
+
], resizeMode: resizeMode, onLoadEnd: function () { return setIsLoading(false); }, source: {
|
|
54
|
+
priority: react_native_fast_image_1.default.priority.normal,
|
|
55
|
+
uri: (0, getImageURL_1.getImageURL)({ src: src, dimensions: dimensions, geminiResizeMode: geminiResizeMode, performResize: performResize }),
|
|
56
|
+
} }), isLoading && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { style: [dimensions, { position: "absolute" }], children: (0, jsx_runtime_1.jsx)(exports.ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }) }))] })));
|
|
28
57
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
58
|
+
var useImageDimensions = function (props) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
var screenDimensions = (0, useScreenDimensions_1.useScreenDimensions)();
|
|
61
|
+
var imageWidth = (_a = props.width) !== null && _a !== void 0 ? _a : screenDimensions.width;
|
|
62
|
+
var imageHeight;
|
|
33
63
|
if (props.height) {
|
|
34
64
|
imageHeight = props.height;
|
|
35
65
|
}
|
|
@@ -37,18 +67,20 @@ const useImageDimensions = (props) => {
|
|
|
37
67
|
if (!props.aspectRatio) {
|
|
38
68
|
console.error("[Image] Error: `aspectRatio` is required if `height` is not provided.");
|
|
39
69
|
}
|
|
40
|
-
|
|
70
|
+
var aspectRatio = (_b = props.aspectRatio) !== null && _b !== void 0 ? _b : 1;
|
|
41
71
|
imageHeight = imageWidth / aspectRatio;
|
|
42
72
|
}
|
|
43
|
-
|
|
73
|
+
var dimensions = {
|
|
44
74
|
width: imageWidth,
|
|
45
75
|
height: imageHeight,
|
|
46
76
|
};
|
|
47
77
|
return dimensions;
|
|
48
78
|
};
|
|
49
|
-
|
|
79
|
+
var ImageSkeleton = function (_a) {
|
|
80
|
+
var dimensions = _a.dimensions, blurhash = _a.blurhash, style = _a.style;
|
|
50
81
|
if (!!blurhash) {
|
|
51
|
-
return (
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, __assign({ backgroundColor: "mono10" }, dimensions, { style: style, children: (0, jsx_runtime_1.jsx)(react_native_blurhash_1.Blurhash, { blurhash: blurhash, style: { flex: 1 }, decodeWidth: 16, decodeHeight: 16, decodeAsync: true }) })));
|
|
52
83
|
}
|
|
53
|
-
return (
|
|
84
|
+
return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { style: style, children: (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { children: (0, jsx_runtime_1.jsx)(Skeleton_1.SkeletonBox, __assign({}, dimensions)) }) }));
|
|
54
85
|
};
|
|
86
|
+
exports.ImageSkeleton = ImageSkeleton;
|
|
@@ -1,44 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WithoutAutomaticResizingBlurhash = exports.WithAspectRatioBlurhash = exports.WithWidthAndHeightBlurhash = exports.WithDefaultFallbackScreenWidthBlurhash = exports.WithPercentageWidthAndHeight = exports.WithoutAutomaticResizing = exports.WithAspectRatio = exports.WithWidthAndHeight = exports.WithDefaultFallbackScreenWidth = void 0;
|
|
4
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
var Image_1 = require("./Image");
|
|
6
|
+
var Flex_1 = require("../Flex");
|
|
7
|
+
exports.default = {
|
|
5
8
|
title: "Image",
|
|
6
9
|
};
|
|
7
|
-
|
|
8
|
-
WithDefaultFallbackScreenWidth
|
|
10
|
+
var WithDefaultFallbackScreenWidth = function () { return ((0, jsx_runtime_1.jsx)(Image_1.Image, { aspectRatio: 0.62, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })); };
|
|
11
|
+
exports.WithDefaultFallbackScreenWidth = WithDefaultFallbackScreenWidth;
|
|
12
|
+
exports.WithDefaultFallbackScreenWidth.story = {
|
|
9
13
|
name: "With default fallback screen width",
|
|
10
14
|
};
|
|
11
|
-
|
|
12
|
-
WithWidthAndHeight
|
|
15
|
+
var WithWidthAndHeight = function () { return ((0, jsx_runtime_1.jsx)(Image_1.Image, { width: 250, height: 400, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })); };
|
|
16
|
+
exports.WithWidthAndHeight = WithWidthAndHeight;
|
|
17
|
+
exports.WithWidthAndHeight.story = {
|
|
13
18
|
name: "With width and height",
|
|
14
19
|
};
|
|
15
|
-
|
|
16
|
-
WithAspectRatio
|
|
20
|
+
var WithAspectRatio = function () { return ((0, jsx_runtime_1.jsx)(Image_1.Image, { width: 250, aspectRatio: 0.62, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })); };
|
|
21
|
+
exports.WithAspectRatio = WithAspectRatio;
|
|
22
|
+
exports.WithAspectRatio.story = {
|
|
17
23
|
name: "With aspect ratio",
|
|
18
24
|
};
|
|
19
|
-
|
|
20
|
-
WithoutAutomaticResizing
|
|
25
|
+
var WithoutAutomaticResizing = function () { return ((0, jsx_runtime_1.jsx)(Image_1.Image, { aspectRatio: 0.62, performResize: false, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })); };
|
|
26
|
+
exports.WithoutAutomaticResizing = WithoutAutomaticResizing;
|
|
27
|
+
exports.WithoutAutomaticResizing.story = {
|
|
21
28
|
name: "Without automatic resizing",
|
|
22
29
|
};
|
|
23
|
-
|
|
24
|
-
return (
|
|
30
|
+
var WithPercentageWidthAndHeight = function () {
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flexDirection: "row", flex: 1, children: [(0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, style: { aspectRatio: 0.69 }, children: (0, jsx_runtime_1.jsx)(Image_1.Image, { src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg", height: 260, width: 180, style: { width: "100%", height: "100%" } }) }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, style: { aspectRatio: 1 }, children: (0, jsx_runtime_1.jsx)(Image_1.Image, { src: "https://i.imgur.com/b9IZinu.gif", width: 200, height: 200, style: { width: "100%", height: "100%" } }) }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, style: { aspectRatio: 1.2 }, children: (0, jsx_runtime_1.jsx)(Image_1.Image, { width: 200, height: 240, src: "https://i.imgur.com/non-existing-image.gif", style: { width: "100%", height: "100%" } }) })] }));
|
|
25
32
|
};
|
|
26
|
-
WithPercentageWidthAndHeight
|
|
33
|
+
exports.WithPercentageWidthAndHeight = WithPercentageWidthAndHeight;
|
|
34
|
+
exports.WithPercentageWidthAndHeight.story = {
|
|
27
35
|
name: "With percentage width and height",
|
|
28
36
|
};
|
|
29
|
-
|
|
30
|
-
WithDefaultFallbackScreenWidthBlurhash
|
|
37
|
+
var WithDefaultFallbackScreenWidthBlurhash = function () { return ((0, jsx_runtime_1.jsx)(Image_1.Image, { aspectRatio: 0.62, blurhash: "LXK,+3H#yArKH~bGx:tM.atxM*k9", src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })); };
|
|
38
|
+
exports.WithDefaultFallbackScreenWidthBlurhash = WithDefaultFallbackScreenWidthBlurhash;
|
|
39
|
+
exports.WithDefaultFallbackScreenWidthBlurhash.story = {
|
|
31
40
|
name: "With default fallback screen width + blurhash",
|
|
32
41
|
};
|
|
33
|
-
|
|
34
|
-
WithWidthAndHeightBlurhash
|
|
42
|
+
var WithWidthAndHeightBlurhash = function () { return ((0, jsx_runtime_1.jsx)(Image_1.Image, { blurhash: "LXK,+3H#yArKH~bGx:tM.atxM*k9", width: 250, height: 400, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })); };
|
|
43
|
+
exports.WithWidthAndHeightBlurhash = WithWidthAndHeightBlurhash;
|
|
44
|
+
exports.WithWidthAndHeightBlurhash.story = {
|
|
35
45
|
name: "With width and height + blurhash",
|
|
36
46
|
};
|
|
37
|
-
|
|
38
|
-
WithAspectRatioBlurhash
|
|
47
|
+
var WithAspectRatioBlurhash = function () { return ((0, jsx_runtime_1.jsx)(Image_1.Image, { blurhash: "LXK,+3H#yArKH~bGx:tM.atxM*k9", width: 250, aspectRatio: 0.62, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })); };
|
|
48
|
+
exports.WithAspectRatioBlurhash = WithAspectRatioBlurhash;
|
|
49
|
+
exports.WithAspectRatioBlurhash.story = {
|
|
39
50
|
name: "With aspect ratio + blurhash",
|
|
40
51
|
};
|
|
41
|
-
|
|
42
|
-
WithoutAutomaticResizingBlurhash
|
|
52
|
+
var WithoutAutomaticResizingBlurhash = function () { return ((0, jsx_runtime_1.jsx)(Image_1.Image, { blurhash: "LXK,+3H#yArKH~bGx:tM.atxM*k9", aspectRatio: 0.62, performResize: false, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })); };
|
|
53
|
+
exports.WithoutAutomaticResizingBlurhash = WithoutAutomaticResizingBlurhash;
|
|
54
|
+
exports.WithoutAutomaticResizingBlurhash.story = {
|
|
43
55
|
name: "Without automatic resizing + blurhash",
|
|
44
56
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var getImageURL_1 = require("../helpers/getImageURL");
|
|
4
|
+
describe("getImageURL", function () {
|
|
5
|
+
it("should return the original url if performResize is true", function () {
|
|
6
|
+
var url = (0, getImageURL_1.getImageURL)({
|
|
5
7
|
src: "https://example.com/image.jpg",
|
|
6
8
|
dimensions: { width: 100, height: 100 },
|
|
7
9
|
geminiResizeMode: "fill",
|
|
@@ -9,8 +11,8 @@ describe("getImageURL", () => {
|
|
|
9
11
|
});
|
|
10
12
|
expect(url).toBe("https://d7hftxdivxxvm.cloudfront.net/?height=200&quality=80&resize_to=fill&src=https%3A%2F%2Fexample.com%2Fimage.jpg&width=200");
|
|
11
13
|
});
|
|
12
|
-
it("should return the original url if performResize is true and the url is already resized", ()
|
|
13
|
-
|
|
14
|
+
it("should return the original url if performResize is true and the url is already resized", function () {
|
|
15
|
+
var url = (0, getImageURL_1.getImageURL)({
|
|
14
16
|
src: "https://d7hftxdivxxvm.cloudfront.net/?height=100&quality=80&resize_to=fill&src=https%3A%2F%2Fexample.com%2Fimage.jpg&width=100",
|
|
15
17
|
dimensions: { width: 100, height: 100 },
|
|
16
18
|
geminiResizeMode: "fill",
|
|
@@ -18,8 +20,8 @@ describe("getImageURL", () => {
|
|
|
18
20
|
});
|
|
19
21
|
expect(url).toBe("https://d7hftxdivxxvm.cloudfront.net/?height=100&quality=80&resize_to=fill&src=https%3A%2F%2Fexample.com%2Fimage.jpg&width=100");
|
|
20
22
|
});
|
|
21
|
-
it("should return the original url if performResize is false", ()
|
|
22
|
-
|
|
23
|
+
it("should return the original url if performResize is false", function () {
|
|
24
|
+
var url = (0, getImageURL_1.getImageURL)({
|
|
23
25
|
src: "https://example.com/image.jpg",
|
|
24
26
|
dimensions: { width: 100, height: 100 },
|
|
25
27
|
geminiResizeMode: "fill",
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getImageURL = void 0;
|
|
4
|
+
var react_native_1 = require("react-native");
|
|
5
|
+
var createGeminiUrl_1 = require("../../../utils/createGeminiUrl");
|
|
3
6
|
/**
|
|
4
7
|
* This method retuns a valid image url to be used within an Image Component
|
|
5
8
|
* It handles the case of resizing the image on the fly using Gemini
|
|
6
9
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
var getImageURL = function (_a) {
|
|
11
|
+
var src = _a.src, dimensions = _a.dimensions, geminiResizeMode = _a.geminiResizeMode, performResize = _a.performResize;
|
|
12
|
+
var uri = src;
|
|
9
13
|
if (performResize) {
|
|
10
|
-
if (!imageAlreadyResized(src)) {
|
|
11
|
-
uri = createGeminiUrl({
|
|
14
|
+
if (!(0, createGeminiUrl_1.imageAlreadyResized)(src)) {
|
|
15
|
+
uri = (0, createGeminiUrl_1.createGeminiUrl)({
|
|
12
16
|
imageURL: src,
|
|
13
|
-
width: PixelRatio.getPixelSizeForLayoutSize(dimensions.width),
|
|
14
|
-
height: PixelRatio.getPixelSizeForLayoutSize(dimensions.height),
|
|
17
|
+
width: react_native_1.PixelRatio.getPixelSizeForLayoutSize(dimensions.width),
|
|
18
|
+
height: react_native_1.PixelRatio.getPixelSizeForLayoutSize(dimensions.height),
|
|
15
19
|
resizeMode: geminiResizeMode,
|
|
16
20
|
});
|
|
17
21
|
}
|
|
@@ -23,3 +27,4 @@ export const getImageURL = ({ src, dimensions, geminiResizeMode, performResize,
|
|
|
23
27
|
}
|
|
24
28
|
return uri;
|
|
25
29
|
};
|
|
30
|
+
exports.getImageURL = getImageURL;
|