Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(progress)!: convert value range to 0-100 #10622

Merged
Merged
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 @@ -21,7 +21,7 @@ describe("calcite-progress", () => {
});

describe("theme", () => {
themed(html`<calcite-progress text="optional text" type="determinate" value="0.5"></calcite-progress>`, {
themed(html`<calcite-progress text="optional text" type="determinate" value="50"></calcite-progress>`, {
"--calcite-progress-background-color": {
shadowSelector: `.${CSS.track}`,
targetProp: "backgroundColor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
title: "Components/Progress",
args: {
type: determinateType.defaultValue,
value: 0.8,
value: 80,
text: "",
},
argTypes: {
Expand All @@ -20,7 +20,7 @@ export default {
control: { type: "select" },
},
value: {
control: { type: "range", min: 0, max: 1, step: 0.01 },
control: { type: "range", min: 0, max: 100, step: 1 },
},
},
};
Expand All @@ -33,7 +33,7 @@ export const darkModeRTL_TestOnly = (): string => html`
<calcite-progress
class="calcite-mode-dark"
type="determinate"
value="0.2"
value="20"
text="% Complete (optional text)"
></calcite-progress>
`;
Expand Down
10 changes: 5 additions & 5 deletions packages/calcite-components/src/components/progress/progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Progress extends LitElement {
*/
@property({ reflect: true }) type: "indeterminate" | "determinate" = "determinate";

/** When `type` is `"determinate"`, the component's progress value with a range of 0.0 - 1.0. */
/** When `type` is `"determinate"`, specifies the component's value with a range of 0 to 100. */
@property() value = 0;

// #endregion
Expand All @@ -43,14 +43,14 @@ export class Progress extends LitElement {

override render(): JsxNode {
const isDeterminate = this.type === "determinate";
const barStyles = isDeterminate ? { width: `${this.value * 100}%` } : {};
const barStyles = isDeterminate ? { width: `${this.value}%` } : {};
const dir = getElementDir(this.el);
return (
<div
ariaLabel={this.label || this.text}
ariaValueMax={1}
ariaValueMin={0}
ariaValueNow={this.value}
ariaValueMax={isDeterminate ? "100" : undefined}
Elijbet marked this conversation as resolved.
Show resolved Hide resolved
ariaValueMin={isDeterminate ? "0" : undefined}
ariaValueNow={isDeterminate ? this.value : undefined}
role="progressbar"
>
<div class="track">
Expand Down
2 changes: 1 addition & 1 deletion packages/calcite-components/src/custom-theme/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export const progressTokens = {

export const progress = html`
<calcite-label layout="inline">
<calcite-progress text="optional text" type="determinate" value="0.5"></calcite-progress>
<calcite-progress text="optional text" type="determinate" value="50"></calcite-progress>
</calcite-label>
`;
Loading