Skip to content

Commit

Permalink
corrections/changes applied
Browse files Browse the repository at this point in the history
  • Loading branch information
ekumamatthew committed Sep 27, 2022
1 parent 7b27511 commit 2a5d10f
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 64 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ dist
npm-debug.log*
yarn-debug.log*
yarn-error.log*


# package-lock json
.package-lock.json
4 changes: 4 additions & 0 deletions src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ const Accordion = (props: Props) => {
</ul>
</Component>
</ThemeProvider>



);
};





export default Accordion;

export { Accordion as CDBAccordion };
10 changes: 5 additions & 5 deletions src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Props {
flat ?: boolean,
size ?: string,
borderType ?: string,
color ?: string,
colors ?: string,
tag ?: string,
icon ?: any;
intensity ?: any,
Expand All @@ -21,7 +21,7 @@ const Badge = (props: Props) => {
const {
className,
tag,
color,
colors,
intensity,
children,
icon,
Expand All @@ -31,7 +31,7 @@ const Badge = (props: Props) => {
...attributes
} = props;
const badgeClasses = classNames(className);
const colors = `${color}${intensity.toString()}`;
const color = `${colors}${intensity.toString()}`;
const badgeComponent = (
<ThemeProvider theme={theme}>
<Component
Expand Down Expand Up @@ -60,7 +60,7 @@ const Badge = (props: Props) => {

Badge.defaultProps = {
tag: "span",
color: "primary",
colors: "primary",
borderType: "pill",
size: "medium",
intensity: "900",
Expand All @@ -72,7 +72,7 @@ Badge.propTypes = {
flat: PropTypes.bool,
size: PropTypes.string,
borderType: PropTypes.string,
color: PropTypes.string,
colors: PropTypes.string,
tag: PropTypes.string,
intensity: PropTypes.oneOf([50, 100, 200, 300, 400, 500, 600, 700, 800, 900]),
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Breadcrumb = (props: Props) => {
let children;

if (bold) {
children = React.Children.map(props.children, (child) => {
children = Children.map(props.children, (child) => {
return React.cloneElement(child, {
bold: true,
});
Expand Down
43 changes: 23 additions & 20 deletions src/components/Carousel/Carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, Fragment } from "react";
import React, { useState, Fragment, useEffect } from "react";
import PropTypes from "prop-types";
import classNames from "classnames";
import CarouselControl from "./CarouselControl";
Expand All @@ -8,7 +8,7 @@ import { Tag } from "./Carousel.style";
import { ThemeProvider } from "styled-components";
import { theme } from "../../theme";

class Carousel extends Component {
const Carousel = (props) => {
state = {
activeItem: this.props.activeItem,
initialLength: this.props.length,
Expand All @@ -17,10 +17,11 @@ class Carousel extends Component {
initialX: null,
initialY: null,
};
const [activeItems, set]

carouselRef = React.createRef();

componentDidMount() {
useEffect(() => {
const { interval, thumbnails, length } = this.props;
if (interval === false) {
return;
Expand All @@ -41,30 +42,30 @@ class Carousel extends Component {
}

this.setState({ initialLength: length });
}
}, [])

componentDidUpdate(prevProps, prevState) {
useEffect((prevProps, prevState) =>{
const { length } = this.props;
const initialLength = length;

if (prevState.initialLength !== length) {
this.setState({ initialLength });
}
}
},[])

componentWillUnmount() {
useEffect(() {
const { interval } = this.props;
if (interval === false) {
return;
}
this.clearCycleIntervalHandler();
}
},[])

clearCycleIntervalHandler = () => clearInterval(this.cycleInterval);
const clearCycleIntervalHandler = () => clearInterval(this.cycleInterval);

swipeAvailableHandler = () => this.setState({ swipeAvailable: true });
const swipeAvailableHandler = () => this.setState({ swipeAvailable: true });

restartInterval = () => {
const restartInterval = () => {
const { interval } = this.props;

if (interval !== false) {
Expand All @@ -73,23 +74,23 @@ class Carousel extends Component {
}
};

next = () => {
const next = () => {
const { activeItem, initialLength } = this.state;
const nextIndex = activeItem + 1;
const nextItem = nextIndex > initialLength ? 1 : nextIndex;

this.goToIndex(nextItem);
};

prev = () => {
const prev = () => {
const { activeItem, initialLength } = this.state;
const prevIndex = activeItem - 1;
const prevItem = prevIndex < 1 ? initialLength : prevIndex;

this.goToIndex(prevItem);
};

goToIndex = (item) => {
const goToIndex = (item) => {
this.setState({
...this.state,
activeItem: item,
Expand All @@ -98,7 +99,7 @@ class Carousel extends Component {
this.restartInterval();
};

startTouch = (e) => {
const startTouch = (e) => {
const { mobileGesture } = this.props;
if (mobileGesture !== false) {
this.setState({
Expand All @@ -108,7 +109,7 @@ class Carousel extends Component {
}
};

moveTouch = (e) => {
const moveTouch = (e) => {
this.setState({
swipeAvailable: false,
});
Expand Down Expand Up @@ -140,7 +141,7 @@ class Carousel extends Component {
});
};

getChildContext() {
const getChildContext = () => {
const { activeItem, initialLength } = this.state;
const { slide } = this.props;
return {
Expand All @@ -150,7 +151,9 @@ class Carousel extends Component {
};
}

render() {
return
<>

const {
activeItem,
children,
Expand All @@ -166,7 +169,7 @@ class Carousel extends Component {
testimonial,
thumbnails,
...attributes
} = this.props;
} = props;

const { initialLength, srcArray, swipeAvailable } = this.state;
const ariaLabel = "carousel";
Expand Down Expand Up @@ -257,7 +260,7 @@ class Carousel extends Component {
</Tag>
</ThemeProvider>
);
}
</>
}

Carousel.propTypes = {
Expand Down
7 changes: 4 additions & 3 deletions src/components/Carousel/CarouselCaption/CarouselCaption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ import classNames from "classnames";
import { ThemeProvider } from "styled-components";
import { theme } from "../../../theme";


interface Props{
children: React.ReactNode,
className: string,
tag: [Function, string],
as:any

}

const CarouselCaption = (props: Props) => {
const { children, className, tag, ...attributes } = props;
const { children, className, as, ...attributes } = props;

const classes = classNames("carousel-caption", className);

return (
<ThemeProvider theme={theme}>
<div data-test="carousel-caption" {...tag} {...attributes} className={classes}>
<div data-test="carousel-caption" {...attributes} className={classes}>
{children}
</div>
</ThemeProvider>
Expand All @@ -27,7 +29,6 @@ const CarouselCaption = (props: Props) => {

CarouselCaption.propTypes = {
children: PropTypes.node,

className: PropTypes.string,
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
};
Expand Down
43 changes: 23 additions & 20 deletions src/components/Carousel/CarouselItem/CarouselItem.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
import React, { Component } from "react";
import React, { useState, } from "react";
import PropTypes from "prop-types";
import classNames from "classnames";
import { ThemeProvider } from "styled-components";
import { theme } from "./../../../theme";

class CarouselItem extends Component {
moveForward = () => {
this.style = {
const CarouselItem = (props) =>{
const [style, setStyle] = useState({})
const [context, setContext] = useState({})

const moveForward = () => {
setStyle({
position: "absolute",
left: "100%",
};
})
};

moveBackwards = () => {
this.style = {
const moveBackwards = () => {
setStyle({
position: "absolute",
left: "-100%",
};
})
};

makeVisible = () => {
this.style = {
const makeVisible = () => {
setStyle({
left: "0",
};
})
};

render() {

let {
active,
children,
className,
itemId,
tag: Tag,
...attributes
} = this.props;
} = props;

let { slide, activeItem } = this.context;
setContext({ slide, activeItem })

itemId = parseInt(itemId, 10);

Expand All @@ -52,14 +55,14 @@ class CarouselItem extends Component {

if (slide) {
if (slideIndex < 0) {
this.moveForward();
setStyle(moveForward);
} else if (slideIndex > 0) {
this.moveBackwards();
setStyle(moveBackwards);
} else {
this.makeVisible();
setStyle(makeVisible);
}
} else {
this.makeVisible();
setStyle(makeVisible);
}

return (
Expand All @@ -68,13 +71,13 @@ class CarouselItem extends Component {
data-test="carousel-item"
{...attributes}
className={classes}
style={this.style}
style={style}
>
{children}
</Tag>
</ThemeProvider>
);
}

}

CarouselItem.propTypes = {
Expand Down
8 changes: 4 additions & 4 deletions src/components/Modal/Modal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from "react";
import React, { Component, useEffect } from "react";
import classNames from "classnames";
import PropTypes from "prop-types";
import { Transition } from "react-transition-group";
Expand All @@ -8,14 +8,14 @@ import { Component as StyledComponent } from "./Modal.style";
import { ThemeProvider } from "styled-components";
import { theme } from "./../../theme";

class Modal extends Component {
const Modal =() => {
state = {
initialIsOpen: this.props.isOpen || false,
};

modalContent = React.createRef();

componentDidUpdate = (prevProps, prevState) => {
useEffect((prevProps, prevState) => {
const { isOpen, overflowScroll } = this.props;
const overflowStatement = overflowScroll
? "overflow-hidden"
Expand All @@ -30,7 +30,7 @@ class Modal extends Component {
}
});
}
};
}, []);

handleOnEntered = (type, node) => {
if (type === "backdrop" && this.props.fade === false) {
Expand Down
Loading

0 comments on commit 2a5d10f

Please sign in to comment.