-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnode.tsx
More file actions
60 lines (56 loc) · 1.38 KB
/
node.tsx
File metadata and controls
60 lines (56 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React, { FC } from "react";
import type { INodeProps } from "./types";
import { Elements } from "../constants";
import whiteTick from "../assets/white-tick.svg";
import styles from "./styles.module.scss";
/**
* Represents each node in the stepper
* Handles style addition to each node separately
* Handles click event of each node
* @param {INodeProps} props
* @returns {FC}
*/
const Node: FC<INodeProps> = (props) => {
const {
step,
renderNode,
index,
currentStepIndex,
handleStepClick,
showCursor,
getStyles,
nodeStyle
} = props;
const isCompleted = step.completed;
const isActive = index === currentStepIndex;
return (
<div
className={`${styles.eachNode}
${showCursor && styles.cursorPointer}
${isActive && styles.activeStepNode}
${!isCompleted && !isActive && styles.inactiveStepNode}
${isCompleted && !isActive && styles.completedStepNode}
`}
style={nodeStyle}
onClick={(): void | null => handleStepClick && handleStepClick()}
role="presentation"
id="stepper-node"
>
{(renderNode && renderNode(step, index))
|| (
<>
{isCompleted ? (
<img
src={whiteTick}
className={styles.whiteTickImg}
alt=""
/>
) : (
index + 1
)}
</>
)}
</div>
);
};
export default Node;