Skip to content

Commit

Permalink
⭐️ Impl: Ex - Update CardLogDisplay
Browse files Browse the repository at this point in the history
Summary: Implement `shouldShowTimestamp` prop.
  • Loading branch information
dominicstop committed Mar 3, 2023
1 parent ee08b09 commit 8c6756a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions example/src/components/Card/CardLogDisplay/CardLogDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const CardLogDisplay = React.forwardRef<
<CardLogDisplayListRow
key={`event-${item.timestamp}-${item.title}`}
item={item}
shouldShowTimestamp={props.shouldShowTimestamp ?? true}
/>
))}
</View>
Expand Down Expand Up @@ -117,6 +118,7 @@ export const CardLogDisplay = React.forwardRef<
<CardLogDisplayListRow
key={`event-${item.timestamp}-${item.title}`}
item={item}
shouldShowTimestamp={props.shouldShowTimestamp ?? true}
/>
))}
</ScrollView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import type { CardLogDisplayItem } from './CardLogDisplayTypes';

import * as Helpers from '../../../functions/Helpers';

export function CardLogDisplayListRow(props: { item: CardLogDisplayItem }) {
export function CardLogDisplayListRow(props: {
item: CardLogDisplayItem;
shouldShowTimestamp: boolean;
}) {
const { item } = props;
const date = new Date(item.timestamp);

Expand All @@ -19,10 +22,19 @@ export function CardLogDisplayListRow(props: { item: CardLogDisplayItem }) {
return (
<View style={styles.logListItemContainer}>
<Text style={styles.logItemIndexText}>
{/* Col - Index */}
{`${Helpers.pad(item.index, 3)}`}
</Text>
<Text style={styles.logItemTimestampText}>{timeString}</Text>
<Text style={styles.logItemTypeText}>{item.title}</Text>
{props.shouldShowTimestamp && (
<Text style={styles.logItemTimestampText}>
{/* Col - Timestamp */}
{timeString}
</Text>
)}
<Text style={styles.logItemTypeText}>
{/* Col - Title */}
{item.title}
</Text>
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type CardLogDisplayBaseProps = {
style?: ViewStyle;
initialLogItems?: Array<CardLogDisplayItem>;
listEmptyMessage?: string;
shouldShowTimestamp?: boolean;
};

export type CardLogDisplayProps = CardLogDisplayBaseProps & DisplayListModeProp;
Expand Down

0 comments on commit 8c6756a

Please sign in to comment.