Skip to content

Commit

Permalink
Timeline Molecule (#86)
Browse files Browse the repository at this point in the history
* added breadcrumbs

* review changes

* added timeline molecule

* updated versions

* added review changes
  • Loading branch information
Swathi-eGov authored Jun 24, 2024
1 parent a2a538d commit cf10937
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 36 deletions.
4 changes: 4 additions & 0 deletions react/css/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.0.2-beta.6] - 2024-06-24
### Added
- Added ViewMore button for timeline molecule

## [0.0.2-beta.5] - 2024-06-19
### Added
- Added BreadCrumb css
Expand Down
2 changes: 1 addition & 1 deletion react/css/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-components-css",
"version": "0.0.2-test.5",
"version": "0.0.2-beta.6",
"license": "MIT",
"main": "dist/index.css",
"author": "Jagankumar <[email protected]>",
Expand Down
17 changes: 13 additions & 4 deletions react/css/src/digitv2/components/timelineV2.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
top: theme(digitv2.spacers.spacer8);

&.completed,
&.inprogress{
&.inprogress,
&.nextActiveStep{
border-color: theme(digitv2.lightTheme.primary-1);
}

&.inprogress{
border-style: dashed;
&.nextActiveStep{
border-style: dotted;
}

@media (max-aspect-ratio: 9/16) {
Expand Down Expand Up @@ -147,4 +148,12 @@ img {
height: 1.125rem;
}
}
}
}

.digit-timeline-molecule{
@apply max-h-full;
}

.view-more-container {
margin-top: theme(digitv2.spacers.spacer4);
}
2 changes: 1 addition & 1 deletion react/example/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
rel='stylesheet' type='text/css'>
<link
rel="stylesheet"
href="https://unpkg.com/@egovernments/[email protected].5/dist/index.css"
href="https://unpkg.com/@egovernments/[email protected].6/dist/index.css"
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#00bcd1" />
Expand Down
2 changes: 1 addition & 1 deletion react/modules/Project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.1-beta.4",
"@egovernments/digit-ui-components": "0.0.2-beta.6",
"@egovernments/digit-ui-components": "0.0.2-beta.7",
"lodash": "^4.17.21",
"react": "17.0.2",
"react-date-range": "^1.4.0",
Expand Down
2 changes: 1 addition & 1 deletion react/modules/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"prepublish": "yarn build"
},
"dependencies": {
"@egovernments/digit-ui-components": "0.0.2-beta.6",
"@egovernments/digit-ui-components": "0.0.2-beta.7",
"@egovernments/digit-ui-react-components": "1.8.1-beta.4",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion react/modules/sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.1-beta.4",
"@egovernments/digit-ui-components": "0.0.2-beta.6",
"@egovernments/digit-ui-components": "0.0.2-beta.7",
"react": "17.0.2",
"react-date-range": "^1.4.0",
"react-dom": "17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@egovernments/digit-ui-module-sample": "0.0.1",
"@egovernments/digit-ui-react-components": "1.7.10",
"@egovernments/digit-ui-svg-components": "1.0.4",
"@egovernments/digit-ui-components": "0.0.2-beta.6",
"@egovernments/digit-ui-components": "0.0.2-beta.7",
"babel-loader": "8.1.0",
"clean-webpack-plugin": "4.0.0",
"css-loader": "5.2.6",
Expand Down
4 changes: 4 additions & 0 deletions react/ui-components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.2-beta.7] - 2024-06-24
### New Changes
- Added ViewMore button for Timeline Molecule.

## [0.0.2-beta.6] - 2024-06-19
### New Changes
- Added BreadCrumb Component.
Expand Down
4 changes: 2 additions & 2 deletions react/ui-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-components",
"version": "0.0.2-beta.6",
"version": "0.0.2-beta.7",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.modern.js",
Expand Down Expand Up @@ -51,7 +51,7 @@
"dist"
],
"dependencies": {
"@egovernments/digit-ui-components-css": "0.0.2-beta.5",
"@egovernments/digit-ui-components-css": "0.0.2-beta.6",
"@egovernments/digit-ui-libraries": "1.8.1-beta.1",
"@egovernments/digit-ui-svg-components": "1.0.4",
"@googlemaps/js-api-loader": "1.13.10",
Expand Down
5 changes: 3 additions & 2 deletions react/ui-components/src/atoms/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const Timeline = ({
individualElementStyles,
showConnector,
className,
isLastStep
isLastStep,
isNextActiveStep
}) => {
const [showDetails, setShowDetails] = useState(false);

Expand Down Expand Up @@ -76,7 +77,7 @@ const Timeline = ({
</div>
)}
</div>
{showConnector && !isLastStep && <div className={`connector-line ${variant || ""}`} />}
{showConnector && !isLastStep && <div className={`connector-line ${variant || ""} ${isNextActiveStep ? "nextActiveStep": "" }`} />}
<div className="timeline-content">
<div className="timeline-info">
<div className="timeline-label">
Expand Down
66 changes: 61 additions & 5 deletions react/ui-components/src/molecules/TimelineMolecule.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,68 @@
import React,{Children} from "react";
import { Timeline } from "../atoms";
import React, { Children, useState,useMemo } from "react";
import { Timeline, Button, StringManipulator } from "../atoms";

const sortTimelines = (children) => {
const variantsOrder = {
upcoming: 1,
inprogress: 2,
completed: 3,
};

return Children.toArray(children).sort((a, b) => {
const variantA = variantsOrder[a.props.variant] || 4;
const variantB = variantsOrder[b.props.variant] || 4;
return variantA - variantB;
});
};

const TimelineMolecule = ({ children, initialVisibleCount, viewMoreLabel,viewLessLabel }) => {
const sortedChildren = useMemo(() => sortTimelines(children), [children]);

const [visibleCount, setVisibleCount] = useState(initialVisibleCount);
const [isExpanded, setIsExpanded] = useState(false);


const toggleViewMoreItems = () => {
if (isExpanded) {
setVisibleCount(initialVisibleCount);
} else {
setVisibleCount(sortedChildren.length);
}
setIsExpanded(!isExpanded);
};

let currentActiveStep = -1;
sortedChildren.forEach((child, index) => {
console.log(child.props, "child ");
if (child.props.variant === "inprogress") {
currentActiveStep = index;
}
});

const visibleChildren = sortedChildren.slice(0, visibleCount);


const TimelineMolecule = ({ children }) => {
return (
<div className="digit-timeline-molecule">
{Children.map(children, (child, index) => (
<Timeline {...child.props} isLastStep={index === Children.count(children) - 1} />
{Children.map(visibleChildren, (child, index) => (
<Timeline
{...child.props}
isLastStep={index === Children.count(visibleChildren) - 1}
isNextActiveStep={currentActiveStep - 1 === index}
/>
))}
{initialVisibleCount && (
<div className="view-more-container">
<Button
isSuffix={true}
icon={isExpanded ? "ArrowDropUp" : "ArrowDropDown"}
variation={"teritiary"}
onClick={toggleViewMoreItems}
label = {isExpanded ? (StringManipulator("CAPITALIZEFIRSTLETTER", viewLessLabel) || "View Less") : (StringManipulator("CAPITALIZEFIRSTLETTER", viewMoreLabel) || "View More")}
size={"medium"}
></Button>
</div>
)}
</div>
);
};
Expand Down
Loading

0 comments on commit cf10937

Please sign in to comment.