Skip to content

Commit

Permalink
chore(fuselage): Messages's components incorrect types (#1336)
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris authored Mar 25, 2024
1 parent cef61fd commit baea129
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 100 deletions.
4 changes: 2 additions & 2 deletions packages/fuselage/src/components/Message/MessageBody.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { AllHTMLAttributes, ReactElement } from 'react';
import type { HTMLAttributes, ReactElement } from 'react';
import React from 'react';

import { prependClassName } from '../../helpers/prependClassName';

type MessageBodyProps = AllHTMLAttributes<HTMLDivElement> & {
type MessageBodyProps = HTMLAttributes<HTMLDivElement> & {
clamp?: 2 | 3 | 4;
};

Expand Down
8 changes: 2 additions & 6 deletions packages/fuselage/src/components/Message/MessageContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { ReactNode } from 'react';
import type { HTMLAttributes } from 'react';
import React from 'react';

type MessageContainerProps = {
children?: ReactNode;
};

export const MessageContainer = (props: MessageContainerProps) => (
export const MessageContainer = (props: HTMLAttributes<HTMLDivElement>) => (
<div className='rcx-box rcx-box--full rcx-message-container' {...props} />
);
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { ReactNode } from 'react';
import type { HTMLAttributes } from 'react';
import React from 'react';

type MessageContainerFixedProps = {
children?: ReactNode;
};

export const MessageContainerFixed = (props: MessageContainerFixedProps) => (
export const MessageContainerFixed = (
props: HTMLAttributes<HTMLDivElement>
) => (
<div
className='rcx-box rcx-box--full rcx-message-container rcx-message-container--fixed'
{...props}
Expand Down
12 changes: 4 additions & 8 deletions packages/fuselage/src/components/Message/MessageEmoji.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import type { ReactNode } from 'react';
import type { ComponentProps } from 'react';
import React from 'react';

import { MessageEmojiBase } from './MessageEmojiBase';

type MessageEmojiProps = {
name: string;
className?: string;
image?: string;
type MessageEmojiProps = ComponentProps<typeof MessageEmojiBase> & {
big?: boolean;
children?: ReactNode;
};

export const MessageEmoji = ({
name,
className,
image,
big,
children,
...props
}: MessageEmojiProps) => (
<MessageEmojiBase
className={[
Expand All @@ -28,6 +24,6 @@ export const MessageEmoji = ({
.join(' ')}
name={name}
image={image}
children={children}
{...props}
/>
);
12 changes: 5 additions & 7 deletions packages/fuselage/src/components/Message/MessageEmojiBase.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import type { ReactNode } from 'react';
import type { HTMLAttributes } from 'react';
import React from 'react';

type MessageEmojiBaseProps = {
name: string;
className?: string;
children?: ReactNode;
image?: string;
};
} & HTMLAttributes<HTMLSpanElement>;

export const MessageEmojiBase = ({
name,
className,
image,
children,
className,
...props
}: MessageEmojiBaseProps) => (
<span
className={`${className || ''} ${name}`}
style={image && image.length ? { backgroundImage: image } : undefined}
children={children}
{...props}
/>
);
13 changes: 6 additions & 7 deletions packages/fuselage/src/components/Message/MessageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { ReactNode } from 'react';
import type { HTMLAttributes } from 'react';
import React from 'react';

type MessageHeaderProps = {
children?: ReactNode;
};

export const MessageHeader = ({ children }: MessageHeaderProps) => (
<div className='rcx-box rcx-box--full rcx-message-header'>
export const MessageHeader = ({
children,
...props
}: HTMLAttributes<HTMLDivElement>) => (
<div className='rcx-box rcx-box--full rcx-message-header' {...props}>
<div className='rcx-box rcx-box--full rcx-message-header__wrapper'>
{children}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import type { ReactElement, ReactNode } from 'react';
import type { HTMLAttributes, ReactElement } from 'react';
import React from 'react';

type MessageLeftContainerProps = {
children?: ReactNode;
};

export const MessageLeftContainer = (
props: MessageLeftContainerProps
props: HTMLAttributes<HTMLDivElement>
): ReactElement => (
<div
className='rcx-box rcx-box--full rcx-message-container rcx-message-container--left'
Expand Down
6 changes: 2 additions & 4 deletions packages/fuselage/src/components/Message/MessageName.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { AllHTMLAttributes } from 'react';
import type { HTMLAttributes } from 'react';
import React from 'react';

type MessageNameProps = AllHTMLAttributes<HTMLSpanElement>;

export const MessageName = (props: MessageNameProps) => (
export const MessageName = (props: HTMLAttributes<HTMLSpanElement>) => (
<span className='rcx-box rcx-box--full rcx-message-header__name' {...props} />
);
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { AllHTMLAttributes } from 'react';
import type { HTMLAttributes } from 'react';
import React, { forwardRef } from 'react';

type MessageNameContainerProps = AllHTMLAttributes<HTMLSpanElement>;

export const MessageNameContainer = forwardRef<
HTMLSpanElement,
MessageNameContainerProps
HTMLAttributes<HTMLSpanElement>
>(function MessageNameContainer(props, ref) {
return (
<span
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
import type { ReactNode } from 'react';
import type { ComponentProps } from 'react';
import React from 'react';

import { MessageEmojiBase } from '../MessageEmojiBase';

type MessageReactionEmojiProps = {
name: string;
className?: string;
children?: ReactNode;
image?: string;
};

export const MessageReactionEmoji = ({
name,
className,
image,
children,
}: MessageReactionEmojiProps) => (
...props
}: ComponentProps<typeof MessageEmojiBase>) => (
<MessageEmojiBase
className={`rcx-message-reactions__emoji ${className || ''}`}
name={name}
image={image}
children={children}
{...props}
/>
);
8 changes: 2 additions & 6 deletions packages/fuselage/src/components/Message/MessageRole.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import type { ReactNode } from 'react';
import type { ComponentProps } from 'react';
import React from 'react';

import { Tag } from '../Tag';

type MessageRoleProps = {
children?: ReactNode;
};

export const MessageRole = (props: MessageRoleProps) => (
export const MessageRole = (props: ComponentProps<typeof Tag>) => (
<Tag className='rcx-box rcx-box--full rcx-message-header__role' {...props} />
);
8 changes: 2 additions & 6 deletions packages/fuselage/src/components/Message/MessageRoles.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { ReactNode } from 'react';
import type { HTMLAttributes } from 'react';
import React from 'react';

type MessageRolesProps = {
children?: ReactNode;
};

export const MessageRoles = (props: MessageRolesProps) => (
export const MessageRoles = (props: HTMLAttributes<HTMLDivElement>) => (
<div className='rcx-box rcx-box--full rcx-message-header__roles' {...props} />
);
6 changes: 2 additions & 4 deletions packages/fuselage/src/components/Message/MessageTimestamp.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { ReactNode } from 'react';
import type { HTMLAttributes } from 'react';
import React from 'react';

type MessageTimestampProps = { children: ReactNode; title?: string };

export const MessageTimestamp = (props: MessageTimestampProps) => (
export const MessageTimestamp = (props: HTMLAttributes<HTMLSpanElement>) => (
<span className='rcx-box rcx-box--full rcx-message-header__time' {...props} />
);
6 changes: 2 additions & 4 deletions packages/fuselage/src/components/Message/MessageUsername.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { AllHTMLAttributes } from 'react';
import type { HTMLAttributes } from 'react';
import React from 'react';

type MessageUsernameProps = AllHTMLAttributes<HTMLSpanElement>;

export const MessageUsername = (props: MessageUsernameProps) => (
export const MessageUsername = (props: HTMLAttributes<HTMLSpanElement>) => (
<span
className='rcx-box rcx-box--full rcx-message-header__username'
{...props}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
import type { ReactNode } from 'react';
import type { ComponentProps } from 'react';
import React from 'react';

import { MessageEmojiBase } from '../MessageEmojiBase';

type ThreadMessageEmojiProps = {
name: string;
className?: string;
image?: string;
children?: ReactNode;
};

export const ThreadMessageEmoji = ({
name,
className,
image,
children,
}: ThreadMessageEmojiProps) => (
...props
}: ComponentProps<typeof MessageEmojiBase>) => (
<MessageEmojiBase
className={`rcx-message-thread__emoji ${className || ''}`}
name={name}
image={image}
children={children}
{...props}
/>
);

0 comments on commit baea129

Please sign in to comment.