From e70cf1e509947b79bb41067c37cf0e60aa7ff769 Mon Sep 17 00:00:00 2001 From: devadula-nandan <47176249+devadula-nandan@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:50:15 +0530 Subject: [PATCH 1/4] chore(NotificationsEmptyState): converted file to typescript --- .../{NotificationsEmptyState.js => NotificationsEmptyState.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/{NotificationsEmptyState.js => NotificationsEmptyState.tsx} (100%) diff --git a/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js b/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx similarity index 100% rename from packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js rename to packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx From 3dab543319e9dc4e5b9fdacb3b9007bac6876061 Mon Sep 17 00:00:00 2001 From: devadula-nandan <47176249+devadula-nandan@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:54:55 +0530 Subject: [PATCH 2/4] refactor(NotificationsEmptyState): added TS types to the component --- .../NotificationsEmptyState.tsx | 70 ++++++++++++++++++- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx b/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx index 6f08083af0..89241a573e 100644 --- a/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx +++ b/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx @@ -6,7 +6,7 @@ */ // Import portions of React that are needed. -import React from 'react'; +import React, { ReactNode } from 'react'; // Other standard imports. import PropTypes from 'prop-types'; @@ -19,15 +19,79 @@ import { pkg } from '../../../settings'; import { EmptyStateContent } from '../EmptyStateContent'; import NotificationsIllustration from '../assets/NotificationsIllustration'; import { defaults } from '../EmptyState'; +import { ButtonProps } from '@carbon/react'; +import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon'; // The block part of our conventional BEM class names (blockClass__E--M). const blockClass = `${pkg.prefix}--empty-state`; const componentName = 'NotificationsEmptyState'; +interface NotificationsEmptyStateProps { + /** + * Empty state action button + */ + + action?: { + kind?: 'primary' | 'secondary' | 'tertiary'; + renderIcon?: CarbonIconType; + onClick?: ButtonProps['onClick']; + text?: string; + }; + + /** + * Provide an optional class to be applied to the containing node. + */ + className?: string; + + /** + * The alt text for empty state svg images. If not provided , title will be used. + */ + illustrationDescription?: string; + + /** + * Designates the position of the illustration relative to the content + */ + illustrationPosition?: 'top' | 'right' | 'bottom' | 'left'; + + /** + * Empty state illustration theme variations. + * To ensure you use the correct themed illustrations, you can conditionally specify light or dark + * based on your app's current theme value. Example: + * `illustrationTheme={appTheme === ('carbon--g100' || 'carbon--g90') ? 'dark' : 'light'}` + */ + illustrationTheme?: 'light' | 'dark'; + + /** + * Empty state link object + */ + link?: { + text?: string | ReactNode; + href?: string; + }; + + /** + * Empty state size + */ + size?: 'lg' | 'sm'; + + /** + * Empty state subtitle + */ + subtitle: string | ReactNode; + + /** + * Empty state title + */ + title: string | ReactNode; +} + /** * The `EmptyState` component follows the Carbon guidelines for empty states with some added specifications around illustration usage. For additional usage guidelines and documentation please refer to the links above. */ -export let NotificationsEmptyState = React.forwardRef( +export let NotificationsEmptyState = React.forwardRef< + HTMLDivElement, + NotificationsEmptyStateProps +>( ( { // The component props, in alphabetical order (for consistency). @@ -72,7 +136,7 @@ export let NotificationsEmptyState = React.forwardRef( link={link} size={size} subtitle={subtitle} - title={title} + title={title || ''} /> ); From 63c70e0fa4cd9e29b0d64116ea6d74603b699ee5 Mon Sep 17 00:00:00 2001 From: devadula-nandan <47176249+devadula-nandan@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:32:34 +0530 Subject: [PATCH 3/4] chore(NotificationsEmptyState): removed string type on subtitle and title --- .../NotificationsEmptyState/NotificationsEmptyState.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx b/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx index 89241a573e..49b4ea0121 100644 --- a/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx +++ b/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx @@ -77,12 +77,12 @@ interface NotificationsEmptyStateProps { /** * Empty state subtitle */ - subtitle: string | ReactNode; + subtitle: ReactNode; /** * Empty state title */ - title: string | ReactNode; + title: ReactNode; } /** From 05910b46808a06be17d87fe1920d4bdff07daad3 Mon Sep 17 00:00:00 2001 From: devadula-nandan <47176249+devadula-nandan@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:37:00 +0530 Subject: [PATCH 4/4] chore(NotificationsEmptyState): updated copyright year --- .../NotificationsEmptyState/NotificationsEmptyState.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx b/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx index 49b4ea0121..d0b23a12c9 100644 --- a/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx +++ b/packages/ibm-products/src/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.tsx @@ -1,5 +1,5 @@ /** - * Copyright IBM Corp. 2020, 2021 + * Copyright IBM Corp. 2020, 2024 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree.