Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ const meta: Meta<typeof ProgressBar> = {
type: "number",
},
},
percentage: {
control: {
type: "boolean",
},
},
},
args: {
label: "Loading something...",
value: 70,
max: 100,
percentage: false,
},
decorators: [
(Story) => (
Expand Down
2 changes: 1 addition & 1 deletion client/apollo/css/src/ProgressBar/ProgressBarApollo.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "./ProgressBarCommon.css";

.af-progress-bar {
--progress-bar-radius: 0;
--progress-bar-radius: var(--radius-4);
--progress-bar-background-color: var(--neutral-14);
--progress-bar-appearance: var(--axa-blue-100);
}
16 changes: 16 additions & 0 deletions client/apollo/css/src/ProgressBar/ProgressBarCommon.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,19 @@
opacity: 0;
user-select: none;
}

.af-progress-bar__container {
display: flex;
flex-direction: row;
align-items: center;
gap: calc(8 / var(--font-size-base) * 1rem);

& > span {
width: 44px;
font: var(--font-family-base);
font-size: calc(16 / var(--font-size-base) * 1rem);
font-weight: 600;
line-height: 125%;
white-space: nowrap;
}
}
15 changes: 10 additions & 5 deletions client/apollo/react/src/ProgressBar/ProgressBarCommon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { useId, type ComponentProps, type ReactNode } from "react";

type ProgressBarProps = ComponentProps<"progress"> & {
label?: ReactNode;
percentage?: boolean;
};

export const ProgressBar = ({
id,
label,
percentage = false,
className,
...props
}: ProgressBarProps) => {
Expand All @@ -20,11 +22,14 @@ export const ProgressBar = ({
{label}
</label>
)}
<progress
id={inputId}
className={["af-progress-bar", className].filter(Boolean).join(" ")}
{...props}
/>
<div className="af-progress-bar__container">
<progress
id={inputId}
className={["af-progress-bar", className].filter(Boolean).join(" ")}
{...props}
/>
{Boolean(percentage) && <span>{props.value} %</span>}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cette information ne sera t-elle pas lue en double avec le progress par les lecteurs d'écran ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est fort probable.
Il faut tester pour s'en assurer et voir aussi le comportement dans le cas où on affiche le pourcentage et que l'on définit un label (le label est un texte caché qui permet d'être lu par les lecteurs d'écran dans ce composant)

</div>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe("ProgressBar Component", () => {
expect(progressBar).toBeInTheDocument();
expect(progressBar).toHaveValue(50);
expect(progressBar).toHaveAttribute("max", "100");
expect(screen.queryByText("50 %")).toBeNull();
});

it("applies custom className", () => {
Expand All @@ -38,4 +39,10 @@ describe("ProgressBar Component", () => {

expect(container.querySelector(`label[for=${id}]`)).not.toBeInTheDocument();
});

it("does render percentage if props percetage id provided", () => {
render(<ProgressBar id={id} value={50} max={100} percentage />);

expect(screen.getByText("50 %")).toBeInTheDocument();
});
});
Loading