Skip to content

Commit fedb362

Browse files
authored
Fix default style (svg width/height) & css prop on promotions (#3185)
* Fix default style (svg width/height) & css prop on promotions * Lint * Test fix & change version * PR review: position styles according to element responsibility
1 parent e07939c commit fedb362

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

.changeset/curvy-lines-tie.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+
Add `className` prop to `Message.Promotion` for custom styles

chat/message/src/MessagePromotion/MessagePromotion.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const meta: StoryMetaType<typeof MessagePromotion> = {
1313
combineArgs: {
1414
darkMode: [false, true],
1515
promotionText: [
16-
'Challenge your knowledge by earning the Advanced Schema Design skill!',
17-
'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.',
16+
'Challenge your knowledge and earn the Schema Design badge!',
17+
'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.',
1818
],
1919
promotionUrl: ['https://learn.mongodb.com/skills'],
2020
},

chat/message/src/MessagePromotion/MessagePromotion.styles.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const badgeStyles = css`
1515
display: flex;
1616
flex-direction: row;
1717
justify-content: center;
18-
19-
width: ${BADGE_WIDTH}px;
20-
height: ${BADGE_HEIGHT}px;
18+
box-sizing: border-box;
19+
min-width: ${BADGE_WIDTH}px;
20+
min-height: ${BADGE_HEIGHT}px;
2121
`;

chat/message/src/MessagePromotion/MessagePromotion.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22

33
import Badge, { Variant } from '@leafygreen-ui/badge';
4+
import { cx } from '@leafygreen-ui/emotion';
45
import Icon from '@leafygreen-ui/icon';
56
import LeafyGreenProvider, {
67
useDarkMode,
@@ -23,18 +24,17 @@ export function MessagePromotion({
2324
promotionUrl,
2425
onPromotionLinkClick,
2526
darkMode: darkModeProp,
27+
className,
2628
...rest
2729
}: MessagePromotionProps) {
2830
const { darkMode } = useDarkMode(darkModeProp);
2931
return (
3032
<LeafyGreenProvider darkMode={darkMode}>
31-
<div className={promotionContainerStyles}>
32-
<div>
33-
<Badge variant={Variant.Green} className={badgeStyles}>
34-
<Icon glyph="Award" />
35-
</Badge>
36-
</div>
37-
<Body as="span" {...rest}>
33+
<div className={cx(promotionContainerStyles, className)} {...rest}>
34+
<Badge variant={Variant.Green} className={badgeStyles}>
35+
<Icon glyph="Award" />
36+
</Badge>
37+
<Body as="span">
3838
{promotionText}
3939
<>
4040
{' '}

0 commit comments

Comments
 (0)