-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(react-drawer): create DrawerBody component #27581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
marcosmoura
merged 27 commits into
microsoft:master
from
marcosmoura:feat/drawer-components
May 10, 2023
Merged
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
35148a5
feat(react-drawer): create body component
marcosmoura ca1a90f
Merge branch 'master' into feat/drawer-components
marcosmoura 8a1bafc
Merge branch 'master' into feat/drawer-components
marcosmoura 49e55d3
fix: remove .cy files from lib config
marcosmoura ca1a06e
fix: remove .cy files from lib config
marcosmoura 1867b3d
Merge branch 'master' into feat/drawer-components
marcosmoura e98fc9e
Merge branch 'master' into feat/drawer-components
marcosmoura aee85b9
fix: remove conflict code leftover
marcosmoura b61d019
docs: remove TODO marks
marcosmoura 2190a1f
docs: add TODO indicator
marcosmoura 13b2226
Merge branch 'master' into feat/drawer-components
marcosmoura c9c3efd
feat: add support to override drawer body styles
marcosmoura 5e7224b
test: add cypress tests for scroll positions
marcosmoura 7ea5df2
fix: rename styles file to use the newer naming conventions
marcosmoura cbca31c
Merge branch 'master' into feat/drawer-components
marcosmoura 7e22ce8
Merge branch 'master' into feat/drawer-components
marcosmoura 8f76678
fix: prevent elements from stretching
marcosmoura 7035ce5
feat: add support to override drawer styles
marcosmoura bf14755
feat: add style overrides for upcoming drawer components
marcosmoura b2c81eb
docs: update API
marcosmoura 8547ea6
Merge branch 'master' into feat/drawer-components
marcosmoura 355e444
docs: update API
marcosmoura 4b6570f
Merge branch 'master' into feat/drawer-components
marcosmoura 9ff3422
Merge branch 'master' into feat/drawer-components
marcosmoura d287cbb
fix: add missing change file
marcosmoura c195885
test: merge tests
marcosmoura 83cf470
fix: add changefiles
marcosmoura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-provider-d5d6ba04-fdeb-4003-be12-17ef140ed50c.json
This file contains hidden or 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": "patch", | ||
| "comment": "add style overrides for upcoming drawer components", | ||
marcosmoura marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "packageName": "@fluentui/react-provider", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "patch" | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-shared-contexts-4e124152-f0bd-4310-9a56-2ce177884ec7.json
This file contains hidden or 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": "patch", | ||
| "comment": "add style overrides for upcoming drawer components", | ||
| "packageName": "@fluentui/react-shared-contexts", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "patch" | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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/DrawerBody/index'; |
This file contains hidden or 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 hidden or 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 hidden or 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
48 changes: 48 additions & 0 deletions
48
packages/react-components/react-drawer/src/components/DrawerBody/DrawerBody.cy.tsx
This file contains hidden or 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,48 @@ | ||
| import * as React from 'react'; | ||
| import { mount } from '@cypress/react'; | ||
| import type {} from '@cypress/react'; | ||
| import { FluentProvider } from '@fluentui/react-provider'; | ||
| import { webLightTheme } from '@fluentui/react-theme'; | ||
| import { Drawer, DrawerBody } from '@fluentui/react-drawer'; | ||
|
|
||
| const mountFluent = (element: JSX.Element) => { | ||
| mount(<FluentProvider theme={webLightTheme}>{element}</FluentProvider>); | ||
| }; | ||
|
|
||
| function assertScrollPosition(element: HTMLElement, position: number) { | ||
| expect(element.scrollTop).to.equal(position); | ||
| } | ||
|
|
||
| describe('DrawerBody', () => { | ||
| it('render drawer body component', () => { | ||
marcosmoura marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
marcosmoura marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| mountFluent(<DrawerBody id="drawer-body" />); | ||
|
|
||
| cy.get('#drawer-body').should('exist'); | ||
| }); | ||
|
|
||
| it('scroll drawer body', () => { | ||
| const Example = () => ( | ||
| <Drawer type="inline" open style={{ height: '200px' }}> | ||
| <DrawerBody id="drawer-body"> | ||
| Lorem ipsum dolor sit amet consectetur, adipisicing elit. Corrupti, animi? Quos, eum pariatur. Labore magni | ||
| vel doloremque reiciendis, consequatur porro explicabo similique harum illo, ad hic, earum nobis accusantium | ||
| quasi? Lorem ipsum dolor sit amet consectetur adipisicing elit. Provident eligendi impedit culpa ea ipsum | ||
| voluptate inventore labore, delectus nam veniam dolor debitis dolorem blanditiis in, natus deleniti illo. | ||
| Asperiores, porro. Lorem ipsum dolor sit amet consectetur adipisicing elit. Repellat obcaecati aperiam | ||
| recusandae. Pariatur dolorem cumque odit delectus voluptates ea ipsam culpa voluptate? Praesentium beatae | ||
| corrupti accusamus. Suscipit voluptas natus illo? | ||
| </DrawerBody> | ||
| </Drawer> | ||
| ); | ||
|
|
||
| mountFluent(<Example />); | ||
|
|
||
| cy.get('#drawer-body') | ||
| .scrollTo('bottom') | ||
| .should($e => assertScrollPosition($e[0], $e[0].scrollHeight - $e[0].clientHeight)); | ||
|
|
||
| cy.get('#drawer-body') | ||
| .scrollTo('top') | ||
| .should($e => assertScrollPosition($e[0], 0)); | ||
| }); | ||
| }); | ||
24 changes: 24 additions & 0 deletions
24
packages/react-components/react-drawer/src/components/DrawerBody/DrawerBody.test.tsx
This file contains hidden or 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 { render } from '@testing-library/react'; | ||
| import { DrawerBody } from './DrawerBody'; | ||
| import { isConformant } from '../../testing/isConformant'; | ||
|
|
||
| describe('DrawerBody', () => { | ||
| isConformant({ | ||
| Component: DrawerBody, | ||
| displayName: 'DrawerBody', | ||
| }); | ||
|
|
||
| it('renders a default state', () => { | ||
| const result = render(<DrawerBody>Default DrawerBody</DrawerBody>); | ||
| expect(result.container).toMatchInlineSnapshot(` | ||
| <div> | ||
| <div | ||
| class="fui-DrawerBody" | ||
| > | ||
| Default DrawerBody | ||
| </div> | ||
| </div> | ||
| `); | ||
| }); | ||
| }); |
21 changes: 21 additions & 0 deletions
21
packages/react-components/react-drawer/src/components/DrawerBody/DrawerBody.tsx
This file contains hidden or 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,21 @@ | ||
| import * as React from 'react'; | ||
| import { useDrawerBody_unstable } from './useDrawerBody'; | ||
| import { renderDrawerBody_unstable } from './renderDrawerBody'; | ||
| import { useDrawerBodyStyles_unstable } from './useDrawerBodyStyles.styles'; | ||
| import type { DrawerBodyProps } from './DrawerBody.types'; | ||
| import type { ForwardRefComponent } from '@fluentui/react-utilities'; | ||
| import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts'; | ||
|
|
||
| /** | ||
| * DrawerBody provides with a container for the main content of a Drawer. | ||
| */ | ||
| export const DrawerBody: ForwardRefComponent<DrawerBodyProps> = React.forwardRef((props, ref) => { | ||
| const state = useDrawerBody_unstable(props, ref); | ||
|
|
||
| useDrawerBodyStyles_unstable(state); | ||
| useCustomStyleHook_unstable('useDrawerBodyStyles_unstable')(state); | ||
|
|
||
| return renderDrawerBody_unstable(state); | ||
| }); | ||
|
|
||
| DrawerBody.displayName = 'DrawerBody'; |
15 changes: 15 additions & 0 deletions
15
packages/react-components/react-drawer/src/components/DrawerBody/DrawerBody.types.ts
This file contains hidden or 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 DrawerBodySlots = { | ||
| root: Slot<'div'>; | ||
| }; | ||
|
|
||
| /** | ||
| * DrawerBody Props | ||
| */ | ||
| export type DrawerBodyProps = ComponentProps<DrawerBodySlots> & {}; | ||
|
|
||
| /** | ||
| * State used in rendering DrawerBody | ||
| */ | ||
| export type DrawerBodyState = ComponentState<DrawerBodySlots>; |
5 changes: 5 additions & 0 deletions
5
packages/react-components/react-drawer/src/components/DrawerBody/index.ts
This file contains hidden or 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 './DrawerBody'; | ||
| export * from './DrawerBody.types'; | ||
| export * from './renderDrawerBody'; | ||
| export * from './useDrawerBody'; | ||
| export * from './useDrawerBodyStyles.styles'; |
12 changes: 12 additions & 0 deletions
12
packages/react-components/react-drawer/src/components/DrawerBody/renderDrawerBody.tsx
This file contains hidden or 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,12 @@ | ||
| import * as React from 'react'; | ||
| import { getSlots } from '@fluentui/react-utilities'; | ||
| import type { DrawerBodyState, DrawerBodySlots } from './DrawerBody.types'; | ||
|
|
||
| /** | ||
| * Render the final JSX of DrawerBody | ||
| */ | ||
| export const renderDrawerBody_unstable = (state: DrawerBodyState) => { | ||
| const { slots, slotProps } = getSlots<DrawerBodySlots>(state); | ||
|
|
||
| return <slots.root {...slotProps.root} />; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.