Skip to content

Commit

Permalink
Improvement/33473 react toast styling (#33550)
Browse files Browse the repository at this point in the history
  • Loading branch information
soumyart authored Jan 8, 2025
1 parent bd3e4c2 commit 52572e1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "feat: Add intent property to Toast state and useToast hook. Correct media className assignment in useToastTitleStyles.",
"packageName": "@fluentui/react-toast",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
import { BackgroundAppearanceContextValue } from '@fluentui/react-shared-contexts';
import type { ToastIntent } from '../../state/types';

export type ToastSlots = {
root: Slot<'div'>;
Expand All @@ -21,4 +22,5 @@ export type ToastProps = ComponentProps<ToastSlots> & {
*/
export type ToastState = ComponentState<ToastSlots> & {
backgroundAppearance: BackgroundAppearanceContextValue;
intent?: ToastIntent | undefined;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
import type { ToastProps, ToastState } from './Toast.types';
import { useToastContainerContext } from '../../contexts/toastContainerContext';

/**
* Create the state required to render Toast.
Expand All @@ -12,6 +13,8 @@ import type { ToastProps, ToastState } from './Toast.types';
* @param ref - reference to root HTMLElement of Toast
*/
export const useToast_unstable = (props: ToastProps, ref: React.Ref<HTMLElement>): ToastState => {
const { intent } = useToastContainerContext();

return {
components: {
root: 'div',
Expand All @@ -27,5 +30,6 @@ export const useToast_unstable = (props: ToastProps, ref: React.Ref<HTMLElement>
{ elementType: 'div' },
),
backgroundAppearance: props.appearance,
intent,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ export const useToastTitleStyles_unstable = (state: ToastTitleState): ToastTitle
toastTitleClassNames.media,
mediaBaseClassName,
state.backgroundAppearance === 'inverted' && invertedStyles.media,
state.media.className,
intent && intentIconStyles[intent],
intent && state.backgroundAppearance === 'inverted' && intentIconStylesInverted[intent],
state.media.className,
);
}

Expand Down

0 comments on commit 52572e1

Please sign in to comment.