mirror of
https://github.com/Steffo99/bluelib.git
synced 2024-12-22 11:34:21 +00:00
Fix whatever I did last night
This commit is contained in:
parent
9c9db45aed
commit
1dc090eb62
2 changed files with 9 additions and 4 deletions
|
@ -14,10 +14,13 @@ export interface BaseElementProps extends React.HTMLProps<any> {
|
|||
disabled?: boolean,
|
||||
builtinColor?: BuiltinColor,
|
||||
customColor?: typeof Color,
|
||||
childRef?: React.RefObject<HTMLElement>,
|
||||
}
|
||||
|
||||
|
||||
export const BaseElement = React.forwardRef(({kind = "div", bluelibClassNames, disabled = false, builtinColor, customColor, ...props}: BaseElementProps, ref): JSX.Element => {
|
||||
// forwardRef has some strange behaviour in TypeScript, so I'm not using it
|
||||
|
||||
export const BaseElement = ({kind = "div", bluelibClassNames, disabled = false, builtinColor, customColor, childRef, ...props}: BaseElementProps): JSX.Element => {
|
||||
// Set the Bluelib color
|
||||
if(customColor) {
|
||||
props.style = {...props.style, ...Colors.colorToBluelibStyle("color", customColor)}
|
||||
|
@ -37,7 +40,9 @@ export const BaseElement = React.forwardRef(({kind = "div", bluelibClassNames, d
|
|||
props.className = mergeClassNames(props.className, bluelibClassNames)
|
||||
|
||||
// Set the ref on the child element
|
||||
props.ref = ref
|
||||
if(childRef) {
|
||||
props.ref = childRef
|
||||
}
|
||||
|
||||
return React.createElement(kind, props)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ export const Bluelib = (props: BluelibProps): JSX.Element => {
|
|||
const element = React.useMemo(
|
||||
() => (
|
||||
<BaseElement
|
||||
ref={ref}
|
||||
childRef={ref}
|
||||
kind={"div"}
|
||||
bluelibClassNames={"bluelib"}
|
||||
{...baseElementProps}
|
||||
|
|
Loading…
Reference in a new issue