Skip to content

Commit e1f3c14

Browse files
authored
Adding missing support for disabled state in color hooks docs (#6278)
1 parent e352bda commit e1f3c14

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

packages/@react-aria/color/docs/useColorSlider.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ const TRACK_THICKNESS = 28;
105105
const THUMB_SIZE = 20;
106106

107107
function ColorSlider(props) {
108+
let {isDisabled} = props;
108109
let {locale} = useLocale();
109110
let state = useColorSliderState({...props, locale});
110111
let trackRef = React.useRef(null);
@@ -145,20 +146,21 @@ function ColorSlider(props) {
145146
...trackProps.style,
146147
height: TRACK_THICKNESS,
147148
width: '100%',
148-
borderRadius: 4
149+
borderRadius: 4,
150+
background: isDisabled ? 'rgb(142, 142, 142)' : trackProps.style.background
149151
}}>
150152
<div
151153
{...thumbProps}
152154
style={{
153155
...thumbProps.style,
154156
top: TRACK_THICKNESS / 2,
155-
border: '2px solid white',
157+
background: isDisabled ? 'rgb(142, 142, 142)' : state.getDisplayColor().toString('css'),
158+
border: `2px solid ${isDisabled ? 'rgb(142, 142, 142)' : 'white'}`,
156159
boxShadow: '0 0 0 1px black, inset 0 0 0 1px black',
157160
width: isFocusVisible ? TRACK_THICKNESS + 4 : THUMB_SIZE,
158161
height: isFocusVisible ? TRACK_THICKNESS + 4 : THUMB_SIZE,
159162
borderRadius: '50%',
160-
boxSizing: 'border-box',
161-
background: state.getDisplayColor().toString('css')
163+
boxSizing: 'border-box'
162164
}}>
163165
<input ref={inputRef} {...inputProps} {...focusProps} />
164166
</div>

packages/@react-aria/color/docs/useColorWheel.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const TRACK_THICKNESS = 28;
9393
const THUMB_SIZE = 20;
9494

9595
function ColorWheel(props) {
96+
let {isDisabled} = props;
9697
let state = useColorWheelState(props);
9798
let inputRef = React.useRef(null);
9899
let {trackProps, inputProps, thumbProps} = useColorWheel({
@@ -105,12 +106,18 @@ function ColorWheel(props) {
105106

106107
return (
107108
<div style={{position: 'relative', display: 'inline-block'}}>
108-
<div {...trackProps} />
109+
<div
110+
{...trackProps}
111+
style={{
112+
...trackProps.style,
113+
background: isDisabled ? 'rgb(142, 142, 142)' : trackProps.style.background
114+
}} />
109115
<div
110116
{...thumbProps}
111117
style={{
112118
...thumbProps.style,
113-
border: '2px solid white',
119+
background: isDisabled ? 'rgb(142, 142, 142)' : state.getDisplayColor().toString('css'),
120+
border: `2px solid ${isDisabled ? 'rgb(142, 142, 142)' : 'white'}`,
114121
boxShadow: '0 0 0 1px black, inset 0 0 0 1px black',
115122
width: isFocusVisible ? TRACK_THICKNESS + 4 : THUMB_SIZE,
116123
height: isFocusVisible ? TRACK_THICKNESS + 4 : THUMB_SIZE,

0 commit comments

Comments
 (0)