Skip to content

Commit 92fb3a5

Browse files
authored
Reuse timeline for activity log (#2851)
* allow to provide width prop to line * allow to pass icon props to point * update types * unify line styles * fix lint * rm extra comma - lint * update dependencies list
1 parent f3a7a5d commit 92fb3a5

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/components/timeline/Line.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ type LinePropsInternal = LineProps & {
1313
};
1414

1515
const Line = React.memo((props: LinePropsInternal) => {
16-
const {type, color = 'transparent', entry, top, style} = props;
16+
const {type, color = 'transparent', entry, top, style, width = LINE_WIDTH} = props;
1717

1818
const solidLineStyle = useMemo(() => {
19-
return [style, styles.solidLine, {backgroundColor: color}];
20-
}, [color, style]);
19+
return [style, styles.line, {width, backgroundColor: color}];
20+
}, [color, style, width]);
2121

2222
const dashedLineStyle = useMemo(() => {
23-
return [style, styles.dashedLine];
23+
return [style, styles.line];
2424
}, [style]);
2525

2626
const renderStartPoint = () => {
@@ -52,11 +52,7 @@ const styles = StyleSheet.create({
5252
width: 12,
5353
height: ENTRY_POINT_HEIGHT
5454
},
55-
solidLine: {
56-
width: LINE_WIDTH,
57-
overflow: 'hidden'
58-
},
59-
dashedLine: {
55+
line: {
6056
overflow: 'hidden'
6157
}
6258
});

src/components/timeline/Point.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type PointPropsInternal = PointProps & {
2020
};
2121

2222
const Point = (props: PointPropsInternal) => {
23-
const {icon, label, type, color, onLayout} = props;
23+
const {icon, iconProps, label, type, color, onLayout} = props;
2424

2525
const pointStyle = useMemo(() => {
2626
const hasOutline = type === PointTypes.OUTLINE;
@@ -43,7 +43,7 @@ const Point = (props: PointPropsInternal) => {
4343

4444
const renderPointContent = () => {
4545
if (icon) {
46-
return <Icon source={icon} size={ICON_SIZE} tintColor={Colors.$iconDefaultLight}/>;
46+
return <Icon size={ICON_SIZE} tintColor={Colors.$iconDefaultLight} {...iconProps} source={icon}/>;
4747
} else if (label) {
4848
return <Text recorderTag={'unmask'} $textDefaultLight subtextBold>{label}</Text>;
4949
}

src/components/timeline/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, {PropsWithChildren} from 'react';
22
import {ImageRequireSource} from 'react-native';
3+
import {IconProps} from '../icon';
34

45
export enum StateTypes {
56
CURRENT = 'current', // default
@@ -25,13 +26,15 @@ export type LineProps = {
2526
color?: string;
2627
/** to mark as entry point */
2728
entry?: boolean;
29+
width?: number;
2830
}
2931

3032
export type PointProps = {
3133
state?: StateTypes;
3234
type?: PointTypes;
3335
color?: string;
3436
icon?: ImageRequireSource;
37+
iconProps?: IconProps;
3538
label?: number;
3639
/** to align point to this view's center */
3740
anchorRef?: React.MutableRefObject<undefined>;

0 commit comments

Comments
 (0)