Skip to content

Commit

Permalink
Adding missing support for disabled state in color hooks docs (#6278)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktabors committed Apr 30, 2024
1 parent e352bda commit e1f3c14
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 6 additions & 4 deletions packages/@react-aria/color/docs/useColorSlider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const TRACK_THICKNESS = 28;
const THUMB_SIZE = 20;

function ColorSlider(props) {
let {isDisabled} = props;
let {locale} = useLocale();
let state = useColorSliderState({...props, locale});
let trackRef = React.useRef(null);
Expand Down Expand Up @@ -145,20 +146,21 @@ function ColorSlider(props) {
...trackProps.style,
height: TRACK_THICKNESS,
width: '100%',
borderRadius: 4
borderRadius: 4,
background: isDisabled ? 'rgb(142, 142, 142)' : trackProps.style.background
}}>
<div
{...thumbProps}
style={{
...thumbProps.style,
top: TRACK_THICKNESS / 2,
border: '2px solid white',
background: isDisabled ? 'rgb(142, 142, 142)' : state.getDisplayColor().toString('css'),
border: `2px solid ${isDisabled ? 'rgb(142, 142, 142)' : 'white'}`,
boxShadow: '0 0 0 1px black, inset 0 0 0 1px black',
width: isFocusVisible ? TRACK_THICKNESS + 4 : THUMB_SIZE,
height: isFocusVisible ? TRACK_THICKNESS + 4 : THUMB_SIZE,
borderRadius: '50%',
boxSizing: 'border-box',
background: state.getDisplayColor().toString('css')
boxSizing: 'border-box'
}}>
<input ref={inputRef} {...inputProps} {...focusProps} />
</div>
Expand Down
11 changes: 9 additions & 2 deletions packages/@react-aria/color/docs/useColorWheel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const TRACK_THICKNESS = 28;
const THUMB_SIZE = 20;

function ColorWheel(props) {
let {isDisabled} = props;
let state = useColorWheelState(props);
let inputRef = React.useRef(null);
let {trackProps, inputProps, thumbProps} = useColorWheel({
Expand All @@ -105,12 +106,18 @@ function ColorWheel(props) {

return (
<div style={{position: 'relative', display: 'inline-block'}}>
<div {...trackProps} />
<div
{...trackProps}
style={{
...trackProps.style,
background: isDisabled ? 'rgb(142, 142, 142)' : trackProps.style.background
}} />
<div
{...thumbProps}
style={{
...thumbProps.style,
border: '2px solid white',
background: isDisabled ? 'rgb(142, 142, 142)' : state.getDisplayColor().toString('css'),
border: `2px solid ${isDisabled ? 'rgb(142, 142, 142)' : 'white'}`,
boxShadow: '0 0 0 1px black, inset 0 0 0 1px black',
width: isFocusVisible ? TRACK_THICKNESS + 4 : THUMB_SIZE,
height: isFocusVisible ? TRACK_THICKNESS + 4 : THUMB_SIZE,
Expand Down

1 comment on commit e1f3c14

@rspbot
Copy link

@rspbot rspbot commented on e1f3c14 Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.