Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
35148a5
feat(react-drawer): create body component
marcosmoura Apr 17, 2023
3c49889
feat(react-drawer): create header component
marcosmoura Apr 17, 2023
b2237ea
docs: regenerate API
marcosmoura Apr 17, 2023
ca1a90f
Merge branch 'master' into feat/drawer-components
marcosmoura Apr 17, 2023
8a1bafc
Merge branch 'master' into feat/drawer-components
marcosmoura Apr 18, 2023
49e55d3
fix: remove .cy files from lib config
marcosmoura Apr 18, 2023
ca1a06e
fix: remove .cy files from lib config
marcosmoura Apr 18, 2023
1867b3d
Merge branch 'master' into feat/drawer-components
marcosmoura Apr 24, 2023
e98fc9e
Merge branch 'master' into feat/drawer-components
marcosmoura Apr 25, 2023
aee85b9
fix: remove conflict code leftover
marcosmoura Apr 25, 2023
b61d019
docs: remove TODO marks
marcosmoura Apr 25, 2023
c1151a3
Merge branch 'feat/drawer-components' into feat/drawer-header
marcosmoura Apr 25, 2023
0b35c16
docs: add initial stories for header
marcosmoura Apr 25, 2023
5edd737
Merge branch 'master' into feat/drawer-header
marcosmoura Apr 25, 2023
2190a1f
docs: add TODO indicator
marcosmoura Apr 25, 2023
13b2226
Merge branch 'master' into feat/drawer-components
marcosmoura Apr 25, 2023
c9c3efd
feat: add support to override drawer body styles
marcosmoura Apr 27, 2023
5e7224b
test: add cypress tests for scroll positions
marcosmoura Apr 27, 2023
7ea5df2
fix: rename styles file to use the newer naming conventions
marcosmoura Apr 27, 2023
cbca31c
Merge branch 'master' into feat/drawer-components
marcosmoura Apr 27, 2023
7e22ce8
Merge branch 'master' into feat/drawer-components
marcosmoura Apr 27, 2023
8f76678
fix: prevent elements from stretching
marcosmoura Apr 27, 2023
7035ce5
feat: add support to override drawer styles
marcosmoura Apr 27, 2023
bf14755
feat: add style overrides for upcoming drawer components
marcosmoura Apr 27, 2023
b2c81eb
docs: update API
marcosmoura Apr 27, 2023
275aae4
Merge branch 'feat/drawer-components' into feat/drawer-header
marcosmoura Apr 27, 2023
8547ea6
Merge branch 'master' into feat/drawer-components
marcosmoura May 2, 2023
355e444
docs: update API
marcosmoura May 2, 2023
4b6570f
Merge branch 'master' into feat/drawer-components
marcosmoura May 2, 2023
fde52a5
Merge branch 'master' into feat/drawer-header
marcosmoura May 2, 2023
c8158b3
Merge branch 'feat/drawer-components' into feat/drawer-header
marcosmoura May 2, 2023
9ff3422
Merge branch 'master' into feat/drawer-components
marcosmoura May 2, 2023
ac858d8
feat: create components and slots for the drawer header package
marcosmoura May 2, 2023
d287cbb
fix: add missing change file
marcosmoura May 2, 2023
1686909
Merge branch 'master' into feat/drawer-header
marcosmoura May 2, 2023
ae946eb
Merge branch 'feat/drawer-components' into feat/drawer-header
marcosmoura May 2, 2023
19412cd
fix: only render content if there is any children content
marcosmoura May 2, 2023
bfe0ec0
feat: split all header slots into dedicated components for better com…
marcosmoura May 2, 2023
45c11a1
fix: remove duplicated values
marcosmoura May 3, 2023
a4822f7
fix: use correct component
marcosmoura May 3, 2023
c195885
test: merge tests
marcosmoura May 3, 2023
83cf470
fix: add changefiles
marcosmoura May 3, 2023
4065ff1
Merge branch 'feat/drawer-components' into feat/drawer-header
marcosmoura May 3, 2023
22f2f85
fix: remove duplicated changefile
marcosmoura May 3, 2023
b9c32a2
fix: header spacing
marcosmoura May 3, 2023
3efe043
docs: refactor docs to include DrawerBody and DrawerHeader
marcosmoura May 3, 2023
1a6d43f
docs: add subcomponents to stories
marcosmoura May 3, 2023
7475b1d
docs: improve property description
marcosmoura May 4, 2023
7815c89
Merge branch 'master' into feat/drawer-header
marcosmoura May 5, 2023
a6a3377
Merge branch 'master' into feat/drawer-header
marcosmoura May 10, 2023
a8683e8
fix: add changefiles
marcosmoura May 10, 2023
98287f6
fix: use composition to build DrawerHeaderTitle
marcosmoura May 11, 2023
2b52d4a
fix: generate API
marcosmoura May 11, 2023
6178ffe
Merge branch 'master' into feat/drawer-header
marcosmoura May 12, 2023
dcbc355
fix: move style override to outside the component
marcosmoura May 16, 2023
42f3c94
Merge branch 'master' into feat/drawer-header
marcosmoura May 18, 2023
c4d5c2d
fix: cleanup for better readability
marcosmoura May 18, 2023
fffc1aa
fix: generate API
marcosmoura May 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: add style overrides for drawer components",
"packageName": "@fluentui/react-provider",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: add style overrides for drawer components",
"packageName": "@fluentui/react-shared-contexts",
"email": "[email protected]",
"dependentChangeType": "patch"
}
85 changes: 84 additions & 1 deletion packages/react-components/react-drawer/etc/react-drawer.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import type { DialogProps } from '@fluentui/react-dialog';
import type { DialogSurfaceProps } from '@fluentui/react-dialog';
import { DialogTitleSlots } from '@fluentui/react-dialog';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import * as React_2 from 'react';
import type { Slot } from '@fluentui/react-utilities';
Expand All @@ -25,7 +26,7 @@ export const DrawerBody: ForwardRefComponent<DrawerBodyProps>;
export const drawerBodyClassNames: SlotClassNames<DrawerBodySlots>;

