-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(web-react):
UNSAFE_classname
in elementTypes
components
- `styleProps` updated to handle `UNSAFE_classname` in elementTypes components - `DropdownTrigger` duplicated classNames fixed and marked as spirit component - `Button` component marked as spirit component - Added global types for `spiritComponent` prop
- Loading branch information
1 parent
9b9c1fc
commit d407e78
Showing
12 changed files
with
165 additions
and
73 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
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
23 changes: 9 additions & 14 deletions
23
packages/web-react/src/components/Tooltip/TooltipTrigger.tsx
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 |
---|---|---|
@@ -1,34 +1,29 @@ | ||
'use client'; | ||
|
||
import React, { ElementType, ReactNode } from 'react'; | ||
import React from 'react'; | ||
import { useStyleProps } from '../../hooks'; | ||
import { StyleProps, TransferProps } from '../../types'; | ||
import { TooltipTriggerProps } from '../../types'; | ||
import { useTooltipContext } from './TooltipContext'; | ||
|
||
interface TooltipTriggerProps extends StyleProps, TransferProps { | ||
elementType?: ElementType | string; | ||
children?: string | ReactNode | ((props: { isOpen: boolean }) => ReactNode); | ||
} | ||
|
||
const defaultProps: TooltipTriggerProps = { | ||
const defaultProps: Partial<TooltipTriggerProps> = { | ||
elementType: 'button', | ||
children: null, | ||
}; | ||
|
||
const TooltipTrigger = (props: TooltipTriggerProps) => { | ||
const propsWithDefaults = { ...defaultProps, ...props }; | ||
const { elementType = 'button', children, ...rest } = propsWithDefaults; | ||
const { elementType: ElementTag = 'button', children, ...rest } = propsWithDefaults; | ||
const { id, isOpen, triggerRef, getReferenceProps } = useTooltipContext(); | ||
|
||
const Component = elementType; | ||
|
||
const { styleProps: triggerStyleProps, props: transferProps } = useStyleProps(rest); | ||
const { styleProps: triggerStyleProps, props: transferProps } = useStyleProps({ ElementTag, ...rest }); | ||
|
||
return ( | ||
<Component {...transferProps} {...triggerStyleProps} id={id} ref={triggerRef} {...getReferenceProps()}> | ||
<ElementTag {...transferProps} {...triggerStyleProps} id={id} ref={triggerRef} {...getReferenceProps()}> | ||
{typeof children === 'function' ? children({ isOpen }) : children} | ||
</Component> | ||
</ElementTag> | ||
); | ||
}; | ||
|
||
TooltipTrigger.spiritComponent = 'TooltipTrigger'; | ||
|
||
export default TooltipTrigger; |
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.