Skip to content

Commit 91827e8

Browse files
feat: Add JSDoc annotation for components and utils
* JSDoc addition * eslint error
1 parent 8355771 commit 91827e8

File tree

9 files changed

+35926
-25580
lines changed

9 files changed

+35926
-25580
lines changed

package-lock.json

Lines changed: 35870 additions & 25579 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11

2+
/**
3+
* Enum for Label position
4+
*/
25
export enum LABEL_POSITION {
36
LEFT = "left",
47
RIGHT = "right",
58
TOP = "top",
69
BOTTOM = "bottom",
710
}
811

12+
/**
13+
* Enum for orientation
14+
*/
915
export enum ORIENTATION {
1016
HORIZONTAL = "horizontal",
1117
VERTICAL = "vertical",
1218
}
1319

20+
/**
21+
* Enum for elements of each node
22+
*/
1423
export enum Elements {
1524
LabelDescription = "LabelDescription",
1625
LabelTitle = "LabelTitle",

src/node/node.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import { Elements } from "../constants";
44
import whiteTick from "../assets/white-tick.svg";
55
import styles from "./styles.module.scss";
66

7+
/**
8+
* Represents each node in the stepper
9+
* Handles style addition to each node separately
10+
* Handles click event of each node
11+
* @param {INodeProps} props
12+
* @returns {FC}
13+
*/
714
const Node: FC<INodeProps> = (props) => {
815
const {
916
step,

src/stepper/step.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { LABEL_POSITION, ORIENTATION } from "../constants";
55
import StepContent from "./stepContent";
66
import StepInfo from "./stepInfo";
77

8-
// Each step consists of a node, a label, and connectors to the previous and next steps.
8+
/**
9+
* Represents each step.
10+
* Consist of node, label and connectors to previous and next step
11+
* @function
12+
* @param {IStepProps} props
13+
* @returns {React.FC}
14+
*/
915
const Step: (props: IStepProps) => JSX.Element = ({
1016
stepperProps,
1117
step,

src/stepper/stepContent.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { LABEL_POSITION, Elements } from "../constants";
44
import getStyles from "../utils/getStyles";
55
import { IStepContentProps } from "./types";
66

7+
/**
8+
* Gives the step content considering the orientation
9+
* Can customize styles and nodeWidth of each step
10+
* @param {IStepContentProps} props
11+
* @returns {React.FC}
12+
*/
713
const StepContent: (props: IStepContentProps) => JSX.Element = ({
814
labelPosition,
915
isVertical,

src/stepper/stepInfo.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import { LABEL_POSITION, Elements, ORIENTATION } from "../constants";
66
import getStyles from "../utils/getStyles";
77
import getLabelStyle from "../utils/getLabelStyle";
88

9+
/**
10+
* To handle step display (inline or not)
11+
* Can handle description display and label
12+
* @param {IStepInfoProps} props
13+
* @returns {React.FC}
14+
*/
915
const StepInfo: (props: IStepInfoProps) => JSX.Element = ({
1016
orientation,
1117
labelPosition,

src/stepper/stepperComponent.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import type { IStepperProps } from "./types";
44
import { ORIENTATION } from "../constants";
55
import Step from "./step";
66

7+
/**
8+
* To display each steps after analysing the orientation
9+
* @param { IStepperProps} props
10+
* @returns {React.FC}
11+
*/
712
const Stepper = (props: IStepperProps): JSX.Element => {
813
const {
914
steps,

src/utils/getLabelStyle.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { LABEL_POSITION, ORIENTATION } from "../constants";
22

3+
/**
4+
* To get the label style considering the orientation
5+
* @function
6+
* @param {string} [orientation]
7+
* @param {string} [labelPosition]
8+
* @returns {string|undefined}
9+
*/
310
const getLabelStyle: (orientation?: string, labelPosition?: string) => string | undefined = (orientation, labelPosition) => {
411
if (orientation !== ORIENTATION.VERTICAL) {
512
if (labelPosition === LABEL_POSITION.TOP) return "horizontalLabelTop";

src/utils/getStyles.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ import { Elements } from "../constants";
22
import { IStep, IStyleFunction } from "../stepper/types";
33

44

5+
/**
6+
* To get the Style of element from the style object provided
7+
* @function
8+
* @param {{[key in Elements]?: IStyleFunction}} styles
9+
* @param {Elements} element
10+
* @param {IStep} step
11+
* @param {number} index
12+
* @returns {object}
13+
*/
514
const getStyles = (styles: { [key in Elements]?: IStyleFunction }, element: Elements, step: IStep, index: number): object => {
615
const getElementStyle = styles[element];
716
if (getElementStyle) {

0 commit comments

Comments
 (0)