Progress
A bar that shows where a value is between a min and a max: the progress of a work, a quota.
import { Progress } from "x4js"
setValue
setValue moves the bar; the value is kept by the code, Progress has no getValue.
export function setValue( ) {
let value = 30;
const progress = new Progress( { value, width: 300 } );
const label = new Label( { text: "30%" } );
const move = ( delta: number ) => {
value = Math.max( 0, Math.min( 100, value + delta ) );
progress.setValue( value );
label.setText( `${value}%` );
};
return new VBox( { content: [
progress,
new HBox( { content: [
new Button( { label: "-10", cls: "outline", click: ( ) => move( -10 ) } ),
new Button( { label: "+10", cls: "outline", click: ( ) => move( 10 ) } ),
label,
] } ),
] } );
}
Range
min and max: the bar is empty at min, full at max. Here 6 files of 8.
export function range( ) {
return new VBox( { content: [
new Label( { text: "6 files of 8" } ),
new Progress( { min: 0, max: 8, value: 6, width: 300 } ),
] } );
}
Busy
The class indeterm stripes the bar and moves it, while the length of the work is not known.
export function busy( ) {
const progress = new Progress( { value: 100, width: 300 } );
return new HBox( { content: [
progress,
new Button( { label: "Busy / idle", cls: "outline", click: ( ) => progress.toggleClass( "indeterm" ) } ),
] } );
}
Colors
A class of your own sets the variables of the bar, and its height.
export function colors( ) {
return new VBox( { cls: "bars", content: [
new Progress( { value: 80, width: 300, cls: "success" } ),
new Progress( { value: 45, width: 300, cls: "thick" } ),
] } );
}
.bars {
gap: 16px;
}
.x4progress.success {
--progress-color: var( --success-background );
}
.x4progress.thick {
height: 14px;
--progress-color: var( --color-violet-600 );
.bar {
}
}
For an assistant: llms.txt, llms-full.txt.