Skip to content

Commit 52572e1

Browse files
authored
Improvement/33473 react toast styling (#33550)
1 parent bd3e4c2 commit 52572e1

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "feat: Add intent property to Toast state and useToast hook. Correct media className assignment in useToastTitleStyles.",
4+
"packageName": "@fluentui/react-toast",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/react-toast/library/src/components/Toast/Toast.types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
22
import { BackgroundAppearanceContextValue } from '@fluentui/react-shared-contexts';
3+
import type { ToastIntent } from '../../state/types';
34

45
export type ToastSlots = {
56
root: Slot<'div'>;
@@ -21,4 +22,5 @@ export type ToastProps = ComponentProps<ToastSlots> & {
2122
*/
2223
export type ToastState = ComponentState<ToastSlots> & {
2324
backgroundAppearance: BackgroundAppearanceContextValue;
25+
intent?: ToastIntent | undefined;
2426
};

packages/react-components/react-toast/library/src/components/Toast/useToast.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
33
import type { ToastProps, ToastState } from './Toast.types';
4+
import { useToastContainerContext } from '../../contexts/toastContainerContext';
45

56
/**
67
* Create the state required to render Toast.
@@ -12,6 +13,8 @@ import type { ToastProps, ToastState } from './Toast.types';
1213
* @param ref - reference to root HTMLElement of Toast
1314
*/
1415
export const useToast_unstable = (props: ToastProps, ref: React.Ref<HTMLElement>): ToastState => {
16+
const { intent } = useToastContainerContext();
17+
1518
return {
1619
components: {
1720
root: 'div',
@@ -27,5 +30,6 @@ export const useToast_unstable = (props: ToastProps, ref: React.Ref<HTMLElement>
2730
{ elementType: 'div' },
2831
),
2932
backgroundAppearance: props.appearance,
33+
intent,
3034
};
3135
};

packages/react-components/react-toast/library/src/components/ToastTitle/useToastTitleStyles.styles.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ export const useToastTitleStyles_unstable = (state: ToastTitleState): ToastTitle
102102
toastTitleClassNames.media,
103103
mediaBaseClassName,
104104
state.backgroundAppearance === 'inverted' && invertedStyles.media,
105-
state.media.className,
106105
intent && intentIconStyles[intent],
107106
intent && state.backgroundAppearance === 'inverted' && intentIconStylesInverted[intent],
107+
state.media.className,
108108
);
109109
}
110110

0 commit comments

Comments
 (0)