-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Minor updates to Range, showcase improvements (#29)
Co-authored-by: Anand Gorantala <[email protected]>
- Loading branch information
1 parent
92538c1
commit 2dfdfab
Showing
11 changed files
with
363 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import cn from 'clsx'; | ||
import { ForwardedRef, forwardRef, ReactElement } from 'react'; | ||
import { Number } from '../../number'; | ||
|
||
import type { RangeValueProps } from '../range.types'; | ||
import { useRange } from '../range.context'; | ||
|
||
export const RangeMaxValue = forwardRef(( | ||
props: RangeValueProps, | ||
forwardedRef: ForwardedRef<HTMLSpanElement> | null, | ||
): ReactElement => { | ||
const rangeCtx = useRange(); | ||
|
||
if (!rangeCtx) { | ||
throw new Error('Range.MaxValue should be used within a RangeProvider'); | ||
} | ||
|
||
const { value } = rangeCtx; | ||
|
||
const { | ||
className, | ||
...rest | ||
} = props; | ||
|
||
return ( | ||
<Number {...rest} value={value[1]} className={cn('lui-range-min-value', className)} ref={forwardedRef} /> | ||
); | ||
}); | ||
|
||
RangeMaxValue.displayName = "Range.MaxValue"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import cn from 'clsx'; | ||
import { ForwardedRef, forwardRef, ReactElement } from 'react'; | ||
import { Number } from '../../number'; | ||
|
||
import type { RangeValueProps } from '../range.types'; | ||
import { useRange } from '../range.context'; | ||
|
||
export const RangeMinValue = forwardRef(( | ||
props: RangeValueProps, | ||
forwardedRef: ForwardedRef<HTMLSpanElement> | null, | ||
): ReactElement => { | ||
const rangeCtx = useRange(); | ||
|
||
if (!rangeCtx) { | ||
throw new Error('Range.MinValue should be used within a RangeProvider'); | ||
} | ||
|
||
const { value } = rangeCtx; | ||
|
||
const { | ||
className, | ||
...rest | ||
} = props; | ||
|
||
return ( | ||
<Number {...rest} value={value[0]} className={cn('lui-range-min-value', className)} ref={forwardedRef} /> | ||
); | ||
}); | ||
|
||
RangeMinValue.displayName = "Range.MinValue"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.