Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .changeset/curvy-lines-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-chat/message': minor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a backwards-compatible bugfix, this can be marked as a patch https://semver.org/#summary

Copy link
Collaborator Author

@hschawe hschawe Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was thinking this could be considered a minor change due to the addition of className

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would mark it minor if it was net-new, but in this case, it was already added and getting passed to the Body instance instead of the outermost div

---

Add `className` prop to `Message.Promotion` for custom styles
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ export const promotionContainerStyles = css`
flex-direction: row;
align-items: center;
gap: 0px ${spacing[200]}px;
& div {
box-sizing: border-box;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this specifically for the badge element? If so, wondering if we can add directly to badgeStyles below

`;

export const badgeStyles = css`
display: flex;
flex-direction: row;
justify-content: center;

width: ${BADGE_WIDTH}px;
height: ${BADGE_HEIGHT}px;
min-width: ${BADGE_WIDTH}px;
min-height: ${BADGE_HEIGHT}px;
`;
12 changes: 6 additions & 6 deletions chat/message/src/MessagePromotion/MessagePromotion.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import Badge, { Variant } from '@leafygreen-ui/badge';
import { cx } from '@leafygreen-ui/emotion';
import Icon from '@leafygreen-ui/icon';
import LeafyGreenProvider, {
useDarkMode,
Expand All @@ -23,17 +24,16 @@ export function MessagePromotion({
promotionUrl,
onPromotionLinkClick,
darkMode: darkModeProp,
className,
...rest
}: MessagePromotionProps) {
const { darkMode } = useDarkMode(darkModeProp);
return (
<LeafyGreenProvider darkMode={darkMode}>
<div className={promotionContainerStyles}>
<div>
<Badge variant={Variant.Green} className={badgeStyles}>
<Icon glyph="Award" />
</Badge>
</div>
<div className={cx(promotionContainerStyles, className)}>
<Badge variant={Variant.Green} className={badgeStyles}>
<Icon glyph="Award" />
</Badge>
<Body as="span" {...rest}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we almost move this {...rest} to the outer div?

{promotionText}
<>
Expand Down
19 changes: 17 additions & 2 deletions chat/message/src/MessagePromotion/MessagePromotions.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import React from 'react';
import { storybookArgTypes, StoryMetaType } from '@lg-tools/storybook-utils';
import { StoryFn } from '@storybook/react';

import { css } from '@leafygreen-ui/emotion';
import { palette } from '@leafygreen-ui/palette';

import { MessagePromotion, MessagePromotionProps } from '.';

const meta: StoryMetaType<typeof MessagePromotion> = {
Expand All @@ -13,10 +16,22 @@ const meta: StoryMetaType<typeof MessagePromotion> = {
combineArgs: {
darkMode: [false, true],
promotionText: [
'Challenge your knowledge by earning the Advanced Schema Design skill!',
'Challenge your knowledge by earning the Advanced Schema Design skill! This is a really really really really really really really really really really really really really really really really really really really really really really really really really long copy text to test how the component handles long text content.',
'Challenge your knowledge and earn the Schema Design badge!',
'Challenge your knowledge by earning the Advanced Schema Design skill! This is a really really really really really really really really really long copy text to test how the component handles multiline text content.',
],
promotionUrl: ['https://learn.mongodb.com/skills'],
className: [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't typically generate story instances for demonstrating className overrides. Although we'll expose the className prop for components, it's typically an exception rather than a promoted feature to keep UI consistent

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair! I thought it'd be useful to keep a content-box test case, but it might be more appropriate to test that on the Badge component anyway

css`
box-sizing: content-box;
gap: 20px;
& div {
background-color: ${palette.blue.dark2};
border-color: white;
color: ${palette.blue.light2};
}
`,
undefined,
],
},
},
},
Expand Down
Loading