@momo-kits/information 0.77.5-beta.1

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/index.tsx ADDED
@@ -0,0 +1,87 @@
1
+ import React, {FC, useContext} from 'react';
2
+ import {TouchableOpacity, View} from 'react-native';
3
+ import {InformationProps} from './types';
4
+ import styles from './styles';
5
+ import {
6
+ ApplicationContext,
7
+ Button,
8
+ Colors,
9
+ Icon,
10
+ Image,
11
+ Text,
12
+ } from '@momo-kits/foundation';
13
+
14
+ const Information: FC<InformationProps> = ({
15
+ title,
16
+ description = 'Description',
17
+ state = 'default',
18
+ image,
19
+ onPressCTA,
20
+ showIcon = true,
21
+ CTA,
22
+ style,
23
+ showIconClose = true,
24
+ onPressClose,
25
+ }) => {
26
+ const {theme} = useContext(ApplicationContext);
27
+
28
+ const getTypeStyle = () => {
29
+ let borderColor = Colors.blue_07;
30
+ let backgroundColor = Colors.blue_10;
31
+ let color = Colors.blue_03;
32
+ let iconSource = 'notifications_info';
33
+
34
+ if (state === 'warning') {
35
+ borderColor = Colors.yellow_06;
36
+ backgroundColor = Colors.yellow_09;
37
+ color = Colors.orange_03;
38
+ iconSource = '24_notifications_alert_triangle';
39
+ }
40
+
41
+ if (state === 'error') {
42
+ borderColor = Colors.red_07;
43
+ backgroundColor = Colors.red_10;
44
+ color = Colors.red_03;
45
+ iconSource = '24_notifications_alert_octagon';
46
+ }
47
+
48
+ return {borderColor, backgroundColor, color, iconSource};
49
+ };
50
+
51
+ const {backgroundColor, borderColor, color, iconSource} = getTypeStyle();
52
+
53
+ return (
54
+ <View style={[style, {backgroundColor, borderColor}, styles.container]}>
55
+ <View style={styles.row}>
56
+ {!!image && <Image source={{uri: image}} style={styles.image} />}
57
+ {!image && showIcon && (
58
+ <Icon
59
+ color={color}
60
+ style={styles.icon}
61
+ size={16}
62
+ source={iconSource}
63
+ />
64
+ )}
65
+ <View style={styles.flex}>
66
+ {!!title && <Text typography={'label_default'}>{title}</Text>}
67
+ <Text typography={'description_s'}>{description}</Text>
68
+ </View>
69
+ {showIconClose && (
70
+ <TouchableOpacity onPress={onPressClose}>
71
+ <Icon size={16} source={'navigation_close'} />
72
+ </TouchableOpacity>
73
+ )}
74
+ </View>
75
+
76
+ {!!CTA && onPressCTA && (
77
+ <TouchableOpacity style={styles.cta} onPress={onPressCTA}>
78
+ <Text color={color} typography={'action_xs'}>
79
+ {CTA}
80
+ </Text>
81
+ </TouchableOpacity>
82
+ )}
83
+ </View>
84
+ );
85
+ };
86
+
87
+ export default Information;
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@momo-kits/information",
3
+ "version": "0.77.5-beta.01",
4
+ "private": false,
5
+ "main": "index.tsx",
6
+ "peerDependencies": {
7
+ "@momo-kits/foundation": "latest",
8
+ "react": "16.9.0",
9
+ "react-native": ">=0.55",
10
+ "prop-types": "^15.7.2"
11
+ },
12
+ "devDependencies": {},
13
+ "license": "MoMo",
14
+ "dependencies": {}
15
+ }
package/publish.sh ADDED
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+ rm -rf dist
3
+ mkdir dist
4
+
5
+ cp . ./dist
6
+
7
+ # GET VERSION from mck_package.json
8
+ VERSIONSTRING=( v$(jq .version package.json) )
9
+ VERSION=(${VERSIONSTRING//[\"]/})
10
+ echo VERSION: $VERSION
11
+
12
+ rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
13
+
14
+ # #babel component to dist
15
+ #babel ./dist -d dist --copy-files
16
+
17
+ #copy option
18
+ #cp -r ./src/ dist
19
+
20
+
21
+ #npm login
22
+ #publish dist to npm
23
+ cd dist
24
+ npm publish --tag beta --access=public
25
+ cd ..
26
+ rm -rf dist
27
+
28
+ ##curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/bank new version release: '*"$VERSION"*' `https://www.npmjs.com/package/@momo-kits/avatar`"}'
package/styles.ts ADDED
@@ -0,0 +1,29 @@
1
+ import {StyleSheet} from 'react-native';
2
+ import {Radius, Spacing} from '@momo-kits/foundation';
3
+
4
+ export default StyleSheet.create({
5
+ container: {
6
+ borderRadius: Radius.S,
7
+ borderWidth: 0.5,
8
+ padding: Spacing.M,
9
+ },
10
+ image: {
11
+ width: 40,
12
+ height: 40,
13
+ borderRadius: Radius.XS,
14
+ marginRight: Spacing.S,
15
+ },
16
+ icon: {
17
+ marginRight: Spacing.S,
18
+ },
19
+ row: {
20
+ flexDirection: 'row',
21
+ },
22
+ cta: {
23
+ width: '100%',
24
+ alignItems: 'flex-end',
25
+ },
26
+ flex: {
27
+ flex: 1,
28
+ },
29
+ });
package/types.ts ADDED
@@ -0,0 +1,73 @@
1
+ import {ViewStyle} from 'react-native';
2
+
3
+ /**
4
+ * Props for the Information component. This component is typically used to display a piece of
5
+ * information with optional actions for the user. It can represent various states and levels
6
+ * of importance or urgency.
7
+ */
8
+ export type InformationProps = {
9
+ /**
10
+ * Optional. The title for the information block, often used to emphasize the main theme or
11
+ * to indicate the reason for the message. If not provided, only the description will be shown.
12
+ */
13
+ title?: string;
14
+
15
+ /**
16
+ * The main content text of the information block. This text provides the necessary details
17
+ * and is essential for understanding the context of the message.
18
+ */
19
+ description: string;
20
+
21
+ /**
22
+ * Optional. The text for the Call To Action (CTA) button. This is intended to prompt the user
23
+ * to take some specified action like "Retry", "Learn More", or "Dismiss".
24
+ */
25
+ CTA?: string;
26
+
27
+ /**
28
+ * Optional. A callback function that is triggered when the CTA button is pressed. This is
29
+ * used to handle the user's response to the proposed call to action.
30
+ */
31
+ onPressCTA?: () => void;
32
+
33
+ /**
34
+ * Optional. The URL or local file path of an image to be displayed. This is typically used
35
+ * to provide visual context or support to the information being presented.
36
+ */
37
+ image?: string;
38
+
39
+ /**
40
+ * Optional. Specifies the state of the information block, which may influence the block's
41
+ * styling, such as color coding. The 'default' state is neutral, while 'warning' and 'error'
42
+ * represent increasing levels of urgency or attention.
43
+ * Defaults to 'default' if not provided.
44
+ */
45
+ state?: 'default' | 'warning' | 'error';
46
+
47
+ /**
48
+ * Optional. If `true`, an icon is displayed within the information block, often used to
49
+ * visually reinforce the state or content of the block. The type of icon is typically
50
+ * influenced by the `state` prop.
51
+ * Defaults to `false` if not provided.
52
+ */
53
+ showIcon?: boolean;
54
+
55
+ /**
56
+ * Optional. If `true`, a close icon is displayed, usually in the upper corner of the information
57
+ * block, indicating that the user can dismiss or remove the block from view.
58
+ * Defaults to `false` if not provided.
59
+ */
60
+ showIconClose?: boolean;
61
+
62
+ /**
63
+ * Optional. A callback function that is triggered when the close icon is pressed. This is
64
+ * used to handle the dismissal of the information block, often removing it from display.
65
+ */
66
+ onPressClose?: () => void;
67
+
68
+ /**
69
+ * Optional. Custom styles to apply to the Information component. Can be used to adjust
70
+ * the visual presentation or layout beyond the default and state-based styling.
71
+ */
72
+ style?: ViewStyle;
73
+ };