@@ -17,7 +17,7 @@ import {
17
17
} from 'react-aria-components' ;
18
18
import { bar , track } from './bar-utils' with { type : 'macro' } ;
19
19
import { createContext , forwardRef , ReactNode } from 'react' ;
20
- import { DOMRef , DOMRefValue } from '@react-types/shared' ;
20
+ import { DOMRef , DOMRefValue , LabelPosition } from '@react-types/shared' ;
21
21
import { FieldLabel } from './Field' ;
22
22
import { fieldLabel , getAllowedOverrides , StyleProps } from './style-utils' with { type : 'macro' } ;
23
23
import { keyframes } from '../style/style-macro' with { type : 'macro' } ;
@@ -37,8 +37,16 @@ interface ProgressBarStyleProps {
37
37
* Whether presentation is indeterminate when progress isn't known.
38
38
*/
39
39
isIndeterminate ?: boolean ,
40
- /** The static color style to apply. Useful when the button appears over a color background. */
41
- staticColor ?: 'white' | 'black'
40
+ /**
41
+ * The static color style to apply. Useful when the button appears over a color background.
42
+ */
43
+ staticColor ?: 'white' | 'black' ,
44
+ /**
45
+ * The label's overall position relative to the element it is labeling.
46
+ * @default 'top'
47
+ */
48
+ labelPosition ?: LabelPosition
49
+
42
50
}
43
51
44
52
export interface ProgressBarProps extends Omit < AriaProgressBarProps , 'children' | 'className' | 'style' > , ProgressBarStyleProps , StyleProps {
@@ -89,6 +97,7 @@ const trackStyles = style({
89
97
const fill = style < ProgressBarStyleProps > ( {
90
98
height : 'full' ,
91
99
borderStyle : 'none' ,
100
+ borderRadius : 'full' ,
92
101
backgroundColor : {
93
102
default : 'accent' ,
94
103
staticColor : {
@@ -117,17 +126,24 @@ const indeterminateAnimation = style({
117
126
118
127
function ProgressBar ( props : ProgressBarProps , ref : DOMRef < HTMLDivElement > ) {
119
128
[ props , ref ] = useSpectrumContextProps ( props , ref , ProgressBarContext ) ;
120
- let { label, size = 'M' , staticColor, isIndeterminate, UNSAFE_style, UNSAFE_className = '' } = props ;
129
+ let {
130
+ label, size = 'M' ,
131
+ staticColor,
132
+ isIndeterminate,
133
+ labelPosition = 'top' ,
134
+ UNSAFE_style,
135
+ UNSAFE_className = ''
136
+ } = props ;
121
137
let domRef = useDOMRef ( ref ) ;
122
138
return (
123
139
< AriaProgressBar
124
140
{ ...props }
125
141
ref = { domRef }
126
142
style = { UNSAFE_style }
127
- className = { UNSAFE_className + wrapper ( { ...props , size} , props . styles ) } >
143
+ className = { UNSAFE_className + wrapper ( { ...props , size, labelPosition } , props . styles ) } >
128
144
{ ( { percentage, valueText} ) => (
129
145
< >
130
- { label && < FieldLabel size = { size } labelAlign = "start" labelPosition = "top" staticColor = { staticColor } > { label } </ FieldLabel > }
146
+ { label && < FieldLabel size = { size } labelAlign = "start" labelPosition = { labelPosition } staticColor = { staticColor } > { label } </ FieldLabel > }
131
147
{ label && < span className = { valueStyles ( { size, labelAlign : 'end' , staticColor} ) } > { valueText } </ span > }
132
148
< div className = { trackStyles ( { ...props } ) } >
133
149
< div
0 commit comments