Skip to content

Commit

Permalink
Adding color property to Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
namnguyen20999 committed Aug 21, 2024
1 parent 58890d4 commit f417fd8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
19 changes: 17 additions & 2 deletions frontend/taipy-gui/src/components/Taipy/Progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useClassNames, useDynamicProperty } from "../../utils/hooks";
import { TaipyBaseProps } from "./utils";

interface ProgressBarProps extends TaipyBaseProps {
color?: string; //color of the progress indicator
linear?: boolean; //by default - false
showValue?: boolean; //by default - false
value?: number; //progress value
Expand Down Expand Up @@ -87,7 +88,16 @@ const Progress = (props: ProgressBarProps) => {
) : null}
<Box sx={{ ...linearSx, width: getBoxWidth(title, titleAnchor) }} className={className} id={props.id}>
<Box sx={linearPrgSx}>
<LinearProgress data-progress={value} variant="determinate" value={value} />
<LinearProgress
sx={{
"& .MuiLinearProgress-bar": {
background: props.color ? props.color : undefined,
},
}}
data-progress={value}
variant="determinate"
value={value}
/>
</Box>
<Box sx={linearTxtSx}>
<Typography variant="body2" color="text.secondary">{`${Math.round(value)}%`}</Typography>
Expand Down Expand Up @@ -126,7 +136,12 @@ const Progress = (props: ProgressBarProps) => {
) : null}
<LinearProgress
id={props.id}
sx={{ width: "100%" }}
sx={{
width: "100%",
"& .MuiLinearProgress-bar": {
background: props.color ? props.color : undefined,
},
}}
variant={value === undefined ? "indeterminate" : "determinate"}
value={value}
className={className}
Expand Down
1 change: 1 addition & 0 deletions taipy/gui/_renderers/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ class _Factory:
.set_value_and_default(var_type=PropertyType.dynamic_number, native_type=True)
.set_attributes(
[
("color", PropertyType.string),
("linear", PropertyType.boolean, False),
("show_value", PropertyType.boolean, False),
("title", PropertyType.dynamic_string),
Expand Down
16 changes: 16 additions & 0 deletions taipy/gui/viselements.json
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,11 @@
"doc": "If set, then the value represents the progress percentage that is shown.TODO - if unset?",
"default_property": true
},
{
"name": "color",
"type": "str",
"doc": "The color of the progress indicator."
},
{
"name": "linear",
"type": "bool",
Expand All @@ -1287,6 +1292,17 @@
"default_value": "False",
"doc": "If set to True, the progress value is shown."
},
{
"name": "title",
"type": "dynamic(str)",
"doc": "The title of the progress indicator."
},
{
"name": "title_anchor",
"type": "str",
"default_value": "\"bottom\"",
"doc": "The anchor of the title."
},
{
"name": "render",
"type": "dynamic(bool)",
Expand Down

0 comments on commit f417fd8

Please sign in to comment.