Commit 4f013030 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Migrate presentational-component to TS

parent ba92ed1b
import classnames from 'classnames';
import type { JSX, ComponentChildren, Ref } from 'preact';
import { downcastRef } from './type-coercions';
/**
* @typedef {import('preact').JSX.HTMLAttributes<HTMLDivElement>} HTMLDivAttributes
*/
type HTMLDivAttributes = JSX.HTMLAttributes<HTMLDivElement>;
/**
* @typedef PresentationalComponentProps
* @prop {import('preact').ComponentChildren} [children]
* @prop {string|string[]} [classes] - Optional extra CSS classes to append to the
* component's default classes
* @prop {import('preact').Ref<HTMLElement>} [elementRef]
*/
export type PresentationalComponentProps = {
children?: ComponentChildren;
/** Optional extra CSS classes to append to the component's default classes */
classes?: string | string[];
elementRef?: Ref<HTMLElement>;
};
/**
* Make a presentational component which wraps children to apply layout and
* styling.
*
* @param {string} displayName
* @param {string|string[]} classes - CSS classes for this component
* @param classes - CSS classes for this component
*/
export function makePresentationalComponent(displayName, classes) {
/**
* @param {HTMLDivAttributes & PresentationalComponentProps} props
*/
export function makePresentationalComponent(
displayName: string,
classes: string | string[]
) {
function PresentationalComponent({
classes: extraClasses,
elementRef,
children,
...htmlAttributes
}) {
}: HTMLDivAttributes & PresentationalComponentProps) {
return (
<div
className={classnames(classes, extraClasses)}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment