Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(GetStartedCard): update to typescript #5719

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,92 @@
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';

import React, { PropsWithChildren, ReactNode } from 'react';
import PropTypes from 'prop-types';
import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';

import { getDevtoolsProps } from '../../global/js/utils/devtools';
import { pkg } from '../../settings';

import { Card } from '../Card';
const componentName = 'GetStartedCard';

type MetaData = {
id?: string;
icon?: () => void | object;
iconDescription?: string;
};

interface GetStartedCardProps extends PropsWithChildren {
/**
* Provide an optional class to be applied to the containing node.
*/
className?: string;

/**
* Optional if the card should be disabled
*/
disabled?: boolean;

/**
* Provides the action icon that's displayed at the footer of the card
*/
footerActionIcon: () => void | object;

/**
* Optional label for the top of the card
*/
label?: string | object | ReactNode;

/**
* Optional media content like an image to be placed in the card
*/
media?: ReactNode;

/**
* Icons that are displayed on the card showing the time and skill needed
*/
metadata: MetaData[];

/**
* Provides the callback for a clickable card
*/
onClick?: () => void;

/**
* Provides the icon that's displayed at the top of the card
*/
pictogram?: CarbonIconType;

/**
* Provides number for card for tasks in a sequential order
*/
sequence?: number;

/**
* Provides the status that's displayed at the top of the card
*/
status?: 'complete' | 'incomplete';

/**
* Title that's displayed at the top of the card
*/
title?: string | object | ReactNode;
}

/**
* GetStartedCard a card with icon, number, and media variants
*/
export let GetStartedCard = React.forwardRef(({ ...rest }, ref) => {
return (
<Card getStarted ref={ref} {...rest} {...getDevtoolsProps(componentName)} />
);
});
export let GetStartedCard = React.forwardRef(
(props: GetStartedCardProps, ref: React.Ref<HTMLDivElement>) => {
return (
<Card
{...{ ...props, ref, getStarted: true }}
{...getDevtoolsProps(componentName)}
/>
);
}
);

// Return a placeholder if not released and not enabled by feature flag
GetStartedCard = pkg.checkComponentEnabled(GetStartedCard, componentName);
Expand All @@ -43,6 +111,7 @@ GetStartedCard.propTypes = {
/**
* Provides the action icon that's displayed at the footer of the card
*/
/**@ts-ignore */
footerActionIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),

/**
Expand All @@ -62,6 +131,7 @@ GetStartedCard.propTypes = {
/**
* Icons that are displayed on the card showing the time and skill needed
*/
/**@ts-ignore */
metadata: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string,
Expand All @@ -78,6 +148,7 @@ GetStartedCard.propTypes = {
/**
* Provides the icon that's displayed at the top of the card
*/
/**@ts-ignore */
pictogram: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),

/**
Expand Down
Loading