Skip to content

Commit

Permalink
feat: revert to using React.ReactElement
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhdaware committed Mar 23, 2023
1 parent 0781b27 commit 9772fbe
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 25 deletions.
6 changes: 5 additions & 1 deletion packages/blade/src/components/ActionList/ActionList.tsx
Expand Up @@ -60,7 +60,11 @@ type ActionListProps = {
* ```
*
*/
const ActionList = ({ children, surfaceLevel = 2, testID }: ActionListProps): JSX.Element => {
const ActionList = ({
children,
surfaceLevel = 2,
testID,
}: ActionListProps): React.ReactElement => {
const {
setOptions,
actionListItemRef,
Expand Down
4 changes: 2 additions & 2 deletions packages/blade/src/components/ActionList/ActionListFooter.tsx
Expand Up @@ -67,7 +67,7 @@ const StyledActionListFooter = styled(BaseBox)((props) => {
* />
* ```
*/
const _ActionListFooter = (props: ActionListFooterProps): JSX.Element => {
const _ActionListFooter = (props: ActionListFooterProps): React.ReactElement => {
const footerRef = React.useRef<HTMLDivElement | null>(null);
const {
setShouldIgnoreBlur,
Expand Down Expand Up @@ -163,7 +163,7 @@ const ActionListFooter = assignWithoutSideEffects(_ActionListFooter, {
componentId: componentIds.ActionListFooter,
});

const _ActionListFooterIcon = ({ icon }: { icon: IconComponent }): JSX.Element => {
const _ActionListFooterIcon = ({ icon }: { icon: IconComponent }): React.ReactElement => {
const Icon = icon;
return <Icon color="surface.text.muted.lowContrast" size="small" />;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/blade/src/components/ActionList/ActionListHeader.tsx
Expand Up @@ -46,7 +46,7 @@ type ActionListHeaderProps = {
* />
* ```
*/
const _ActionListHeader = (props: ActionListHeaderProps): JSX.Element => {
const _ActionListHeader = (props: ActionListHeaderProps): React.ReactElement => {
React.useEffect(() => {
React.Children.map(props.leading, (child) => {
if (!isValidAllowedChildren(child, componentIds.ActionListHeaderIcon)) {
Expand Down Expand Up @@ -75,7 +75,7 @@ const ActionListHeader = assignWithoutSideEffects(_ActionListHeader, {
componentId: componentIds.ActionListHeader,
});

const _ActionListHeaderIcon = ({ icon }: { icon: IconComponent }): JSX.Element => {
const _ActionListHeaderIcon = ({ icon }: { icon: IconComponent }): React.ReactElement => {
const Icon = icon;
return <Icon color="surface.text.muted.lowContrast" size="small" />;
};
Expand Down
14 changes: 9 additions & 5 deletions packages/blade/src/components/ActionList/ActionListItem.tsx
Expand Up @@ -72,7 +72,7 @@ const StyledSectionDivider = styled(BaseBox)((props) => ({
margin: `${makeSize(props.theme.spacing[1])} ${makeSize(props.theme.spacing[3])}`,
}));

const ActionListSectionDivider = (): JSX.Element => (
const ActionListSectionDivider = (): React.ReactElement => (
<StyledSectionDivider
{...makeAccessible({
role: getSeparatorRole(),
Expand Down Expand Up @@ -102,7 +102,7 @@ const _ActionListSection = ({
children,
testID,
_hideDivider,
}: ActionListSectionProps): JSX.Element => {
}: ActionListSectionProps): React.ReactElement => {
return (
<BaseBox
{...makeAccessible({
Expand Down Expand Up @@ -135,7 +135,7 @@ const ActionListSection = assignWithoutSideEffects(_ActionListSection, {
componentId: componentIds.ActionListSection,
});

const _ActionListItemIcon = ({ icon }: { icon: IconComponent }): JSX.Element => {
const _ActionListItemIcon = ({ icon }: { icon: IconComponent }): React.ReactElement => {
const Icon = icon;
const { intent, isDisabled } = React.useContext(ActionListItemContext);
return (
Expand All @@ -154,7 +154,11 @@ const ActionListItemIcon = assignWithoutSideEffects(_ActionListItemIcon, {
componentId: componentIds.ActionListItemIcon,
});

const _ActionListItemText = ({ children }: { children: StringChildrenType }): JSX.Element => {
const _ActionListItemText = ({
children,
}: {
children: StringChildrenType;
}): React.ReactElement => {
const { isDisabled } = React.useContext(ActionListItemContext);

return (
Expand Down Expand Up @@ -206,7 +210,7 @@ const makeActionListItemClickable = (
* </ActionList>
* ```
*/
const _ActionListItem = (props: ActionListItemProps): JSX.Element => {
const _ActionListItem = (props: ActionListItemProps): React.ReactElement => {
const {
activeIndex,
dropdownBaseId,
Expand Down
Expand Up @@ -19,7 +19,7 @@ type ActionListItemAssetProps = {
/**
*
*/
const _ActionListItemAsset = (props: ActionListItemAssetProps): JSX.Element => {
const _ActionListItemAsset = (props: ActionListItemAssetProps): React.ReactElement => {
const source = typeof props.src === 'string' ? { uri: props.src } : props.src;

return (
Expand Down
Expand Up @@ -12,7 +12,7 @@ type ActionListItemAssetProps = {
*/
alt: string;
};
const _ActionListItemAsset = (props: ActionListItemAssetProps): JSX.Element => {
const _ActionListItemAsset = (props: ActionListItemAssetProps): React.ReactElement => {
return <img src={props.src} alt={props.alt} width={size[16]} height={size[12]} />;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/blade/src/components/Card/Card.tsx
Expand Up @@ -81,7 +81,7 @@ type CardBodyProps = {
children: React.ReactNode;
} & TestID;

const _CardBody = ({ children, testID }: CardBodyProps): JSX.Element => {
const _CardBody = ({ children, testID }: CardBodyProps): React.ReactElement => {
useVerifyInsideCard('CardBody');

return <BaseBox {...metaAttribute({ name: MetaConstants.CardBody, testID })}>{children}</BaseBox>;
Expand Down
6 changes: 3 additions & 3 deletions packages/blade/src/components/Card/CardFooter.tsx
Expand Up @@ -32,7 +32,7 @@ const useIsMobile = (): boolean => {
return matchedDeviceType === 'mobile';
};

const _CardFooter = ({ children, testID }: CardFooterProps): JSX.Element => {
const _CardFooter = ({ children, testID }: CardFooterProps): React.ReactElement => {
const isMobile = useIsMobile();
useVerifyInsideCard('CardFooter');
useVerifyAllowedComponents(children, 'CardFooter', [
Expand Down Expand Up @@ -62,7 +62,7 @@ type CardFooterLeadingProps = {
title?: string;
subtitle?: string;
};
const _CardFooterLeading = ({ title, subtitle }: CardFooterLeadingProps): JSX.Element => {
const _CardFooterLeading = ({ title, subtitle }: CardFooterLeadingProps): React.ReactElement => {
useVerifyInsideCard('CardFooterLeading');

return (
Expand Down Expand Up @@ -90,7 +90,7 @@ type CardFooterTrailingProps = {
secondary?: CardFooterAction;
};
};
const _CardFooterTrailing = ({ actions }: CardFooterTrailingProps): JSX.Element => {
const _CardFooterTrailing = ({ actions }: CardFooterTrailingProps): React.ReactElement => {
const isMobile = useIsMobile();
useVerifyInsideCard('CardFooterTrailing');

Expand Down
18 changes: 9 additions & 9 deletions packages/blade/src/components/Card/CardHeader.tsx
Expand Up @@ -26,7 +26,7 @@ import {
import type { TestID } from '~src/_helpers/types';
import { assignWithoutSideEffects } from '~src/utils/assignWithoutSideEffects';

const _CardHeaderIcon = ({ icon: Icon }: { icon: IconComponent }): JSX.Element => {
const _CardHeaderIcon = ({ icon: Icon }: { icon: IconComponent }): React.ReactElement => {
useVerifyInsideCard('CardHeaderIcon');

return <Icon color="surface.text.normal.lowContrast" size="xlarge" />;
Expand All @@ -35,7 +35,7 @@ const CardHeaderIcon = assignWithoutSideEffects(_CardHeaderIcon, {
componentId: ComponentIds.CardHeaderIcon,
});

const _CardHeaderCounter = (props: CounterProps): JSX.Element => {
const _CardHeaderCounter = (props: CounterProps): React.ReactElement => {
useVerifyInsideCard('CardHeaderCounter');

return <Counter {...props} />;
Expand All @@ -44,7 +44,7 @@ const CardHeaderCounter = assignWithoutSideEffects(_CardHeaderCounter, {
componentId: ComponentIds.CardHeaderCounter,
});

const _CardHeaderBadge = (props: BadgeProps): JSX.Element => {
const _CardHeaderBadge = (props: BadgeProps): React.ReactElement => {
useVerifyInsideCard('CardHeaderBadge');

return <Badge {...props} />;
Expand All @@ -53,7 +53,7 @@ const CardHeaderBadge = assignWithoutSideEffects(_CardHeaderBadge, {
componentId: ComponentIds.CardHeaderBadge,
});

const _CardHeaderText = (props: TextProps<{ variant: TextVariant }>): JSX.Element => {
const _CardHeaderText = (props: TextProps<{ variant: TextVariant }>): React.ReactElement => {
useVerifyInsideCard('CardHeaderText');

return <Text {...props} />;
Expand All @@ -62,7 +62,7 @@ const CardHeaderText = assignWithoutSideEffects(_CardHeaderText, {
componentId: ComponentIds.CardHeaderText,
});

const _CardHeaderLink = (props: LinkProps): JSX.Element => {
const _CardHeaderLink = (props: LinkProps): React.ReactElement => {
useVerifyInsideCard('CardHeaderLink');

return <Link {...props} />;
Expand All @@ -78,7 +78,7 @@ type CardHeaderIconButtonProps = Omit<
icon: IconComponent;
};

const _CardHeaderIconButton = (props: CardHeaderIconButtonProps): JSX.Element => {
const _CardHeaderIconButton = (props: CardHeaderIconButtonProps): React.ReactElement => {
useVerifyInsideCard('CardHeaderIconButton');

return (
Expand All @@ -95,7 +95,7 @@ type CardHeaderProps = {
children?: React.ReactNode;
} & TestID;

const _CardHeader = ({ children, testID }: CardHeaderProps): JSX.Element => {
const _CardHeader = ({ children, testID }: CardHeaderProps): React.ReactElement => {
useVerifyInsideCard('CardHeader');
useVerifyAllowedComponents(children, 'CardHeader', [
ComponentIds.CardHeaderLeading,
Expand Down Expand Up @@ -142,7 +142,7 @@ const _CardHeaderLeading = ({
subtitle,
prefix,
suffix,
}: CardHeaderLeadingProps): JSX.Element => {
}: CardHeaderLeadingProps): React.ReactElement => {
useVerifyInsideCard('CardHeaderLeading');

if (prefix && !isValidAllowedChildren(prefix, ComponentIds.CardHeaderIcon)) {
Expand Down Expand Up @@ -198,7 +198,7 @@ const headerTrailingAllowedComponents = [
ComponentIds.CardHeaderBadge,
];

const _CardHeaderTrailing = ({ visual }: CardHeaderTrailingProps): JSX.Element => {
const _CardHeaderTrailing = ({ visual }: CardHeaderTrailingProps): React.ReactElement => {
useVerifyInsideCard('CardHeaderTrailing');

if (visual && !headerTrailingAllowedComponents.includes(getComponentId(visual)!)) {
Expand Down

0 comments on commit 9772fbe

Please sign in to comment.