Skip to content

Commit 0870bea

Browse files
authored
chore(message): deprecate spacious variant props in MessageProps (#3144)
* refactor(message): deprecate spacious variant props in MessageProps * chore(message): changeset * refactor(message): move MessageSubcomponentProperty to Message.types and remove constants file
1 parent 23ce595 commit 0870bea

File tree

5 files changed

+42
-24
lines changed

5 files changed

+42
-24
lines changed

.changeset/wide-signs-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@lg-chat/message': patch
3+
---
4+
5+
Deprecate spacious variant props in `MessageProps`

chat/message/src/Message/CompactMessage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { filterChildren, findChild } from '@leafygreen-ui/lib';
77
import { BaseFontSize } from '@leafygreen-ui/tokens';
88
import { Body } from '@leafygreen-ui/typography';
99

10-
import { MessageSubcomponentProperty } from '../constants';
1110
import {
1211
MessageContainer,
1312
Variant as MessageContainerVariant,
@@ -18,7 +17,10 @@ import {
1817
avatarContainerStyles,
1918
getContainerStyles,
2019
} from './CompactMessage.styles';
21-
import { type MessageProps } from './Message.types';
20+
import {
21+
type MessageProps,
22+
MessageSubcomponentProperty,
23+
} from './Message.types';
2224

2325
export const CompactMessage = forwardRef<HTMLDivElement, MessageProps>(
2426
(

chat/message/src/Message/Message.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ import LeafyGreenProvider, {
99
} from '@leafygreen-ui/leafygreen-provider';
1010
import { consoleOnce } from '@leafygreen-ui/lib';
1111

12-
import { MessageSubcomponentProperty } from '../constants';
1312
import { MessageActions } from '../MessageActions';
1413
import { MessageVerifiedBanner } from '../MessageBanner';
1514
import { MessageContext } from '../MessageContext';
1615
import { MessageLinks } from '../MessageLinks';
1716

1817
import { CompactMessage } from './CompactMessage';
1918
import {
20-
ActionsType,
21-
LinksType,
19+
type ActionsType,
20+
type LinksType,
2221
type MessageProps,
22+
MessageSubcomponentProperty,
2323
type VerifiedBannerType,
2424
} from './Message.types';
2525
import { SpaciousMessage } from './SpaciousMessage';

chat/message/src/Message/Message.types.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export const Align = {
2020

2121
export type Align = (typeof Align)[keyof typeof Align];
2222

23+
/**
24+
* @deprecated
25+
*/
2326
export interface ComponentOverrides {
2427
MessageContainer?: (props: MessageContainerProps) => JSX.Element;
2528
MessageContent?: (props: MessageContentProps) => JSX.Element;
@@ -35,28 +38,31 @@ export interface MessageProps
3538
children?: React.ReactNode;
3639
/**
3740
* Determines whether the message is aligned to the left or right
38-
*
3941
* By default, if `isSender === true`, the message is aligned to the right, and otherwise to the left. This prop overrides that behavior.
4042
* @remarks This prop is only considered when the parent `LeafyGreenChatProvider` has `variant="spacious"`.
43+
* @deprecated The spacious variant will be removed by EOY 2025. Instead, use the compact variant.
4144
*/
4245
align?: Align;
4346

4447
/**
4548
* Avatar element
4649
* @remarks This prop is only considered when the parent `LeafyGreenChatProvider` has `variant="spacious"`.
50+
* @deprecated The spacious variant will be removed by EOY 2025. Instead, use the compact variant.
4751
*/
4852
avatar?: ReactElement;
4953

5054
/**
5155
* Base font size
5256
* @remarks This prop is only considered when the parent `LeafyGreenChatProvider` has `variant="spacious"`.
57+
* @deprecated The spacious variant will be removed by EOY 2025. Instead, use the compact variant.
5358
*/
5459
baseFontSize?: BaseFontSize;
5560

5661
/**
5762
* Component overrides for any subcomponents
5863
* @deprecated
5964
* @remarks This prop is only considered when the parent `LeafyGreenChatProvider` has `variant="spacious"`.
65+
* @deprecated The spacious variant will be removed by EOY 2025. Instead, use the compact variant.
6066
*/
6167
componentOverrides?: ComponentOverrides;
6268

@@ -69,12 +75,14 @@ export interface MessageProps
6975
/**
7076
* A list of links to render as rich links for the message.
7177
* @remarks This prop is only considered when the parent `LeafyGreenChatProvider` has `variant="spacious"`.
78+
* @deprecated The spacious variant will be removed by EOY 2025. Instead, use the compact variant.
7279
*/
7380
links?: Array<RichLinkProps>;
7481

7582
/**
7683
* The heading text to display for the links section.
7784
* @remarks This prop is only considered when the parent `LeafyGreenChatProvider` has `variant="spacious"`.
85+
* @deprecated The spacious variant will be removed by EOY 2025. Instead, use the compact variant.
7886
*/
7987
linksHeading?: string;
8088

@@ -86,26 +94,44 @@ export interface MessageProps
8694
/**
8795
* A callback function that is called when any link is clicked.
8896
* @remarks This prop is only considered when the parent `LeafyGreenChatProvider` has `variant="spacious"`.
97+
* @deprecated The spacious variant will be removed by EOY 2025. Instead, use the compact variant.
8998
*/
9099
onLinkClick?: RichLinkProps['onLinkClick'];
91100

92101
/**
93102
* Configure a *verified message* which includes additional styles and
94103
* displays information about the message.
95104
* @remarks This prop is only considered when the parent `LeafyGreenChatProvider` has `variant="spacious"`.
105+
* @deprecated The spacious variant will be removed by EOY 2025. Instead, use the compact variant.
96106
*/
97107
verified?: BaseMessageVerifiedBannerProps;
98108
}
99109

110+
/**
111+
* Static property names used to identify Message compound components.
112+
* These are implementation details for the compound component pattern and should not be exported.
113+
*/
114+
export const MessageSubcomponentProperty = {
115+
Actions: 'isLGMessageActions',
116+
VerifiedBanner: 'isLGMessageVerifiedBanner',
117+
Links: 'isLGMessageLinks',
118+
} as const;
119+
120+
/**
121+
* Type representing the possible static property names for Message subcomponents.
122+
*/
123+
export type MessageSubcomponentProperty =
124+
(typeof MessageSubcomponentProperty)[keyof typeof MessageSubcomponentProperty];
125+
100126
export type ActionsType = ForwardRefExoticComponent<MessageActionsProps> & {
101-
isLGMessageActions?: boolean;
127+
[MessageSubcomponentProperty.Actions]?: boolean;
102128
};
103129

104130
export type LinksType = ForwardRefExoticComponent<MessageLinksProps> & {
105-
isLGMessageLinks?: boolean;
131+
[MessageSubcomponentProperty.Links]?: boolean;
106132
};
107133

108134
export type VerifiedBannerType =
109135
ForwardRefExoticComponent<MessageVerifiedBannerProps> & {
110-
isLGMessageVerifiedBanner?: boolean;
136+
[MessageSubcomponentProperty.VerifiedBanner]?: boolean;
111137
};

chat/message/src/constants.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)