-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rename ToastLayout to Toast (#28140)
* feat: rename ToastLayout to Toast Follows up from #28139 and renames ToastLayout to Toast * fix md
- Loading branch information
Showing
32 changed files
with
168 additions
and
174 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
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 * from './components/Toast/index'; |
This file was deleted.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
...mponents/ToastLayout/ToastLayout.test.tsx → ...toast/src/components/Toast/Toast.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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { ToastLayout } from './ToastLayout'; | ||
import { Toast } from './Toast'; | ||
import { isConformant } from '../../testing/isConformant'; | ||
|
||
describe('ToastLayout', () => { | ||
describe('Toast', () => { | ||
isConformant({ | ||
Component: ToastLayout, | ||
displayName: 'ToastLayout', | ||
Component: Toast, | ||
displayName: 'Toast', | ||
}); | ||
|
||
it('renders a default state', () => { | ||
const result = render(<ToastLayout>Default ToastLayout</ToastLayout>); | ||
const result = render(<Toast>Default Toast</Toast>); | ||
expect(result.container).toMatchSnapshot(); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/react-components/react-toast/src/components/Toast/Toast.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,18 @@ | ||
import * as React from 'react'; | ||
import { useToast_unstable } from './useToast'; | ||
import { renderToast_unstable } from './renderToast'; | ||
import { useToastStyles_unstable } from './useToastStyles.styles'; | ||
import type { ToastProps } from './Toast.types'; | ||
import type { ForwardRefComponent } from '@fluentui/react-utilities'; | ||
|
||
/** | ||
* Toast component | ||
*/ | ||
export const Toast: ForwardRefComponent<ToastProps> = React.forwardRef((props, ref) => { | ||
const state = useToast_unstable(props, ref); | ||
|
||
useToastStyles_unstable(state); | ||
return renderToast_unstable(state); | ||
}); | ||
|
||
Toast.displayName = 'Toast'; |
15 changes: 15 additions & 0 deletions
15
packages/react-components/react-toast/src/components/Toast/Toast.types.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,15 @@ | ||
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities'; | ||
|
||
export type ToastSlots = { | ||
root: Slot<'div'>; | ||
}; | ||
|
||
/** | ||
* Toast Props | ||
*/ | ||
export type ToastProps = ComponentProps<ToastSlots> & {}; | ||
|
||
/** | ||
* State used in rendering Toast | ||
*/ | ||
export type ToastState = ComponentState<ToastSlots>; |
11 changes: 11 additions & 0 deletions
11
packages/react-components/react-toast/src/components/Toast/__snapshots__/Toast.test.tsx.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Toast renders a default state 1`] = ` | ||
<div> | ||
<div | ||
class="fui-Toast" | ||
> | ||
Default Toast | ||
</div> | ||
</div> | ||
`; |
5 changes: 5 additions & 0 deletions
5
packages/react-components/react-toast/src/components/Toast/index.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,5 @@ | ||
export * from './Toast'; | ||
export * from './Toast.types'; | ||
export * from './renderToast'; | ||
export * from './useToast'; | ||
export * from './useToastStyles.styles'; |
15 changes: 15 additions & 0 deletions
15
packages/react-components/react-toast/src/components/Toast/renderToast.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,15 @@ | ||
/** @jsxRuntime classic */ | ||
/** @jsx createElement */ | ||
|
||
import { createElement } from '@fluentui/react-jsx-runtime'; | ||
import { getSlotsNext } from '@fluentui/react-utilities'; | ||
import type { ToastState, ToastSlots } from './Toast.types'; | ||
|
||
/** | ||
* Render the final JSX of Toast | ||
*/ | ||
export const renderToast_unstable = (state: ToastState) => { | ||
const { slots, slotProps } = getSlotsNext<ToastSlots>(state); | ||
|
||
return <slots.root {...slotProps.root} />; | ||
}; |
24 changes: 24 additions & 0 deletions
24
packages/react-components/react-toast/src/components/Toast/useToast.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,24 @@ | ||
import * as React from 'react'; | ||
import { getNativeElementProps } from '@fluentui/react-utilities'; | ||
import type { ToastProps, ToastState } from './Toast.types'; | ||
|
||
/** | ||
* Create the state required to render Toast. | ||
* | ||
* The returned state can be modified with hooks such as useToastStyles_unstable, | ||
* before being passed to renderToast_unstable. | ||
* | ||
* @param props - props from this instance of Toast | ||
* @param ref - reference to root HTMLElement of Toast | ||
*/ | ||
export const useToast_unstable = (props: ToastProps, ref: React.Ref<HTMLElement>): ToastState => { | ||
return { | ||
components: { | ||
root: 'div', | ||
}, | ||
root: getNativeElementProps('div', { | ||
ref, | ||
...props, | ||
}), | ||
}; | ||
}; |
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
18 changes: 0 additions & 18 deletions
18
packages/react-components/react-toast/src/components/ToastLayout/ToastLayout.tsx
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
packages/react-components/react-toast/src/components/ToastLayout/ToastLayout.types.ts
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
...components/react-toast/src/components/ToastLayout/__snapshots__/ToastLayout.test.tsx.snap
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
packages/react-components/react-toast/src/components/ToastLayout/index.ts
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
packages/react-components/react-toast/src/components/ToastLayout/renderToastLayout.tsx
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
packages/react-components/react-toast/src/components/ToastLayout/useToastLayout.ts
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.