-
Notifications
You must be signed in to change notification settings - Fork 71
Fix default style (svg width/height) & css prop on promotions #3185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
25b56fb
36deb7a
2df2eee
54c6e45
59b9292
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@lg-chat/message': minor | ||
| --- | ||
|
|
||
| Add `className` prop to `Message.Promotion` for custom styles | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,13 +9,16 @@ export const promotionContainerStyles = css` | |
| flex-direction: row; | ||
| align-items: center; | ||
| gap: 0px ${spacing[200]}px; | ||
| & div { | ||
| box-sizing: border-box; | ||
| } | ||
|
||
| `; | ||
|
|
||
| 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; | ||
| `; | ||
| 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, | ||
|
|
@@ -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}> | ||
|
||
| {promotionText} | ||
| <> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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> = { | ||
|
|
@@ -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: [ | ||
|
||
| css` | ||
| box-sizing: content-box; | ||
| gap: 20px; | ||
| & div { | ||
| background-color: ${palette.blue.dark2}; | ||
| border-color: white; | ||
| color: ${palette.blue.light2}; | ||
| } | ||
| `, | ||
| undefined, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
classNameThere was a problem hiding this comment.
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
Bodyinstance instead of the outermost div