diff --git a/ts/features/pn/components/Timeline.tsx b/ts/features/pn/components/Timeline.tsx new file mode 100644 index 00000000000..a4bec65a51d --- /dev/null +++ b/ts/features/pn/components/Timeline.tsx @@ -0,0 +1,166 @@ +import React, { PropsWithChildren } from "react"; +import { StyleSheet, View } from "react-native"; +import { Caption, H6, IOColors, VSpacer } from "@pagopa/io-app-design-system"; + +type ColorStates = { + background: string; +}; + +type Position = { + isFirst: boolean; + isLast: boolean; +}; + +export type TimelineStatus = + | "default" + | "viewed" + | "unreachable" + | "effective" + | "cancelled"; + +type TimelineItemProps = { + day: string; + description: string; + month: string; + time: string; + status: TimelineStatus; +}; + +export type TimelineProps = { + data: Array; +}; + +const styles = StyleSheet.create({ + item: { + flex: 1, + flexShrink: 1, + flexDirection: "row", + alignItems: "center", + paddingHorizontal: 24 + }, + oppositeContent: { + alignItems: "center", + paddingVertical: 12 + }, + content: { + flexShrink: 1, + paddingVertical: 12 + }, + hidden: { + opacity: 0 + }, + line: { + alignItems: "center", + paddingHorizontal: 16 + }, + rectangle: { + flexGrow: 1, + width: 2, + backgroundColor: IOColors.bluegreyLight + }, + dot: { + marginVertical: 4, + width: 14, + height: 14, + borderRadius: 14 / 2, + borderColor: IOColors.white + } +}); + +const mapColorStatus: Record, ColorStates> = { + cancelled: { + background: IOColors["warning-500"] + }, + default: { + background: IOColors["grey-300"] + }, + effective: { + background: IOColors["info-500"] + }, + unreachable: { + background: IOColors["error-500"] + }, + viewed: { + background: IOColors["success-500"] + } +}; + +const borderWidth: number = 1.5; + +const TimelineDot = ({ + isFirst, + isLast, + status +}: Pick & Position) => ( + +); + +const TimelineSeparator = ({ + children, + isFirst, + isLast +}: PropsWithChildren & Position>) => ( + + + {children} + + +); + +const TimelineOppositeContent = ({ + day, + month +}: Pick) => ( + +
{day}
+ {month} +
+); + +const TimelineContent = ({ + description, + time +}: Pick) => ( + +
{description}
+ + {time} +
+); + +const TimelineItem = ({ + day, + description, + month, + time, + ...rest +}: TimelineItemProps & Position) => ( + + + + + + + +); + +export const Timeline = ({ data = [] }: TimelineProps) => ( + <> + {data.map((item, i) => ( + + ))} + +);