forked from adobe/react-spectrum
-
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.
Add our wrapper elements for basic slots
- Loading branch information
1 parent
178f0d4
commit d6bbb26
Showing
3 changed files
with
76 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
import {DOMRef} from '@react-types/shared'; | ||
import {filterDOMProps} from '@react-aria/utils'; | ||
import {HeadingProps} from '@react-types/text'; | ||
import React, {ElementType, forwardRef} from 'react'; | ||
import {useDOMRef, useSlotProps, useStyleProps} from '@react-spectrum/utils'; | ||
import {Heading as RACHeading} from 'react-aria-components'; | ||
|
||
function Heading(props: HeadingProps, ref: DOMRef<HTMLHeadingElement>) { | ||
props = useSlotProps(props, 'heading'); | ||
|
||
let { | ||
children, | ||
...otherProps | ||
} = props; | ||
let {styleProps} = useStyleProps(otherProps); | ||
let domRef = useDOMRef(ref); | ||
|
||
return ( | ||
<RACHeading | ||
{...filterDOMProps(otherProps)} | ||
{...styleProps} | ||
level={props.level} | ||
ref={domRef}> | ||
{children} | ||
</RACHeading> | ||
); | ||
} | ||
|
||
/** | ||
* Heading is used to create various levels of typographic hierarchies. | ||
*/ | ||
const _Heading = forwardRef(Heading); | ||
export {_Heading as Heading}; |
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,29 @@ | ||
|
||
import {DOMRef} from '@react-types/shared'; | ||
import {filterDOMProps} from '@react-aria/utils'; | ||
import {KeyboardProps} from '@react-types/text'; | ||
import React, {forwardRef} from 'react'; | ||
import {useDOMRef, useSlotProps, useStyleProps} from '@react-spectrum/utils'; | ||
import {Keyboard as RACKeyboard} from 'react-aria-components'; | ||
|
||
function Keyboard(props: KeyboardProps, ref: DOMRef) { | ||
props = useSlotProps(props, 'keyboard'); | ||
let { | ||
children, | ||
...otherProps | ||
} = props; | ||
let {styleProps} = useStyleProps(otherProps); | ||
let domRef = useDOMRef(ref); | ||
|
||
return ( | ||
<RACKeyboard {...filterDOMProps(otherProps)} {...styleProps} ref={domRef}> | ||
{children} | ||
</RACKeyboard> | ||
); | ||
} | ||
|
||
/** | ||
* Keyboard represents text that specifies a keyboard command. | ||
*/ | ||
const _Keyboard = forwardRef(Keyboard); | ||
export {_Keyboard as Keyboard}; |
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