Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

Improve ProgressBar docs page and block examples (#1623)

Ted McDonald1d6ff32dd0ac
diff --git a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarCustomFormat.doc.mjs b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarCustomFormat.doc.mjs
index 66bbddfbce..cab3ddf346 100644
--- a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarCustomFormat.doc.mjs
+++ b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarCustomFormat.doc.mjs
@@ -3,8 +3,8 @@ export const doc = {
type: 'block',
name: 'ProgressBar — Custom Format',
description:
- 'Progress bar with a custom value label formatter showing disk usage in GB.',
+ 'Progress bar with a custom value label showing disk usage in GB.',
isReady: true,
aspectRatio: 4 / 3,
- componentsUsed: ['ProgressBar'],
+ componentsUsed: ['ProgressBar', 'Center', 'VStack', 'Text'],
};
diff --git a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarCustomFormat.tsx b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarCustomFormat.tsx
index 79f6292d87..d218839df5 100644
--- a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarCustomFormat.tsx
+++ b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarCustomFormat.tsx
@@ -1,27 +1,27 @@
'use client';
import {XDSProgressBar} from '@xds/core/ProgressBar';
+import {XDSCenter} from '@xds/core/Center';
+import {XDSVStack} from '@xds/core/Layout';
+import {XDSText} from '@xds/core/Text';
export default function ProgressBarCustomFormat() {
return (
- <div style={{width: 300}}>
- <XDSProgressBar
- value={3.2}
- max={5}
- label="Disk usage"
- hasValueLabel
- formatValueLabel={(value: number, max: number) =>
- `${value} GB / ${max} GB`
- }
- />
- <div
- style={{
- fontSize: 12,
- color: 'var(--color-text-secondary)',
- marginTop: 4,
- }}>
- 1.8 GB remaining
- </div>
- </div>
+ <XDSCenter width={300}>
+ <XDSVStack gap={1}>
+ <XDSProgressBar
+ value={3.2}
+ max={5}
+ label="Disk usage"
+ hasValueLabel
+ formatValueLabel={(value: number, max: number) =>
+ `${value} GB / ${max} GB`
+ }
+ />
+ <XDSText type="supporting" color="secondary">
+ 1.8 GB remaining
+ </XDSText>
+ </XDSVStack>
+ </XDSCenter>
);
}
diff --git a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarIndeterminate.doc.mjs b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarIndeterminate.doc.mjs
index c8fa5e5576..052407d7a4 100644
--- a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarIndeterminate.doc.mjs
+++ b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarIndeterminate.doc.mjs
@@ -6,5 +6,5 @@ export const doc = {
'Indeterminate progress bar for operations with unknown duration.',
isReady: true,
aspectRatio: 4 / 3,
- componentsUsed: ['ProgressBar'],
+ componentsUsed: ['ProgressBar', 'Center'],
};
diff --git a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarIndeterminate.tsx b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarIndeterminate.tsx
index bcfa40e7c2..abbe402049 100644
--- a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarIndeterminate.tsx
+++ b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarIndeterminate.tsx
@@ -1,11 +1,12 @@
'use client';
import {XDSProgressBar} from '@xds/core/ProgressBar';
+import {XDSCenter} from '@xds/core/Center';
export default function ProgressBarIndeterminate() {
return (
- <div style={{width: 300}}>
+ <XDSCenter width={300}>
<XDSProgressBar isIndeterminate label="Loading..." />
- </div>
+ </XDSCenter>
);
}
diff --git a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarSemanticVariants.doc.mjs b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarSemanticVariants.doc.mjs
index 8f1774abd5..08f876b0e9 100644
--- a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarSemanticVariants.doc.mjs
+++ b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarSemanticVariants.doc.mjs
@@ -3,8 +3,8 @@ export const doc = {
type: 'block',
name: 'ProgressBar — Semantic Variants',
description:
- 'All five semantic color variants side by side: accent, positive, warning, negative, and neutral.',
+ 'All semantic color variants stacked vertically.',
isReady: true,
aspectRatio: 4 / 3,
- componentsUsed: ['ProgressBar'],
+ componentsUsed: ['ProgressBar', 'Center', 'VStack'],
};
diff --git a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarSemanticVariants.tsx b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarSemanticVariants.tsx
index bf1ebf2a26..79f5c5ffca 100644
--- a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarSemanticVariants.tsx
+++ b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarSemanticVariants.tsx
@@ -1,15 +1,19 @@
'use client';
import {XDSProgressBar} from '@xds/core/ProgressBar';
+import {XDSCenter} from '@xds/core/Center';
+import {XDSVStack} from '@xds/core/Layout';
export default function ProgressBarSemanticVariants() {
return (
- <div style={{display: 'flex', flexDirection: 'column', gap: 16, width: 300}}>
- <XDSProgressBar value={60} label="Accent" variant="accent" hasValueLabel />
- <XDSProgressBar value={80} label="Positive" variant="positive" hasValueLabel />
- <XDSProgressBar value={50} label="Warning" variant="warning" hasValueLabel />
- <XDSProgressBar value={92} label="Negative" variant="negative" hasValueLabel />
- <XDSProgressBar value={35} label="Neutral" variant="neutral" hasValueLabel />
- </div>
+ <XDSCenter width={300}>
+ <XDSVStack gap={4}>
+ <XDSProgressBar value={60} label="Accent" variant="accent" hasValueLabel />
+ <XDSProgressBar value={80} label="Positive" variant="positive" hasValueLabel />
+ <XDSProgressBar value={50} label="Warning" variant="warning" hasValueLabel />
+ <XDSProgressBar value={92} label="Negative" variant="negative" hasValueLabel />
+ <XDSProgressBar value={35} label="Neutral" variant="neutral" hasValueLabel />
+ </XDSVStack>
+ </XDSCenter>
);
}
diff --git a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarWithValueLabel.doc.mjs b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarWithValueLabel.doc.mjs
index 47627516f8..6c97591b53 100644
--- a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarWithValueLabel.doc.mjs
+++ b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarWithValueLabel.doc.mjs
@@ -3,8 +3,8 @@ export const doc = {
type: 'block',
name: 'ProgressBar — With Value Label',
description:
- 'Progress bar displaying its current percentage alongside the label.',
+ 'Progress bar with its current percentage displayed.',
isReady: true,
aspectRatio: 4 / 3,
- componentsUsed: ['ProgressBar'],
+ componentsUsed: ['ProgressBar', 'Center'],
};
diff --git a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarWithValueLabel.tsx b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarWithValueLabel.tsx
index d6853a9d64..73a97a7904 100644
--- a/packages/cli/templates/blocks/components/ProgressBar/ProgressBarWithValueLabel.tsx
+++ b/packages/cli/templates/blocks/components/ProgressBar/ProgressBarWithValueLabel.tsx
@@ -1,11 +1,12 @@
'use client';
import {XDSProgressBar} from '@xds/core/ProgressBar';
+import {XDSCenter} from '@xds/core/Center';
export default function ProgressBarWithValueLabel() {
return (
- <div style={{width: 300}}>
+ <XDSCenter width={300}>
<XDSProgressBar value={75} label="Storage used" hasValueLabel />
- </div>
+ </XDSCenter>
);
}
diff --git a/packages/core/src/ProgressBar/ProgressBar.doc.mjs b/packages/core/src/ProgressBar/ProgressBar.doc.mjs
index 31a16cf971..4df8117b65 100644
--- a/packages/core/src/ProgressBar/ProgressBar.doc.mjs
+++ b/packages/core/src/ProgressBar/ProgressBar.doc.mjs
@@ -67,11 +67,14 @@ export const docs = {
},
usage: {
description:
- 'ProgressBar displays the completion progress of a process as a horizontal bar. Use it for determinate operations where the duration is known, or as an indeterminate indicator when progress cannot be calculated.',
+ 'A horizontal bar showing the completion progress of a task. Use it for operations where the duration is known, or as an animated indicator when progress can\'t be calculated. Supports semantic color variants, value labels, and custom formatting.',
bestPractices: [
- { guidance: true, description: 'Use a determinate bar when the total amount of work is known, and switch to indeterminate only when it is not.' },
- { guidance: true, description: 'Choose a semantic color variant that reflects the nature of the process — accent for neutral, positive for success, warning or negative for alerts.' },
- { guidance: false, description: 'Add custom label placements or status icons inside the bar — compose them alongside using layout components.' },
+ { guidance: true, description: "Use a determinate bar when the total amount of work is known, and indeterminate when it's not." },
+ { guidance: true, description: 'Choose a color variant that matches the context — accent for general progress, positive for success, warning or negative for alerts.' },
+ { guidance: true, description: "Always provide a label, even if hidden — screen readers need it to announce what's loading." },
+ { guidance: false, description: 'Place icons or labels inside the bar — compose them alongside it using layout components.' },
+ { guidance: false, description: "Use a progress bar for instant actions — it's meant for operations that take noticeable time." },
+ { guidance: false, description: 'Use multiple progress bars stacked together for the same operation — use one bar with a value label instead.' },
],
},
};
@@ -143,11 +146,14 @@ export const docsZh = {
},
usage: {
description:
- 'ProgressBar displays the completion progress of a process as a horizontal bar. Use it for determinate operations where the duration is known, or as an indeterminate indicator when progress cannot be calculated.',
+ 'A horizontal bar showing the completion progress of a task. Use it for operations where the duration is known, or as an animated indicator when progress can\'t be calculated. Supports semantic color variants, value labels, and custom formatting.',
bestPractices: [
- { guidance: true, description: 'Use a determinate bar when the total amount of work is known, and switch to indeterminate only when it is not.' },
- { guidance: true, description: 'Choose a semantic color variant that reflects the nature of the process — accent for neutral, positive for success, warning or negative for alerts.' },
- { guidance: false, description: 'Add custom label placements or status icons inside the bar — compose them alongside using layout components.' },
+ { guidance: true, description: "Use a determinate bar when the total amount of work is known, and indeterminate when it's not." },
+ { guidance: true, description: 'Choose a color variant that matches the context — accent for general progress, positive for success, warning or negative for alerts.' },
+ { guidance: true, description: "Always provide a label, even if hidden — screen readers need it to announce what's loading." },
+ { guidance: false, description: 'Place icons or labels inside the bar — compose them alongside it using layout components.' },
+ { guidance: false, description: "Use a progress bar for instant actions — it's meant for operations that take noticeable time." },
+ { guidance: false, description: 'Use multiple progress bars stacked together for the same operation — use one bar with a value label instead.' },
],
},
};
@@ -158,11 +164,14 @@ export const docsDense = {
'Progress bar for displaying determinate or indeterminate progress.',
usage: {
description:
- 'ProgressBar displays the completion progress of a process as a horizontal bar. Use it for determinate operations where the duration is known, or as an indeterminate indicator when progress cannot be calculated.',
+ 'A horizontal bar showing the completion progress of a task. Use it for operations where the duration is known, or as an animated indicator when progress can\'t be calculated. Supports semantic color variants, value labels, and custom formatting.',
bestPractices: [
- { guidance: true, description: 'Use a determinate bar when the total amount of work is known, and switch to indeterminate only when it is not.' },
- { guidance: true, description: 'Choose a semantic color variant that reflects the nature of the process — accent for neutral, positive for success, warning or negative for alerts.' },
- { guidance: false, description: 'Add custom label placements or status icons inside the bar — compose them alongside using layout components.' },
+ { guidance: true, description: "Use a determinate bar when the total amount of work is known, and indeterminate when it's not." },
+ { guidance: true, description: 'Choose a color variant that matches the context — accent for general progress, positive for success, warning or negative for alerts.' },
+ { guidance: true, description: "Always provide a label, even if hidden — screen readers need it to announce what's loading." },
+ { guidance: false, description: 'Place icons or labels inside the bar — compose them alongside it using layout components.' },
+ { guidance: false, description: "Use a progress bar for instant actions — it's meant for operations that take noticeable time." },
+ { guidance: false, description: 'Use multiple progress bars stacked together for the same operation — use one bar with a value label instead.' },
],
},
propDescriptions: {