Skip to content

Commit 83f65b4

Browse files
committed
docs: enhance IterableEmbedded components with documentation
1 parent 2db3ae7 commit 83f65b4

8 files changed

Lines changed: 120 additions & 1 deletion

File tree

src/embedded/components/IterableEmbeddedBanner/IterableEmbeddedBanner.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ import {
1818
IMAGE_WIDTH,
1919
} from './IterableEmbeddedBanner.styles';
2020

21+
/**
22+
*
23+
* @param config - The config for the IterableEmbeddedBanner component.
24+
* @param message - The message to render.
25+
* @param onButtonClick - The function to call when a button is clicked.
26+
* @param onMessageClick - The function to call when the message is clicked.
27+
* @returns The IterableEmbeddedBanner component.
28+
*
29+
* @example
30+
* ```tsx
31+
* return (
32+
* <IterableEmbeddedBanner
33+
* config={config}
34+
* message={message}
35+
* onButtonClick={onButtonClick}
36+
* onMessageClick={onMessageClick}
37+
* />
38+
* );
39+
* ```
40+
*/
2141
export const IterableEmbeddedBanner = ({
2242
config,
2343
message,

src/embedded/components/IterableEmbeddedCard/IterableEmbeddedCard.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@ import { useEmbeddedView } from '../../hooks/useEmbeddedView';
1515
import type { IterableEmbeddedComponentProps } from '../../types/IterableEmbeddedComponentProps';
1616
import { IMAGE_HEIGHT, styles } from './IterableEmbeddedCard.styles';
1717

18+
/**
19+
*
20+
* @param config - The config for the IterableEmbeddedCard component.
21+
* @param message - The message to render.
22+
* @param onButtonClick - The function to call when a button is clicked.
23+
* @param onMessageClick - The function to call when the message is clicked.
24+
* @returns The IterableEmbeddedCard component.
25+
*
26+
* @example
27+
* ```tsx
28+
* return (
29+
* <IterableEmbeddedCard
30+
* config={config}
31+
* message={message}
32+
* onButtonClick={onButtonClick}
33+
* onMessageClick={onMessageClick}
34+
* />
35+
* );
36+
* ```
37+
*/
1838
export const IterableEmbeddedCard = ({
1939
config,
2040
message,

src/embedded/components/IterableEmbeddedNotification/IterableEmbeddedNotification.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ import { useEmbeddedView } from '../../hooks/useEmbeddedView';
1212
import type { IterableEmbeddedComponentProps } from '../../types/IterableEmbeddedComponentProps';
1313
import { styles } from './IterableEmbeddedNotification.styles';
1414

15+
/**
16+
*
17+
* @param config - The config for the IterableEmbeddedNotification component.
18+
* @param message - The message to render.
19+
* @param onButtonClick - The function to call when a button is clicked.
20+
* @param onMessageClick - The function to call when the message is clicked.
21+
* @returns The IterableEmbeddedNotification component.
22+
*
23+
* @example
24+
* ```tsx
25+
* return (
26+
* <IterableEmbeddedNotification
27+
* config={config}
28+
* message={message}
29+
* onButtonClick={onButtonClick}
30+
* onMessageClick={onMessageClick}
31+
* />
32+
* );
33+
* ```
34+
*/
1535
export const IterableEmbeddedNotification = ({
1636
config,
1737
message,

src/embedded/components/IterableEmbeddedView.tsx

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IterableEmbeddedNotification } from './IterableEmbeddedNotification';
99
/**
1010
* The props for the IterableEmbeddedView component.
1111
*/
12-
interface IterableEmbeddedViewProps extends IterableEmbeddedComponentProps {
12+
export interface IterableEmbeddedViewProps extends IterableEmbeddedComponentProps {
1313
/** The type of view to render. */
1414
viewType: IterableEmbeddedViewType;
1515
}
@@ -20,10 +20,62 @@ interface IterableEmbeddedViewProps extends IterableEmbeddedComponentProps {
2020
* @param message - The message to render.
2121
* @param config - The config for the IterableEmbeddedView component, most likely used to style the view.
2222
* @param onButtonClick - The function to call when a button is clicked.
23+
* @param onMessageClick - The function to call when the message is clicked.
2324
* @returns The IterableEmbeddedView component.
2425
*
2526
* This component is used to render pre-created, customizable message displays
2627
* included with Iterables RN SDK: cards, banners, and notifications.
28+
*
29+
* @example
30+
* ```tsx
31+
* // See `IterableEmbeddedViewType`` for available view types.
32+
* const viewType = IterableEmbeddedViewType.Card;
33+
*
34+
* // The message object that will be rendered.
35+
* // You can retrieve messages by calling `Iterable.embeddedManager.getMessages(IDS)`
36+
* const message = {
37+
* metadata: {
38+
* messageId: 'test-message-123',
39+
* campaignId: 123456,
40+
* placementId: 'test-placement',
41+
* },
42+
* elements: {
43+
* title: 'Test Title',
44+
* body: 'Test Body',
45+
* buttons: [
46+
* { id: 'button-1', label: 'Button 1', action: 'button-1-action' },
47+
* { id: 'button-2', label: 'Button 2', action: 'button-2-action' },
48+
* ],
49+
* },
50+
* };
51+
*
52+
* // The config for the IterableEmbeddedView component, most likely used to style the view.
53+
* // See `IterableEmbeddedViewConfig` for available config options.
54+
* const config = { backgroundColor: '#FFFFFF', borderRadius: 8 };
55+
*
56+
* // A callback that will be called when a button is clicked.
57+
* // General click handling is handled by the SDK; This is only for custom logic.
58+
* const onButtonClick = () => {
59+
* console.log('Button clicked');
60+
* };
61+
*
62+
* // A callback that will be called when the message is clicked.
63+
* // This is not called when a button is clicked.
64+
* // If a default action is set, this is what will be called.
65+
* const onMessageClick = () => {
66+
* console.log('Message clicked');
67+
* };
68+
*
69+
* return (
70+
* <IterableEmbeddedView
71+
* viewType={viewType}
72+
* message={message}
73+
* config={config}
74+
* onButtonClick={onButtonClick}
75+
* onMessageClick={onMessageClick}
76+
* />
77+
* );
78+
* ```
2779
*/
2880
export const IterableEmbeddedView = ({
2981
viewType,

src/embedded/hooks/useEmbeddedView/getMedia.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import { IterableEmbeddedViewType } from '../../enums';
1010
* @returns The media to render.
1111
*
1212
* @example
13+
* ```ts
1314
* const media = getMedia(IterableEmbeddedViewType.Notification, message);
1415
* console.log(media.url);
1516
* console.log(media.caption);
1617
* console.log(media.shouldShow ? 'true' : 'false');
18+
* ```
1719
*/
1820
export const getMedia = (
1921
/** The type of view to render. */

src/embedded/hooks/useEmbeddedView/getStyles.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const getDefaultStyle = <T>(
3737
* @returns The styles.
3838
*
3939
* @example
40+
* ```ts
4041
* const styles = getStyles(IterableEmbeddedViewType.Notification, {
4142
* backgroundColor: '#000000',
4243
* borderColor: '#000000',
@@ -45,6 +46,7 @@ const getDefaultStyle = <T>(
4546
* primaryBtnBackgroundColor: '#000000',
4647
* primaryBtnTextColor: '#000000',
4748
* });
49+
* ```
4850
*/
4951
export const getStyles = (
5052
viewType: IterableEmbeddedViewType,

src/embedded/hooks/useEmbeddedView/useEmbeddedView.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const noop = () => {};
1616
* @returns The embedded view.
1717
*
1818
* @example
19+
* ```tsx
1920
* const { handleButtonClick, handleMessageClick, media, parsedStyles } = useEmbeddedView(IterableEmbeddedViewType.Notification, {
2021
* message,
2122
* config,
@@ -30,6 +31,7 @@ const noop = () => {};
3031
* <Text>{parsedStyles.backgroundColor}</Text>
3132
* </View>
3233
* );
34+
* ```
3335
*/
3436
export const useEmbeddedView = (
3537
/** The type of view to render. */

src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export {
4242
type IterableEmbeddedMessageElementsButton,
4343
type IterableEmbeddedMessageElementsText,
4444
type IterableEmbeddedViewConfig,
45+
type IterableEmbeddedViewProps,
4546
} from './embedded';
4647
export {
4748
IterableHtmlInAppContent,

0 commit comments

Comments
 (0)