Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing support for disabled state in color hooks docs #6278

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/@react-aria/color/docs/useColorSlider.mdx
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
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