-
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(react-drawer): make dialog slot to be used for composition only (#…
- Loading branch information
1 parent
8eee0cd
commit fd51d50
Showing
15 changed files
with
199 additions
and
97 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-drawer-840c300d-046b-4ec7-b733-f88067df7dea.json
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,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "feat: make dialog slot internal to be used for composition only", | ||
"packageName": "@fluentui/react-drawer", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
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
25 changes: 25 additions & 0 deletions
25
...s/react-drawer/src/components/DrawerOverlay/DrawerOverlaySurface/DrawerOverlaySurface.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,25 @@ | ||
import * as React from 'react'; | ||
import type { ForwardRefComponent } from '@fluentui/react-utilities'; | ||
import { | ||
useDialogSurface_unstable, | ||
useDialogSurfaceContextValues_unstable, | ||
renderDialogSurface_unstable, | ||
} from '@fluentui/react-dialog'; | ||
|
||
import { useDrawerOverlaySurfaceStyles_unstable } from './useDrawerOverlaySurfaceStyles.styles'; | ||
import type { DrawerOverlaySurfaceProps } from './DrawerOverlaySurface.types'; | ||
|
||
/** | ||
* @internal | ||
* DrawerOverlaySurface is a proxy for DialogSurface as is only meant to be used internally for Drawer. | ||
*/ | ||
export const DrawerOverlaySurface: ForwardRefComponent<DrawerOverlaySurfaceProps> = React.forwardRef((props, ref) => { | ||
const dialogSurfaceState = useDialogSurface_unstable(props, ref); | ||
const dialogSurfaceContextValues = useDialogSurfaceContextValues_unstable(dialogSurfaceState); | ||
|
||
useDrawerOverlaySurfaceStyles_unstable(dialogSurfaceState); | ||
|
||
return renderDialogSurface_unstable(dialogSurfaceState, dialogSurfaceContextValues); | ||
}); | ||
|
||
DrawerOverlaySurface.displayName = 'DrawerOverlaySurface'; |
17 changes: 17 additions & 0 deletions
17
...ct-drawer/src/components/DrawerOverlay/DrawerOverlaySurface/DrawerOverlaySurface.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,17 @@ | ||
import type { DialogSurfaceSlots, DialogSurfaceState } from '@fluentui/react-dialog'; | ||
import type { ComponentProps, ComponentState } from '@fluentui/react-utilities'; | ||
|
||
/** | ||
* DrawerOverlaySurface slots | ||
*/ | ||
export type DrawerOverlaySurfaceSlots = DialogSurfaceSlots; | ||
|
||
/** | ||
* DrawerOverlaySurface Props | ||
*/ | ||
export type DrawerOverlaySurfaceProps = ComponentProps<DrawerOverlaySurfaceSlots>; | ||
|
||
/** | ||
* State used in rendering DrawerOverlaySurface | ||
*/ | ||
export type DrawerOverlaySurfaceState = ComponentState<DrawerOverlaySurfaceSlots> & DialogSurfaceState; |
2 changes: 2 additions & 0 deletions
2
.../react-components/react-drawer/src/components/DrawerOverlay/DrawerOverlaySurface/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,2 @@ | ||
export * from './DrawerOverlaySurface'; | ||
export * from './DrawerOverlaySurface.types'; |
43 changes: 43 additions & 0 deletions
43
...src/components/DrawerOverlay/DrawerOverlaySurface/useDrawerOverlaySurfaceStyles.styles.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,43 @@ | ||
import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react'; | ||
import type { SlotClassNames } from '@fluentui/react-utilities'; | ||
import { tokens } from '@fluentui/react-theme'; | ||
|
||
import type { DrawerOverlaySurfaceSlots, DrawerOverlaySurfaceState } from './DrawerOverlaySurface.types'; | ||
|
||
export const drawerOverlaySurfaceClassNames: SlotClassNames<DrawerOverlaySurfaceSlots> = { | ||
root: 'fui-DrawerOverlaySurface', | ||
backdrop: 'fui-DrawerOverlaySurface__backdrop', | ||
}; | ||
|
||
/** | ||
* Styles for the backdrop slot | ||
*/ | ||
const useBackdropResetStyles = makeResetStyles({ | ||
...shorthands.inset('0px'), | ||
position: 'fixed', | ||
backgroundColor: 'rgba(0, 0, 0, 0.4)', | ||
}); | ||
|
||
const useBackdropStyles = makeStyles({ | ||
nested: { | ||
backgroundColor: tokens.colorTransparentBackground, | ||
}, | ||
}); | ||
|
||
/** | ||
* Apply styling to the DrawerOverlaySurface slots based on the state | ||
*/ | ||
export const useDrawerOverlaySurfaceStyles_unstable = (state: DrawerOverlaySurfaceState): DrawerOverlaySurfaceState => { | ||
const backdropResetStyles = useBackdropResetStyles(); | ||
const backdropStyles = useBackdropStyles(); | ||
|
||
if (state.backdrop) { | ||
state.backdrop.className = mergeClasses( | ||
backdropResetStyles, | ||
state.isNestedDialog && backdropStyles.nested, | ||
state.backdrop.className, | ||
); | ||
} | ||
|
||
return state; | ||
}; |
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.