Skip to content

Commit

Permalink
refactor(web) migrate core/EptyState to TypeScript
Browse files Browse the repository at this point in the history
Since it has been touched in a previous commit, moves it to TypeScript
although still being an unfinished component and its future is even
unknown.
  • Loading branch information
dgdavid committed Oct 29, 2024
1 parent d9554b1 commit 9719d0b
Showing 1 changed file with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
* find current contact information at www.suse.com.
*/

// @ts-check

import React from "react";
import {
EmptyState,
Expand All @@ -30,14 +28,21 @@ import {
Stack,
EmptyStateFooter,
EmptyStateActions,
EmptyStateProps,
EmptyStateHeaderProps,
} from "@patternfly/react-core";
import { Icon } from "~/components/layout";
import { IconProps } from "../layout/Icon";

/**
* @typedef {import("~/components/layout/Icon").IconProps} IconProps
* @typedef {import("@patternfly/react-core").EmptyStateProps} EmptyStateProps
* @typedef {import("@patternfly/react-core").EmptyStateHeaderProps} EmptyStateHeaderProps
*/
type EmptyStateWrapperProps = {
title: string;
icon: IconProps["name"];
color?: string;
headingLevel?: EmptyStateHeaderProps["headingLevel"];
noPadding?: boolean;
actions?: React.ReactNode;
children?: React.ReactNode;
};

/**
* Convenient wrapper for easing the use of PF/EmptyState component
Expand All @@ -46,15 +51,6 @@ import { Icon } from "~/components/layout";
* directly when dealing with a very specific UI use case and more freedom is
* needed.
*
* @param {object} props
* @param {string} props.title
* @param {IconProps["name"]} props.icon
* @param {string} [props.color="color-100"]
* @param {EmptyStateHeaderProps["headingLevel"]} [props.headingLevel="h4"]
* @param {boolean} [props.noPadding=false]
* @param {React.ReactNode} [props.actions]
* @param {React.ReactNode} [props.children]
* @param {EmptyStateProps} [props.rest]
* @todo write documentation
*/
export default function EmptyStateWrapper({
Expand All @@ -66,7 +62,7 @@ export default function EmptyStateWrapper({
actions,
children,
...rest
}) {
}: Partial<EmptyStateProps> & EmptyStateWrapperProps) {
// @ts-ignore
if (noPadding) rest.className = [rest.className, "no-padding"].join(" ").trim();

Expand Down

0 comments on commit 9719d0b

Please sign in to comment.