// @public
export type DrawerBodyProps = ComponentProps<DrawerBodySlots> & {};
export type DrawerBodyProps = ComponentProps<DrawerBodySlots>;

// @public (undocumented)
export type DrawerBodySlots = {
Expand Down Expand Up @@ -61,6 +62,61 @@ export type DrawerFooterSlots = {
// @public
export type DrawerFooterState = ComponentState<DrawerFooterSlots>;

// @public
export const DrawerHeader: ForwardRefComponent<DrawerHeaderProps>;

// @public (undocumented)
export const drawerHeaderClassNames: SlotClassNames<DrawerHeaderSlots>;

// @public
export const DrawerHeaderNavigation: ForwardRefComponent<DrawerHeaderNavigationProps>;

// @public (undocumented)
export const drawerHeaderNavigationClassNames: SlotClassNames<DrawerHeaderNavigationSlots>;

// @public
export type DrawerHeaderNavigationProps = ComponentProps<DrawerHeaderNavigationSlots>;

// @public (undocumented)
export type DrawerHeaderNavigationSlots = {
root: Slot<'nav'>;
};

// @public
export type DrawerHeaderNavigationState = ComponentState<DrawerHeaderNavigationSlots>;

// @public
export type DrawerHeaderProps = ComponentProps<DrawerHeaderSlots>;

// @public (undocumented)
export type DrawerHeaderSlots = {
root: Slot<'header'>;
};

// @public
export type DrawerHeaderState = ComponentState<DrawerHeaderSlots>;

// @public
export const DrawerHeaderTitle: ForwardRefComponent<DrawerHeaderTitleProps>;

// @public (undocumented)
export const drawerHeaderTitleClassNames: SlotClassNames<DrawerHeaderTitleSlots>;

// @public
export type DrawerHeaderTitleProps = ComponentProps<DrawerHeaderTitleSlots> & {
children: React_2.ReactNode | undefined;
};

// @public (undocumented)
export type DrawerHeaderTitleSlots = {
root: Slot<'div'>;
heading?: DialogTitleSlots['root'];
action?: DialogTitleSlots['action'];
};

// @public
export type DrawerHeaderTitleState = ComponentState<DrawerHeaderTitleSlots>;

// @public
export type DrawerProps = ComponentProps<Partial<DrawerSlots>> & {
position?: 'left' | 'right';
Expand Down Expand Up @@ -91,6 +147,15 @@ export const renderDrawerBody_unstable: (state: DrawerBodyState) => JSX.Element;
// @public
export const renderDrawerFooter_unstable: (state: DrawerFooterState) => JSX.Element;

// @public
export const renderDrawerHeader_unstable: (state: DrawerHeaderState) => JSX.Element;

// @public
export const renderDrawerHeaderNavigation_unstable: (state: DrawerHeaderNavigationState) => JSX.Element;

// @public
export const renderDrawerHeaderTitle_unstable: (state: DrawerHeaderTitleState) => JSX.Element;

// @public
export const useDrawer_unstable: (props: DrawerProps, ref: React_2.Ref<HTMLElement>) => DrawerState;

Expand All @@ -106,6 +171,24 @@ export const useDrawerFooter_unstable: (props: DrawerFooterProps, ref: React_2.R
// @public
export const useDrawerFooterStyles_unstable: (state: DrawerFooterState) => DrawerFooterState;

// @public
export const useDrawerHeader_unstable: (props: DrawerHeaderProps, ref: React_2.Ref<HTMLElement>) => DrawerHeaderState;

// @public
export const useDrawerHeaderNavigation_unstable: (props: DrawerHeaderNavigationProps, ref: React_2.Ref<HTMLElement>) => DrawerHeaderNavigationState;

// @public
export const useDrawerHeaderNavigationStyles_unstable: (state: DrawerHeaderNavigationState) => DrawerHeaderNavigationState;

// @public
export const useDrawerHeaderStyles_unstable: (state: DrawerHeaderState) => DrawerHeaderState;

// @public
export const useDrawerHeaderTitle_unstable: (props: DrawerHeaderTitleProps, ref: React_2.Ref<HTMLElement>) => DrawerHeaderTitleState;

// @public
export const useDrawerHeaderTitleStyles_unstable: (state: DrawerHeaderTitleState) => DrawerHeaderTitleState;

// @public
export const useDrawerStyles_unstable: (state: DrawerState) => DrawerState;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/DrawerHeader/index';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/DrawerHeaderNavigation/index';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/DrawerHeaderTitle/index';
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export type DrawerProps = ComponentProps<Partial<DrawerSlots>> & {

/**
* When this is set, the rest of the page is dimmed out and cannot be interacted with.
* The tab sequence is kept within the dialog and moving the focus outside
* the dialog will imply closing it. This is the default type of the component.
* The tab sequence is kept within the drawer and moving the focus outside
* the drawer will imply closing it. This is the default type of the component.
* This prop is only used when `type` is `overlay`.
*
* @defaultvalue true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ export const drawerCSSVars = {
*/
const useStyles = makeStyles({
root: {
...shorthands.padding(0),
...shorthands.overflow('hidden'),
...shorthands.borderRadius(`var(${drawerCSSVars.borderRadius})`),
...shorthands.border(0),
...shorthands.overflow('hidden'),

[drawerCSSVars.borderRadius]: 0,

width: `var(${drawerCSSVars.size})`,
maxWidth: 'calc(100vw - 48px)',
maxWidth: '100vw',
height: 'auto',
boxSizing: 'border-box',
display: 'flex',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type DrawerBodySlots = {
/**
* DrawerBody Props
*/
export type DrawerBodyProps = ComponentProps<DrawerBodySlots> & {};
export type DrawerBodyProps = ComponentProps<DrawerBodySlots>;

/**
* State used in rendering DrawerBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const useStyles = makeStyles({
...shorthands.overflow('auto'),
...shorthands.flex(1),

alignSelf: 'stretch',

// A "good hack" to display top and bottom borders based on the scroll position
backgroundImage: `linear-gradient(to top, ${tokens.colorNeutralBackground1}, ${tokens.colorNeutralBackground1}),
linear-gradient(to top, ${tokens.colorNeutralBackground1}, ${tokens.colorNeutralBackground1}),
Expand Down
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 { DrawerHeader } from './DrawerHeader';
import { isConformant } from '../../testing/isConformant';

describe('DrawerHeader', () => {
isConformant({
Component: DrawerHeader,
displayName: 'DrawerHeader',
});

it('renders a default state', () => {
const result = render(<DrawerHeader>Default DrawerHeader</DrawerHeader>);
expect(result.container).toMatchInlineSnapshot(`
<div>
<header
class="fui-DrawerHeader"
>
Default DrawerHeader
</header>
</div>
`);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import { useDrawerHeader_unstable } from './useDrawerHeader';
import { renderDrawerHeader_unstable } from './renderDrawerHeader';
import { useDrawerHeaderStyles_unstable } from './useDrawerHeaderStyles';
import type { DrawerHeaderProps } from './DrawerHeader.types';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';

/**
* DrawerHeader provides a structured header for the drawer component.
*/
export const DrawerHeader: ForwardRefComponent<DrawerHeaderProps> = React.forwardRef((props, ref) => {
const state = useDrawerHeader_unstable(props, ref);

useDrawerHeaderStyles_unstable(state);
useCustomStyleHook_unstable('useDrawerHeaderStyles_unstable')(state);

return renderDrawerHeader_unstable(state);
});

DrawerHeader.displayName = 'DrawerHeader';
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';

export type DrawerHeaderSlots = {
/**
* The root of the DrawerHeader.
*/
root: Slot<'header'>;
};

/**
* DrawerHeader Props
*/
export type DrawerHeaderProps = ComponentProps<DrawerHeaderSlots>;

/**
* State used in rendering DrawerHeader
*/
export type DrawerHeaderState = ComponentState<DrawerHeaderSlots>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './DrawerHeader';
export * from './DrawerHeader.types';
export * from './renderDrawerHeader';
export * from './useDrawerHeader';
export * from './useDrawerHeaderStyles';
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 { DrawerHeaderState, DrawerHeaderSlots } from './DrawerHeader.types';

/**
* Render the final JSX of DrawerHeader
*/
export const renderDrawerHeader_unstable = (state: DrawerHeaderState) => {
const { slots, slotProps } = getSlots<DrawerHeaderSlots>(state);

return <slots.root {...slotProps.root} />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as React from 'react';
import { getNativeElementProps } from '@fluentui/react-utilities';
import type { DrawerHeaderProps, DrawerHeaderState } from './DrawerHeader.types';

/**
* Create the state required to render DrawerHeader.
*
* The returned state can be modified with hooks such as useDrawerHeaderStyles_unstable,
* before being passed to renderDrawerHeader_unstable.
*
* @param props - props from this instance of DrawerHeader
* @param ref - reference to root HTMLElement of DrawerHeader
*/
export const useDrawerHeader_unstable = (props: DrawerHeaderProps, ref: React.Ref<HTMLElement>): DrawerHeaderState => {
return {
components: {
root: 'header',
},

root: getNativeElementProps('header', {
ref,
...props,
}),
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { makeStyles, mergeClasses, shorthands } from '@griffel/react';
import type { DrawerHeaderSlots, DrawerHeaderState } from './DrawerHeader.types';
import type { SlotClassNames } from '@fluentui/react-utilities';
import { tokens } from '@fluentui/react-theme';

export const drawerHeaderClassNames: SlotClassNames<DrawerHeaderSlots> = {
root: 'fui-DrawerHeader',
};

/**
* Styles for the root slot
*/
const useStyles = makeStyles({
root: {
...shorthands.padding(tokens.spacingVerticalXXL, tokens.spacingHorizontalXXL, tokens.spacingVerticalS),
...shorthands.gap(tokens.spacingHorizontalS),

alignSelf: 'stretch',
display: 'flex',
flexDirection: 'column',
},
});

/**
* Apply styling to the DrawerHeader slots based on the state
*/
export const useDrawerHeaderStyles_unstable = (state: DrawerHeaderState): DrawerHeaderState => {
const styles = useStyles();

state.root.className = mergeClasses(drawerHeaderClassNames.root, styles.root, state.root.className);

return state;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react';
import { render } from '@testing-library/react';
import { DrawerHeaderNavigation } from './DrawerHeaderNavigation';
import { isConformant } from '../../testing/isConformant';

describe('DrawerHeaderNavigation', () => {
isConformant({
Component: DrawerHeaderNavigation,
displayName: 'DrawerHeaderNavigation',
});

// TODO add more tests here, and create visual regression tests in /apps/vr-tests

it('renders a default state', () => {
const result = render(<DrawerHeaderNavigation>Default DrawerHeaderNavigation</DrawerHeaderNavigation>);
expect(result.container).toMatchInlineSnapshot(`
<div>
<nav
class="fui-DrawerHeaderNavigation"
>
Default DrawerHeaderNavigation
</nav>
</div>
`);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import { useDrawerHeaderNavigation_unstable } from './useDrawerHeaderNavigation';
import { renderDrawerHeaderNavigation_unstable } from './renderDrawerHeaderNavigation';
import { useDrawerHeaderNavigationStyles_unstable } from './useDrawerHeaderNavigationStyles.styles';
import type { DrawerHeaderNavigationProps } from './DrawerHeaderNavigation.types';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';

/**
* DrawerHeaderNavigation provides a header navigation area for the Drawer.
*/
export const DrawerHeaderNavigation: ForwardRefComponent<DrawerHeaderNavigationProps> = React.forwardRef(
(props, ref) => {
const state = useDrawerHeaderNavigation_unstable(props, ref);

useDrawerHeaderNavigationStyles_unstable(state);
useCustomStyleHook_unstable('useDrawerHeaderNavigationStyles_unstable')(state);

return renderDrawerHeaderNavigation_unstable(state);
},
);

DrawerHeaderNavigation.displayName = 'DrawerHeaderNavigation';
Loading