diff --git a/samples/inputs/circular-progress-indicator/dynamic/src/DynamicCircularProgressStyle.css b/samples/inputs/circular-progress-indicator/dynamic/src/DynamicCircularProgressStyle.css
index b5b21b6e2f..e05d779cfd 100644
--- a/samples/inputs/circular-progress-indicator/dynamic/src/DynamicCircularProgressStyle.css
+++ b/samples/inputs/circular-progress-indicator/dynamic/src/DynamicCircularProgressStyle.css
@@ -1,4 +1,21 @@
igc-circular-progress {
--diameter: 100px;
--stroke-thickness: 5px;
+}
+
+.sample-content {
+ width: 300px;
+ display: flex;
+ align-items: center;
+ margin-top: 30px;
+}
+
+.circular-progress-container {
+ margin-right: 50px;
+ margin-left: 20px;
+}
+
+.buttons-container {
+ display: flex;
+ gap: 10px;
}
\ No newline at end of file
diff --git a/samples/inputs/circular-progress-indicator/dynamic/src/index.tsx b/samples/inputs/circular-progress-indicator/dynamic/src/index.tsx
index 92eee138bc..9ec6e04d48 100644
--- a/samples/inputs/circular-progress-indicator/dynamic/src/index.tsx
+++ b/samples/inputs/circular-progress-indicator/dynamic/src/index.tsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrCircularProgress, IgrCircularGradient, IgrIconButton, IgrCircularProgressModule, IgrCircularGradientModule, IgrIconButtonModule, registerIconFromText } from 'igniteui-react';
@@ -12,70 +12,53 @@ IgrIconButtonModule.register();
const addIconText = '';
const removeIconText = '';
-export default class DynamicCircularProgress extends React.Component {
+export default function DynamicCircularProgress() {
- public circularProgress: IgrCircularProgress;
- public addIcon: IgrIconButton;
- public removeIcon: IgrIconButton;
+ const [currentValue, setCurrentValue] = useState(0);
- constructor(props: any) {
- super(props);
+ useEffect(() => {
+ registerIconFromText("add", addIconText, "material");
+ registerIconFromText("remove", removeIconText, "material");
+ }, []);
- registerIconFromText(
- "add", addIconText, "material"
- );
- registerIconFromText(
- "remove", removeIconText, "material"
- );
-
- this.circularProgressRef = this.circularProgressRef.bind(this);
- this.onIconClick = this.onIconClick.bind(this);
- }
-
- public render(): JSX.Element {
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
- }
-
- public circularProgressRef(progress: IgrCircularProgress)
- {
- if(!progress) { return; }
- this.circularProgress = progress;
+ const incrementProgress = () => {
+ setCurrentValue((oldValue) => {
+ const newValue = oldValue + 10;
+ if (newValue > 100) {
+ return 100;
+ }
+ return newValue;
+ });
}
- public onIconClick(e: any) {
- const target = e.target as HTMLElement;
- const iconButton: any = target.closest('igc-icon-button');
- if(iconButton.getAttribute("classname") === "removeIcon")
- {
- if(this.circularProgress.value > 0) {
- this.circularProgress.value = this.circularProgress.value - 10;
- }
- else {
- this.circularProgress.value = 0;
+ const decrementProgress = () => {
+ setCurrentValue((oldValue) => {
+ const newValue = oldValue - 10;
+ if (newValue < 0) {
+ return 0;
}
- }
- else {
- this.circularProgress.value = this.circularProgress.value + 10;
- }
-
+ return newValue;
+ });
}
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
}
// rendering above class to the React DOM