jp-composter 0.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.
- package/dist/index.d.mts +997 -0
- package/dist/index.d.ts +997 -0
- package/dist/index.js +36837 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +36778 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
- package/src/SliceUI/IconMoon.tsx +33 -0
- package/src/SliceUI/assets/Anatomy diagram copy.svg +19 -0
- package/src/SliceUI/assets/Anatomy diagram.svg +19 -0
- package/src/SliceUI/assets/Anatomycheck.svg +15 -0
- package/src/SliceUI/assets/Anatomyinput.svg +32 -0
- package/src/SliceUI/assets/Checkbox.jpg +0 -0
- package/src/SliceUI/assets/Diagram copy.svg +15 -0
- package/src/SliceUI/assets/Diagram.jpg +0 -0
- package/src/SliceUI/assets/Diagram.svg +15 -0
- package/src/SliceUI/assets/Frame 5 copy.png +0 -0
- package/src/SliceUI/assets/Frame 5.png +0 -0
- package/src/SliceUI/assets/Frame 65.png +0 -0
- package/src/SliceUI/assets/Frame_65.png +0 -0
- package/src/SliceUI/assets/Icon copy.svg +3 -0
- package/src/SliceUI/assets/Icon.svg +3 -0
- package/src/SliceUI/assets/Icon_Bridging copy.svg +39 -0
- package/src/SliceUI/assets/Icon_Bridging.svg +39 -0
- package/src/SliceUI/assets/Icon_Consistent copy.svg +39 -0
- package/src/SliceUI/assets/Icon_Consistent.svg +39 -0
- package/src/SliceUI/assets/Icon_Plug copy.svg +38 -0
- package/src/SliceUI/assets/Icon_Plug.svg +38 -0
- package/src/SliceUI/assets/Icon_Reusable copy.svg +39 -0
- package/src/SliceUI/assets/Icon_Reusable.svg +39 -0
- package/src/SliceUI/assets/Layer_1.png +0 -0
- package/src/SliceUI/assets/accessibility.png +0 -0
- package/src/SliceUI/assets/accessibility.svg +1 -0
- package/src/SliceUI/assets/addon-library.png +0 -0
- package/src/SliceUI/assets/assets.png +0 -0
- package/src/SliceUI/assets/avif-test-image.avif +0 -0
- package/src/SliceUI/assets/bridging.svg +13 -0
- package/src/SliceUI/assets/consistent.svg +11 -0
- package/src/SliceUI/assets/context.png +0 -0
- package/src/SliceUI/assets/discord.svg +1 -0
- package/src/SliceUI/assets/docs.png +0 -0
- package/src/SliceUI/assets/figma-plugin.png +0 -0
- package/src/SliceUI/assets/github.svg +1 -0
- package/src/SliceUI/assets/resources/Anatomy diagram.svg +19 -0
- package/src/SliceUI/assets/resources/Anatomycheck.svg +15 -0
- package/src/SliceUI/assets/resources/Anatomyinput.svg +32 -0
- package/src/SliceUI/assets/resources/Diagram.svg +15 -0
- package/src/SliceUI/assets/resources/Frame 5.png +0 -0
- package/src/SliceUI/assets/resources/Frame 65.png +0 -0
- package/src/SliceUI/assets/resources/Icon.svg +3 -0
- package/src/SliceUI/assets/resources/Icon_Bridging.svg +39 -0
- package/src/SliceUI/assets/resources/Icon_Consistent.svg +39 -0
- package/src/SliceUI/assets/resources/Icon_Plug.svg +38 -0
- package/src/SliceUI/assets/resources/Icon_Reusable.svg +39 -0
- package/src/SliceUI/assets/resources/fonts/FontIcon.json +150 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Black.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Bold.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Heavy.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Medium.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Regular.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato.woff2 +0 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.eot +0 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.svg +601 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.woff +0 -0
- package/src/SliceUI/assets/resources/fonts/selection.json +1 -0
- package/src/SliceUI/assets/share.png +0 -0
- package/src/SliceUI/assets/styling.png +0 -0
- package/src/SliceUI/assets/testing.png +0 -0
- package/src/SliceUI/assets/theming.png +0 -0
- package/src/SliceUI/assets/tutorials.svg +1 -0
- package/src/SliceUI/assets/youtube.svg +1 -0
- package/src/SliceUI/automation/helper.ts +29 -0
- package/src/SliceUI/avatar/Avatar.tsx +237 -0
- package/src/SliceUI/avatar/Token.ts +116 -0
- package/src/SliceUI/avatar/Type.ts +36 -0
- package/src/SliceUI/avatar/helper.ts +53 -0
- package/src/SliceUI/badge/Badge.tsx +308 -0
- package/src/SliceUI/badge/Token.ts +202 -0
- package/src/SliceUI/badge/Type.ts +46 -0
- package/src/SliceUI/badge/helper.ts +39 -0
- package/src/SliceUI/button/Button.tsx +243 -0
- package/src/SliceUI/button/Token.ts +138 -0
- package/src/SliceUI/button/Type.ts +34 -0
- package/src/SliceUI/button/helper.ts +125 -0
- package/src/SliceUI/checkbox/Checkbox.tsx +176 -0
- package/src/SliceUI/checkbox/Token.ts +128 -0
- package/src/SliceUI/checkbox/Type.ts +35 -0
- package/src/SliceUI/chip/Chip.tsx +290 -0
- package/src/SliceUI/chip/Token.ts +151 -0
- package/src/SliceUI/chip/Type.ts +43 -0
- package/src/SliceUI/chip/helper.ts +40 -0
- package/src/SliceUI/colors/Pallete.ts +151 -0
- package/src/SliceUI/colors/Token.ts +110 -0
- package/src/SliceUI/colors/Type.ts +56 -0
- package/src/SliceUI/contextProvider/context.tsx +108 -0
- package/src/SliceUI/divider/Divider.tsx +109 -0
- package/src/SliceUI/divider/Token.ts +18 -0
- package/src/SliceUI/divider/Type.ts +26 -0
- package/src/SliceUI/icon/CustomIcon.ts +4 -0
- package/src/SliceUI/icon/IcoMoonIcon.tsx +11 -0
- package/src/SliceUI/icon/Icon.tsx +38 -0
- package/src/SliceUI/icon/Token.ts +14 -0
- package/src/SliceUI/icon/Type.ts +13 -0
- package/src/SliceUI/icon/selection.json +1 -0
- package/src/SliceUI/input/Input.tsx +573 -0
- package/src/SliceUI/input/ToDo.md +99 -0
- package/src/SliceUI/input/Token.ts +372 -0
- package/src/SliceUI/input/Type.ts +109 -0
- package/src/SliceUI/input/components/InputPortal.tsx +211 -0
- package/src/SliceUI/input/components/NativeBottomSheet.tsx +296 -0
- package/src/SliceUI/input/components/SelectChip.tsx +185 -0
- package/src/SliceUI/input/components/SelectList.tsx +173 -0
- package/src/SliceUI/input/components/SelectListItem.tsx +377 -0
- package/src/SliceUI/input/components/SelectScrollbarStyle.ts +44 -0
- package/src/SliceUI/input/hooks/useCustomScrollbar.ts +17 -0
- package/src/SliceUI/input/hooks/useInputState.ts +41 -0
- package/src/SliceUI/input/hooks/useLabelAnimation.ts +132 -0
- package/src/SliceUI/input/hooks/useOutsideClick.ts +38 -0
- package/src/SliceUI/input/hooks/useSelectLogic.ts +338 -0
- package/src/SliceUI/input/utils/inputUtils.ts +120 -0
- package/src/SliceUI/input/utils/selectUtils.ts +85 -0
- package/src/SliceUI/input/utils/styleUtils.ts +50 -0
- package/src/SliceUI/input/variants/CurrencyInput/CurrencyInput.tsx +16 -0
- package/src/SliceUI/input/variants/CurrencyInput/NativeCurrencyInput.tsx +181 -0
- package/src/SliceUI/input/variants/CurrencyInput/WebCurrencyInput.tsx +163 -0
- package/src/SliceUI/input/variants/CurrencyInput/types.ts +17 -0
- package/src/SliceUI/input/variants/PhoneInput/NativePhoneInput.tsx +189 -0
- package/src/SliceUI/input/variants/PhoneInput/PhoneInput.tsx +16 -0
- package/src/SliceUI/input/variants/PhoneInput/WebPhoneInput.tsx +291 -0
- package/src/SliceUI/input/variants/PhoneInput/types.ts +22 -0
- package/src/SliceUI/input/variants/SelectInput/SelectInput.tsx +407 -0
- package/src/SliceUI/input/variants/SelectInput/types.ts +34 -0
- package/src/SliceUI/input/variants/TextInput.tsx +68 -0
- package/src/SliceUI/layout/Box.tsx +38 -0
- package/src/SliceUI/layout/Center.tsx +38 -0
- package/src/SliceUI/layout/Divider.tsx +37 -0
- package/src/SliceUI/layout/Grid.tsx +75 -0
- package/src/SliceUI/layout/PageContainer.tsx +60 -0
- package/src/SliceUI/layout/ScrollContainer.tsx +72 -0
- package/src/SliceUI/layout/Spacer.tsx +54 -0
- package/src/SliceUI/layout/Stack.tsx +97 -0
- package/src/SliceUI/layout/StickyHeader.tsx +71 -0
- package/src/SliceUI/radio/RadioButton.tsx +130 -0
- package/src/SliceUI/radio/Token.ts +197 -0
- package/src/SliceUI/radio/Type.ts +35 -0
- package/src/SliceUI/react-native.config.js +3 -0
- package/src/SliceUI/responsive/Type.ts +7 -0
- package/src/SliceUI/responsive/helper.ts +53 -0
- package/src/SliceUI/switch/Switch.tsx +119 -0
- package/src/SliceUI/switch/Token.ts +205 -0
- package/src/SliceUI/switch/Type.ts +26 -0
- package/src/SliceUI/tab/TabItem.tsx +204 -0
- package/src/SliceUI/tab/Tabs.tsx +110 -0
- package/src/SliceUI/tab/Token.ts +282 -0
- package/src/SliceUI/tab/Type.ts +66 -0
- package/src/SliceUI/tab/helper.ts +53 -0
- package/src/SliceUI/table/Table.tsx +388 -0
- package/src/SliceUI/table/TableCell.tsx +158 -0
- package/src/SliceUI/table/TableFooter.tsx +353 -0
- package/src/SliceUI/table/TableHeader.tsx +247 -0
- package/src/SliceUI/table/TableRow.tsx +218 -0
- package/src/SliceUI/table/Token.ts +252 -0
- package/src/SliceUI/table/Type.ts +213 -0
- package/src/SliceUI/table/helper.ts +376 -0
- package/src/SliceUI/table/index.ts +53 -0
- package/src/SliceUI/theme/dummyColors.tsx +7 -0
- package/src/SliceUI/theme/theme.ts +107 -0
- package/src/SliceUI/typography/BaseTypographyToken.ts +62 -0
- package/src/SliceUI/typography/FoundationToken.ts +48 -0
- package/src/SliceUI/typography/Token.ts +228 -0
- package/src/SliceUI/typography/Type.ts +20 -0
- package/src/SliceUI/typography/Typography.tsx +99 -0
- package/src/SliceUI/values/BorderRadius.ts +17 -0
- package/src/SliceUI/values/BorderWidth.ts +7 -0
- package/src/SliceUI/values/Dimension.ts +35 -0
- package/src/SliceUI/values/IconSizes.ts +13 -0
- package/src/SliceUI/values/Spacing.ts +22 -0
- package/src/declarations.d.ts +8 -0
- package/src/index.tsx +119 -0
- package/src/stories/Colors.mdx +1418 -0
- package/src/stories/Dimensions.mdx +60 -0
- package/src/stories/GetStarted.mdx +90 -0
- package/src/stories/Introduction.mdx +136 -0
- package/src/stories/Shape.mdx +126 -0
- package/src/stories/Spacing.mdx +104 -0
- package/src/stories/Typography.mdx +454 -0
- package/src/stories/Utils.mdx +277 -0
- package/src/stories/story-components/AddIcon.js +13 -0
- package/src/stories/story-components/RectangleWithBox.jsx +51 -0
- package/src/stories/story-components/RoundedRectangle.jsx +18 -0
- package/src/stories/story-components/RoundedWithWhiteInside.jsx +33 -0
- package/src/stories/story-components/WhiteRoundedRectangle.jsx +107 -0
- package/src/stories/story-components/svgPaths.js +126 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="33" height="32" fill="none" viewBox="0 0 33 32"><g clip-path="url(#clip0_10031_177597)"><path fill="#B7F0EF" fill-rule="evenodd" d="M17 7.87059C17 6.48214 17.9812 5.28722 19.3431 5.01709L29.5249 2.99755C31.3238 2.64076 33 4.01717 33 5.85105V22.1344C33 23.5229 32.0188 24.7178 30.6569 24.9879L20.4751 27.0074C18.6762 27.3642 17 25.9878 17 24.1539L17 7.87059Z" clip-rule="evenodd" opacity=".7"/><path fill="#87E6E5" fill-rule="evenodd" d="M1 5.85245C1 4.01857 2.67623 2.64215 4.47507 2.99895L14.6569 5.01848C16.0188 5.28861 17 6.48354 17 7.87198V24.1553C17 25.9892 15.3238 27.3656 13.5249 27.0088L3.34311 24.9893C1.98119 24.7192 1 23.5242 1 22.1358V5.85245Z" clip-rule="evenodd"/><path fill="#61C1FD" fill-rule="evenodd" d="M15.543 5.71289C15.543 5.71289 16.8157 5.96289 17.4002 6.57653C17.9847 7.19016 18.4521 9.03107 18.4521 9.03107C18.4521 9.03107 18.4521 25.1106 18.4521 26.9629C18.4521 28.8152 19.3775 31.4174 19.3775 31.4174L17.4002 28.8947L16.2575 31.4174C16.2575 31.4174 15.543 29.0765 15.543 27.122C15.543 25.1674 15.543 5.71289 15.543 5.71289Z" clip-rule="evenodd"/></g><defs><clipPath id="clip0_10031_177597"><rect width="32" height="32" fill="#fff" transform="translate(0.5)"/></clipPath></defs></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="none" viewBox="0 0 32 32"><path fill="#ED1D24" d="M31.3313 8.44657C30.9633 7.08998 29.8791 6.02172 28.5022 5.65916C26.0067 5.00026 16 5.00026 16 5.00026C16 5.00026 5.99333 5.00026 3.4978 5.65916C2.12102 6.02172 1.03665 7.08998 0.668678 8.44657C0 10.9053 0 16.0353 0 16.0353C0 16.0353 0 21.1652 0.668678 23.6242C1.03665 24.9806 2.12102 26.0489 3.4978 26.4116C5.99333 27.0703 16 27.0703 16 27.0703C16 27.0703 26.0067 27.0703 28.5022 26.4116C29.8791 26.0489 30.9633 24.9806 31.3313 23.6242C32 21.1652 32 16.0353 32 16.0353C32 16.0353 32 10.9053 31.3313 8.44657Z"/><path fill="#fff" d="M12.7266 20.6934L21.0902 16.036L12.7266 11.3781V20.6934Z"/></svg>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const BASE_ID = 'AK_';
|
|
4
|
+
export const VIEW_DISABLED = '_Disabled';
|
|
5
|
+
export const VIEW_SELECTED = '_Selected';
|
|
6
|
+
|
|
7
|
+
export const setTestId = (
|
|
8
|
+
baseId: string,
|
|
9
|
+
screenName: string | null | undefined,
|
|
10
|
+
id: string | null | undefined | number,
|
|
11
|
+
className: string | null | undefined = null
|
|
12
|
+
) => {
|
|
13
|
+
try {
|
|
14
|
+
return Platform.OS === 'android'
|
|
15
|
+
? {
|
|
16
|
+
accessible: true,
|
|
17
|
+
accessibilityLabel: BASE_ID + screenName + '_' + id,
|
|
18
|
+
}
|
|
19
|
+
: {
|
|
20
|
+
testID: baseId + screenName + '_' + id,
|
|
21
|
+
...(className
|
|
22
|
+
? { dataSet: { class: className } }
|
|
23
|
+
: { dataSet: { class: id } }),
|
|
24
|
+
};
|
|
25
|
+
} catch (e) {
|
|
26
|
+
// Adding automation logging failed
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
};
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import React, {useMemo} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
type ViewStyle,
|
|
6
|
+
type TextStyle,
|
|
7
|
+
Image,
|
|
8
|
+
type ImageSourcePropType,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import {useSliceTheme} from '../contextProvider/context';
|
|
11
|
+
import {
|
|
12
|
+
getBackgroundColor,
|
|
13
|
+
getIconColor,
|
|
14
|
+
getTextColor,
|
|
15
|
+
getInitials,
|
|
16
|
+
} from './helper';
|
|
17
|
+
import {resolveVariant} from '../responsive/helper';
|
|
18
|
+
import type {SizeType, AvatarType} from './Type';
|
|
19
|
+
import {AVATAR_TYPES} from './Type';
|
|
20
|
+
import {setTestId} from '../automation/helper';
|
|
21
|
+
import type {ExtendedTheme} from '../colors/Type';
|
|
22
|
+
import Typography from '../typography/Typography';
|
|
23
|
+
import IconMoon from '../IconMoon';
|
|
24
|
+
import FontIcon from '../assets/resources/fonts/FontIcon.json';
|
|
25
|
+
|
|
26
|
+
interface AvatarProps {
|
|
27
|
+
screenName?: string;
|
|
28
|
+
id?: number | string;
|
|
29
|
+
type?: AvatarType;
|
|
30
|
+
size?: SizeType;
|
|
31
|
+
name?: string;
|
|
32
|
+
imageUri?: string;
|
|
33
|
+
imageSource?: ImageSourcePropType;
|
|
34
|
+
avatarStyle?: ViewStyle;
|
|
35
|
+
textStyle?: TextStyle;
|
|
36
|
+
onPress?: () => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const Avatar: React.FC<AvatarProps> = ({
|
|
40
|
+
screenName,
|
|
41
|
+
id,
|
|
42
|
+
type = 'default',
|
|
43
|
+
size = 'medium',
|
|
44
|
+
name,
|
|
45
|
+
imageUri,
|
|
46
|
+
imageSource,
|
|
47
|
+
avatarStyle,
|
|
48
|
+
textStyle,
|
|
49
|
+
onPress: _onPress,
|
|
50
|
+
}) => {
|
|
51
|
+
const {theme, deviceBreakpoint} = useSliceTheme();
|
|
52
|
+
const {isDebugBuildType, automationBaseid} = theme;
|
|
53
|
+
|
|
54
|
+
const responsiveSize = useMemo(
|
|
55
|
+
() => resolveVariant(size, deviceBreakpoint),
|
|
56
|
+
[size, deviceBreakpoint],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const avatarTheme = useMemo(
|
|
60
|
+
() => theme.avatarStyles[responsiveSize as SizeType],
|
|
61
|
+
[responsiveSize, theme.avatarStyles],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const backgroundColor = useMemo(
|
|
65
|
+
() => getBackgroundColor(type as AvatarType, theme as ExtendedTheme),
|
|
66
|
+
[type, theme],
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const iconColor = useMemo(
|
|
70
|
+
() => getIconColor(type as AvatarType, theme as ExtendedTheme),
|
|
71
|
+
[type, theme],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const textColor = useMemo(
|
|
75
|
+
() => getTextColor(type as AvatarType, theme as ExtendedTheme),
|
|
76
|
+
[type, theme],
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const initials = useMemo(() => getInitials(name || ''), [name]);
|
|
80
|
+
|
|
81
|
+
const typographyVariant = useMemo(() => {
|
|
82
|
+
switch (responsiveSize) {
|
|
83
|
+
case 'small':
|
|
84
|
+
return 'captionBold';
|
|
85
|
+
case 'medium':
|
|
86
|
+
return 'captionBold';
|
|
87
|
+
case 'large':
|
|
88
|
+
return 'body2Bold';
|
|
89
|
+
case 'xLarge':
|
|
90
|
+
return 'body1Bold';
|
|
91
|
+
default:
|
|
92
|
+
return 'captionBold';
|
|
93
|
+
}
|
|
94
|
+
}, [responsiveSize]);
|
|
95
|
+
|
|
96
|
+
const combinedAvatarStyle = useMemo(
|
|
97
|
+
() =>
|
|
98
|
+
StyleSheet.flatten([
|
|
99
|
+
styles.baseAvatar,
|
|
100
|
+
avatarTheme,
|
|
101
|
+
{
|
|
102
|
+
backgroundColor,
|
|
103
|
+
// Remove padding for image avatars so image fills the full space
|
|
104
|
+
padding: type === 'image' ? 0 : avatarTheme.padding,
|
|
105
|
+
},
|
|
106
|
+
avatarStyle,
|
|
107
|
+
]),
|
|
108
|
+
[avatarTheme, backgroundColor, avatarStyle, type],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const combinedTextStyle = useMemo(
|
|
112
|
+
() =>
|
|
113
|
+
StyleSheet.flatten([
|
|
114
|
+
styles.baseText,
|
|
115
|
+
{
|
|
116
|
+
color: textColor,
|
|
117
|
+
padding: avatarTheme.padding,
|
|
118
|
+
},
|
|
119
|
+
textStyle,
|
|
120
|
+
]),
|
|
121
|
+
[textColor, avatarTheme.padding, textStyle],
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const renderContent = () => {
|
|
125
|
+
switch (type) {
|
|
126
|
+
case AVATAR_TYPES.IMAGE:
|
|
127
|
+
// Handle both imageSource (local/require) and imageUri (URL string)
|
|
128
|
+
let imageSourceToUse: ImageSourcePropType | null = null;
|
|
129
|
+
if (imageSource) {
|
|
130
|
+
// If imageSource is provided (local image), use it directly
|
|
131
|
+
imageSourceToUse = imageSource;
|
|
132
|
+
} else if (imageUri) {
|
|
133
|
+
// If imageUri is provided (URL string), wrap it in {uri: imageUri}
|
|
134
|
+
// Ensure the URI is properly formatted for web
|
|
135
|
+
imageSourceToUse = {uri: imageUri};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
console.log(
|
|
139
|
+
'Avatar IMAGE type - imageSource:',
|
|
140
|
+
imageSource,
|
|
141
|
+
'imageUri:',
|
|
142
|
+
imageUri,
|
|
143
|
+
'imageSourceToUse:',
|
|
144
|
+
imageSourceToUse,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
if (imageSourceToUse) {
|
|
148
|
+
return (
|
|
149
|
+
<Image
|
|
150
|
+
source={imageSourceToUse}
|
|
151
|
+
style={[styles.image, {borderRadius: avatarTheme.borderRadius}]}
|
|
152
|
+
resizeMode="cover"
|
|
153
|
+
onError={error => {
|
|
154
|
+
console.log(
|
|
155
|
+
'Image failed to load:',
|
|
156
|
+
imageUri || 'local image',
|
|
157
|
+
error,
|
|
158
|
+
);
|
|
159
|
+
}}
|
|
160
|
+
onLoad={() => {
|
|
161
|
+
console.log(
|
|
162
|
+
'Image loaded successfully:',
|
|
163
|
+
imageUri || 'local image',
|
|
164
|
+
);
|
|
165
|
+
}}
|
|
166
|
+
onLoadStart={() => {
|
|
167
|
+
console.log(
|
|
168
|
+
'Image loading started:',
|
|
169
|
+
imageUri || 'local image',
|
|
170
|
+
);
|
|
171
|
+
}}
|
|
172
|
+
// Web-specific props
|
|
173
|
+
alt={imageUri ? 'Avatar image' : 'Local avatar image'}
|
|
174
|
+
crossOrigin="anonymous"
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
// Fallback to default if no image provided
|
|
179
|
+
return (
|
|
180
|
+
<IconMoon
|
|
181
|
+
icon={FontIcon.USER}
|
|
182
|
+
color={iconColor}
|
|
183
|
+
size={avatarTheme.size * 0.6}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
case AVATAR_TYPES.NAME:
|
|
188
|
+
return (
|
|
189
|
+
<Typography style={combinedTextStyle} variant={typographyVariant}>
|
|
190
|
+
{initials}
|
|
191
|
+
</Typography>
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
case AVATAR_TYPES.DEFAULT:
|
|
195
|
+
default:
|
|
196
|
+
return (
|
|
197
|
+
<IconMoon
|
|
198
|
+
icon={FontIcon.AVATAR_FILL}
|
|
199
|
+
color={iconColor}
|
|
200
|
+
size={avatarTheme.size * 0.6}
|
|
201
|
+
/>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<View
|
|
208
|
+
style={combinedAvatarStyle}
|
|
209
|
+
{...(isDebugBuildType && automationBaseid
|
|
210
|
+
? setTestId(automationBaseid, screenName, id)
|
|
211
|
+
: {})}>
|
|
212
|
+
{renderContent()}
|
|
213
|
+
</View>
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const styles = StyleSheet.create({
|
|
218
|
+
baseAvatar: {
|
|
219
|
+
alignItems: 'center',
|
|
220
|
+
justifyContent: 'center',
|
|
221
|
+
overflow: 'hidden',
|
|
222
|
+
},
|
|
223
|
+
baseText: {
|
|
224
|
+
textAlign: 'center',
|
|
225
|
+
fontWeight: 'bold',
|
|
226
|
+
lineHeight: undefined, // Remove line height for better centering
|
|
227
|
+
margin: 0, // Remove all margins
|
|
228
|
+
padding: 0, // Remove all padding
|
|
229
|
+
},
|
|
230
|
+
image: {
|
|
231
|
+
width: '100%',
|
|
232
|
+
height: '100%',
|
|
233
|
+
objectFit: 'cover', // Web-specific property for better image fitting
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
export default Avatar;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {spacing} from '../values/Spacing';
|
|
2
|
+
import {borderRadius} from '../values/BorderRadius';
|
|
3
|
+
import type {
|
|
4
|
+
AvatarSizeType,
|
|
5
|
+
AvatarTextSizeType,
|
|
6
|
+
AvatarImageSizeType,
|
|
7
|
+
SizeDimensions,
|
|
8
|
+
} from './Type';
|
|
9
|
+
import {TYPOGRAPHY_STYLES} from '../typography/Token';
|
|
10
|
+
import type {TextStyle, ImageStyle} from 'react-native';
|
|
11
|
+
import type {ExtendedTheme} from '../colors/Type';
|
|
12
|
+
|
|
13
|
+
// Size-specific dimensions based on the design spec - improved proportions
|
|
14
|
+
const sizeDimensions = {
|
|
15
|
+
small: {
|
|
16
|
+
size: 28,
|
|
17
|
+
borderRadius: 14, // Half of size for perfect circle
|
|
18
|
+
padding: 4, // Internal padding for text
|
|
19
|
+
},
|
|
20
|
+
medium: {
|
|
21
|
+
size: 36,
|
|
22
|
+
borderRadius: 18,
|
|
23
|
+
padding: 6,
|
|
24
|
+
},
|
|
25
|
+
large: {
|
|
26
|
+
size: 44,
|
|
27
|
+
borderRadius: 22,
|
|
28
|
+
padding: 8,
|
|
29
|
+
},
|
|
30
|
+
xLarge: {
|
|
31
|
+
size: 52,
|
|
32
|
+
borderRadius: 26,
|
|
33
|
+
padding: 10,
|
|
34
|
+
},
|
|
35
|
+
} as const;
|
|
36
|
+
|
|
37
|
+
// Helper function to create styles for a given size
|
|
38
|
+
const createStylesForSize = (sizeDimensions: SizeDimensions) => ({
|
|
39
|
+
size: sizeDimensions.size,
|
|
40
|
+
width: sizeDimensions.size,
|
|
41
|
+
height: sizeDimensions.size,
|
|
42
|
+
borderRadius: sizeDimensions.borderRadius,
|
|
43
|
+
padding: sizeDimensions.padding,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Export the avatar styles
|
|
47
|
+
export const AVATAR_STYLE: AvatarSizeType = {
|
|
48
|
+
small: createStylesForSize(sizeDimensions.small),
|
|
49
|
+
medium: createStylesForSize(sizeDimensions.medium),
|
|
50
|
+
large: createStylesForSize(sizeDimensions.large),
|
|
51
|
+
xLarge: createStylesForSize(sizeDimensions.xLarge),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export function textViewWrapperStyle(
|
|
55
|
+
textStyle: TextStyle,
|
|
56
|
+
marginRight?: TextStyle['marginHorizontal'],
|
|
57
|
+
): TextStyle {
|
|
58
|
+
return {
|
|
59
|
+
...textStyle,
|
|
60
|
+
lineHeight: undefined,
|
|
61
|
+
marginRight,
|
|
62
|
+
margin: 0,
|
|
63
|
+
padding: 0,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const AVATAR_TXT_STYLE: AvatarTextSizeType = {
|
|
68
|
+
small: textViewWrapperStyle(TYPOGRAPHY_STYLES.captionBold as TextStyle),
|
|
69
|
+
medium: textViewWrapperStyle(TYPOGRAPHY_STYLES.captionBold as TextStyle),
|
|
70
|
+
large: textViewWrapperStyle(TYPOGRAPHY_STYLES.body2Bold as TextStyle),
|
|
71
|
+
xLarge: textViewWrapperStyle(TYPOGRAPHY_STYLES.body1Bold as TextStyle),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const AVATAR_IMAGE_STYLE: AvatarImageSizeType = {
|
|
75
|
+
small: {
|
|
76
|
+
width: sizeDimensions.small.size,
|
|
77
|
+
height: sizeDimensions.small.size,
|
|
78
|
+
borderRadius: sizeDimensions.small.borderRadius,
|
|
79
|
+
},
|
|
80
|
+
medium: {
|
|
81
|
+
width: sizeDimensions.medium.size,
|
|
82
|
+
height: sizeDimensions.medium.size,
|
|
83
|
+
borderRadius: sizeDimensions.medium.borderRadius,
|
|
84
|
+
},
|
|
85
|
+
large: {
|
|
86
|
+
width: sizeDimensions.large.size,
|
|
87
|
+
height: sizeDimensions.large.size,
|
|
88
|
+
borderRadius: sizeDimensions.large.borderRadius,
|
|
89
|
+
},
|
|
90
|
+
xLarge: {
|
|
91
|
+
width: sizeDimensions.xLarge.size,
|
|
92
|
+
height: sizeDimensions.xLarge.size,
|
|
93
|
+
borderRadius: sizeDimensions.xLarge.borderRadius,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const AVATAR_ROUNDED_BORDER_RADIUS = borderRadius.borderRadiusFull;
|
|
98
|
+
|
|
99
|
+
// Color tokens based on the design spec
|
|
100
|
+
export const AVATAR_COLOR_TOKENS = {
|
|
101
|
+
default: {
|
|
102
|
+
background: (theme: ExtendedTheme) => theme.colors.colorBackgroundSecondary, // Light gray background
|
|
103
|
+
icon: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary, // Dark gray icon
|
|
104
|
+
text: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary, // Dark gray text
|
|
105
|
+
},
|
|
106
|
+
name: {
|
|
107
|
+
background: (theme: ExtendedTheme) => '#FFB366', // Light orange background (matches design)
|
|
108
|
+
icon: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary,
|
|
109
|
+
text: (theme: ExtendedTheme) => '#FFFFFF', // White text (matches design)
|
|
110
|
+
},
|
|
111
|
+
image: {
|
|
112
|
+
background: (theme: ExtendedTheme) => theme.colors.colorBackgroundSecondary, // Light background as fallback
|
|
113
|
+
icon: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary,
|
|
114
|
+
text: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary,
|
|
115
|
+
},
|
|
116
|
+
} as const;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import type {TextStyle, ViewStyle, ImageStyle} from 'react-native';
|
|
3
|
+
|
|
4
|
+
export type SizeType = 'small' | 'medium' | 'large' | 'xLarge';
|
|
5
|
+
|
|
6
|
+
export type AvatarType = 'default' | 'name' | 'image';
|
|
7
|
+
|
|
8
|
+
export const AVATAR_TYPES = {
|
|
9
|
+
DEFAULT: 'default',
|
|
10
|
+
NAME: 'name',
|
|
11
|
+
IMAGE: 'image',
|
|
12
|
+
} as const;
|
|
13
|
+
|
|
14
|
+
export type AvatarSizeType = {
|
|
15
|
+
[key in SizeType]: {
|
|
16
|
+
size: number;
|
|
17
|
+
borderRadius: number;
|
|
18
|
+
padding: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type AvatarTextSizeType = {
|
|
23
|
+
[key in SizeType]: TextStyle;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type AvatarImageSizeType = {
|
|
27
|
+
[key in SizeType]: ImageStyle;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type AvatarVariant = 'default' | 'name' | 'image';
|
|
31
|
+
|
|
32
|
+
export type SizeDimensions = {
|
|
33
|
+
size: number;
|
|
34
|
+
borderRadius: number;
|
|
35
|
+
padding: number;
|
|
36
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type {ExtendedTheme} from '../colors/Type';
|
|
2
|
+
import {AVATAR_COLOR_TOKENS} from './Token';
|
|
3
|
+
import type {AvatarVariant} from './Type';
|
|
4
|
+
|
|
5
|
+
export const getBackgroundColor = (
|
|
6
|
+
avatarType: AvatarVariant,
|
|
7
|
+
theme: ExtendedTheme,
|
|
8
|
+
) => {
|
|
9
|
+
const variant =
|
|
10
|
+
AVATAR_COLOR_TOKENS[avatarType] || AVATAR_COLOR_TOKENS.default;
|
|
11
|
+
return variant.background(theme);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const getIconColor = (
|
|
15
|
+
avatarType: AvatarVariant,
|
|
16
|
+
theme: ExtendedTheme,
|
|
17
|
+
) => {
|
|
18
|
+
const variant =
|
|
19
|
+
AVATAR_COLOR_TOKENS[avatarType] || AVATAR_COLOR_TOKENS.default;
|
|
20
|
+
return variant.icon(theme);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const getTextColor = (
|
|
24
|
+
avatarType: AvatarVariant,
|
|
25
|
+
theme: ExtendedTheme,
|
|
26
|
+
) => {
|
|
27
|
+
const variant =
|
|
28
|
+
AVATAR_COLOR_TOKENS[avatarType] || AVATAR_COLOR_TOKENS.default;
|
|
29
|
+
return variant.text(theme);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Helper function to get initials from name
|
|
33
|
+
export const getInitials = (name: string): string => {
|
|
34
|
+
if (!name || typeof name !== 'string') return '';
|
|
35
|
+
|
|
36
|
+
const words = name.trim().split(/\s+/);
|
|
37
|
+
if (words.length === 1) {
|
|
38
|
+
return words[0].substring(0, 2).toUpperCase();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (words[0][0] + words[words.length - 1][0]).toUpperCase();
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|