forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING-CHANGE: new ChatMessageContent for style caching (microsoft#…
…24691) * new chat msg content * fix playground * export them * UT * remove cruft * fix style and example * add missing props * fix unhandled * chglog * chglog * Update packages/fluentui/docs/src/examples/components/Chat/Playground.tsx Co-authored-by: Oleksandr Fediashov <alexander.mcgarret@gmail.com> * Update packages/fluentui/react-northstar/src/themes/teams/components/Chat/chatMessageContentStyles.ts Co-authored-by: Oleksandr Fediashov <alexander.mcgarret@gmail.com> * apply comment * remove old classname * remove old classname * small prop update * Update packages/fluentui/react-northstar/src/themes/teams/components/Chat/chatMessageContentStyles.ts * remove function in chatmsgcontentstyles * remove function in chatmsgcontentstyles Co-authored-by: Oleksandr Fediashov <alexander.mcgarret@gmail.com>
- Loading branch information
Showing
18 changed files
with
144 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...rc/examples/components/Chat/Content/ChatExampleReactionGroupMeReacting.shorthand.steps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/fluentui/react-northstar/src/components/Chat/ChatMessageContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { compose } from '@fluentui/react-bindings'; | ||
import * as PropTypes from 'prop-types'; | ||
|
||
import { commonPropTypes } from '../../utils'; | ||
import { Box, BoxProps, BoxStylesProps } from '../Box/Box'; | ||
import { ChatDensity } from './chatDensity'; | ||
import { ChatMessageLayout, ChatMessageProps } from './ChatMessage'; | ||
|
||
export interface ChatMessageContentOwnProps | ||
extends Pick<ChatMessageProps, 'badgePosition' | 'density' | 'failed' | 'mine' | 'unstable_layout'> { | ||
/** Indicates whether parent ChatMessage has badge. */ | ||
hasBadge?: boolean; | ||
} | ||
export interface ChatMessageContentProps extends ChatMessageContentOwnProps, BoxProps {} | ||
|
||
export type ChatMessageContentStylesProps = Required< | ||
Pick<ChatMessageContentOwnProps, 'badgePosition' | 'density' | 'failed' | 'hasBadge' | 'mine'> | ||
> & { | ||
layout: ChatMessageLayout; | ||
}; | ||
export const chatMessageContentClassName = 'ui-chat__messagecontent'; | ||
|
||
/** | ||
* A ChatMessageContent provides a slot for content in the ChatMessage. | ||
*/ | ||
export const ChatMessageContent = compose< | ||
'div', | ||
ChatMessageContentOwnProps, | ||
ChatMessageContentStylesProps, | ||
BoxProps, | ||
BoxStylesProps | ||
>(Box, { | ||
className: chatMessageContentClassName, | ||
displayName: 'ChatMessageContent', | ||
handledProps: ['badgePosition', 'density', 'failed', 'hasBadge', 'mine', 'unstable_layout'], | ||
mapPropsToStylesProps: ({ badgePosition, density, failed, hasBadge, mine, unstable_layout }) => ({ | ||
badgePosition, | ||
density, | ||
failed, | ||
hasBadge, | ||
layout: unstable_layout, | ||
mine, | ||
}), | ||
overrideStyles: true, | ||
shorthandConfig: { mappedProp: 'content' }, | ||
}); | ||
|
||
ChatMessageContent.propTypes = { | ||
...commonPropTypes.createCommon(), | ||
badgePosition: PropTypes.oneOf(['start', 'end']), | ||
density: PropTypes.oneOf<ChatDensity>(['comfy', 'compact']), | ||
failed: PropTypes.bool, | ||
hasBadge: PropTypes.bool, | ||
mine: PropTypes.bool, | ||
unstable_layout: PropTypes.oneOf(['default', 'refresh']), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ges/fluentui/react-northstar/src/themes/teams/components/Chat/chatMessageContentStyles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { ComponentSlotStylesPrepared, ICSSInJSStyle } from '@fluentui/styles'; | ||
|
||
import { ChatMessageContentStylesProps } from '../../../../components/Chat/ChatMessageContent'; | ||
import { ChatMessageVariables } from './chatMessageVariables'; | ||
import { pxToRem } from '../../../../utils'; | ||
|
||
export const chatMessageContentStyles: ComponentSlotStylesPrepared< | ||
ChatMessageContentStylesProps, | ||
ChatMessageVariables | ||
> = { | ||
root: (componentStyleFunctionParam): ICSSInJSStyle => { | ||
const { props: p, variables: v, theme } = componentStyleFunctionParam; | ||
return { | ||
color: v.contentColor, | ||
display: 'block', | ||
'& a': { | ||
outline: 'none', | ||
color: p.mine ? v.linkColorMine : v.linkColor, | ||
':focus': { | ||
textDecoration: 'underline', | ||
}, | ||
}, | ||
|
||
...(p.layout === 'refresh' && | ||
p.density === 'comfy' && { | ||
wordBreak: 'break-word', | ||
wordWrap: 'break-word', | ||
'& a': { | ||
color: 'inherit', | ||
textDecoration: 'underline', | ||
wordBreak: 'break-all', | ||
'&:hover': { textDecorationStyle: 'double' }, | ||
'&:focus': { textDecorationStyle: 'double' }, | ||
}, | ||
...(p.failed && { | ||
color: theme.siteVariables.colorScheme.default.foreground, | ||
}), | ||
}), | ||
|
||
...(p.density === 'comfy' && { | ||
...(p.hasBadge && p.badgePosition === 'end' && { marginRight: pxToRem(4) }), | ||
}), | ||
}; | ||
}, | ||
}; |
1 change: 1 addition & 0 deletions
1
.../fluentui/react-northstar/src/themes/teams/components/Chat/chatMessageContentVariables.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { chatMessageVariables as chatMessageContentVariables } from './chatMessageVariables'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/fluentui/react-northstar/test/specs/components/Chat/ChatMessageContent-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ChatMessageContent } from 'src/components/Chat/ChatMessageContent'; | ||
import { isConformant } from 'test/specs/commonTests'; | ||
|
||
describe('ChatMessageContent', () => { | ||
isConformant(ChatMessageContent, { | ||
testPath: __filename, | ||
constructorName: 'ChatMessageContent', | ||
}); | ||
}); |