Created
February 13, 2021 23:19
-
-
Save delianides/5490c81ba31328eeba5ae45e7dad9269 to your computer and use it in GitHub Desktop.
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
const BaseHTMLElement = <T extends keyof HTMLElementTagNameMap>( | |
htmlElement: T, | |
injectClasses = "" | |
): ((props: React.HTMLProps<unknown>) => React.ReactElement) => { | |
const Component = function (props: React.HTMLProps<unknown>) { | |
const { children, className, ...rest } = props; | |
return React.createElement( | |
htmlElement, | |
{ | |
className: `${className} max-w-4xl mx-auto ${injectClasses}`, | |
...rest, | |
}, | |
children | |
); | |
}; | |
Component.displayName = `MDXCustomHTML<${htmlElement}>`; | |
return Component; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment