Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
35148a5
feat(react-drawer): create body component
marcosmoura Apr 17, 2023
34c596b
feat(react-drawer): create footer component
marcosmoura Apr 17, 2023
fd5c39c
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
e98dd4f
Merge branch 'master' into feat/drawer-footer
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
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
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
9ff3422
Merge branch 'master' into feat/drawer-components
marcosmoura May 2, 2023
d287cbb
fix: add missing change file
marcosmoura May 2, 2023
5a4a3d1
Merge branch 'feat/drawer-components' into feat/drawer-footer
marcosmoura May 2, 2023
c195885
test: merge tests
marcosmoura May 3, 2023
83cf470
fix: add changefiles
marcosmoura May 3, 2023
5917f5a
Merge branch 'feat/drawer-components' into feat/drawer-footer
marcosmoura May 5, 2023
ab506e5
Merge branch 'master' into feat/drawer-footer
marcosmoura May 10, 2023
26d32a4
fix: remove unused stories
marcosmoura May 10, 2023
9b7494c
fix: revert removal of classname
marcosmoura May 10, 2023
941ec46
fix: conflicts
marcosmoura May 10, 2023
bbbf053
Merge branch 'master' into feat/drawer-footer
marcosmoura May 12, 2023
4e58a67
fix: improve code readability
marcosmoura May 16, 2023
fee2966
Merge branch 'master' into feat/drawer-footer
marcosmoura May 16, 2023
1a305bb
fix: generate API
marcosmoura May 16, 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
26 changes: 26 additions & 0 deletions packages/react-components/react-drawer/etc/react-drawer.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ export const drawerCSSVars: {
borderRadius: string;
};

// @public
export const DrawerFooter: ForwardRefComponent<DrawerFooterProps>;

// @public (undocumented)
export const drawerFooterClassNames: SlotClassNames<DrawerFooterSlots>;

// @public
export type DrawerFooterProps = ComponentProps<DrawerFooterSlots>;

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

// @public
export type DrawerFooterState = ComponentState<DrawerFooterSlots>;

// @public
export type DrawerProps = ComponentProps<Partial<DrawerSlots>> & {
position?: 'left' | 'right';
Expand Down Expand Up @@ -71,6 +88,9 @@ export const renderDrawer_unstable: (state: DrawerState) => JSX.Element | null;
// @public
export const renderDrawerBody_unstable: (state: DrawerBodyState) => JSX.Element;

// @public
export const renderDrawerFooter_unstable: (state: DrawerFooterState) => JSX.Element;

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

Expand All @@ -80,6 +100,12 @@ export const useDrawerBody_unstable: (props: DrawerBodyProps, ref: React_2.Ref<H
// @public
export const useDrawerBodyStyles_unstable: (state: DrawerBodyState) => DrawerBodyState;

// @public
export const useDrawerFooter_unstable: (props: DrawerFooterProps, ref: React_2.Ref<HTMLElement>) => DrawerFooterState;

// @public
export const useDrawerFooterStyles_unstable: (state: DrawerFooterState) => DrawerFooterState;

// @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/DrawerFooter/index';
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 { DrawerFooter } from './DrawerFooter';
import { isConformant } from '../../testing/isConformant';

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

it('renders a default state', () => {
const result = render(<DrawerFooter>Default DrawerFooter</DrawerFooter>);
expect(result.container).toMatchInlineSnapshot(`
<div>
<footer
class="fui-DrawerFooter"
>
Default DrawerFooter
</footer>
</div>
`);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import { useDrawerFooter_unstable } from './useDrawerFooter';
import { renderDrawerFooter_unstable } from './renderDrawerFooter';
import { useDrawerFooterStyles_unstable } from './useDrawerFooterStyles';
import type { DrawerFooterProps } from './DrawerFooter.types';
import type { ForwardRefComponent } from '@fluentui/react-utilities';

/**
* DrawerFooter component - TODO: add more docs
*/
export const DrawerFooter: ForwardRefComponent<DrawerFooterProps> = React.forwardRef((props, ref) => {
const state = useDrawerFooter_unstable(props, ref);

useDrawerFooterStyles_unstable(state);
return renderDrawerFooter_unstable(state);
});

DrawerFooter.displayName = 'DrawerFooter';
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 DrawerFooterSlots = {
root: Slot<'footer'>;
};

/**
* DrawerFooter Props
*/
export type DrawerFooterProps = ComponentProps<DrawerFooterSlots>;

/**
* State used in rendering DrawerFooter
*/
export type DrawerFooterState = ComponentState<DrawerFooterSlots>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './DrawerFooter';
export * from './DrawerFooter.types';
export * from './renderDrawerFooter';
export * from './useDrawerFooter';
export * from './useDrawerFooterStyles';
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 { DrawerFooterState, DrawerFooterSlots } from './DrawerFooter.types';

/**
* Render the final JSX of DrawerFooter
*/
export const renderDrawerFooter_unstable = (state: DrawerFooterState) => {
const { slots, slotProps } = getSlots<DrawerFooterSlots>(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 { DrawerFooterProps, DrawerFooterState } from './DrawerFooter.types';

/**
* Create the state required to render DrawerFooter.
*
* The returned state can be modified with hooks such as useDrawerFooterStyles_unstable,
* before being passed to renderDrawerFooter_unstable.
*
* @param props - props from this instance of DrawerFooter
* @param ref - reference to root HTMLElement of DrawerFooter
*/
export const useDrawerFooter_unstable = (props: DrawerFooterProps, ref: React.Ref<HTMLElement>): DrawerFooterState => {
return {
components: {
root: 'footer',
},

root: getNativeElementProps('footer', {
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 { DrawerFooterSlots, DrawerFooterState } from './DrawerFooter.types';
import type { SlotClassNames } from '@fluentui/react-utilities';
import { tokens } from '@fluentui/react-theme';

export const drawerFooterClassNames: SlotClassNames<DrawerFooterSlots> = {
root: 'fui-DrawerFooter',
};

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

display: 'flex',
justifyContent: 'flex-start',
alignItems: 'center',
columnGap: tokens.spacingHorizontalS,
},
});

/**
* Apply styling to the DrawerFooter slots based on the state
*/
export const useDrawerFooterStyles_unstable = (state: DrawerFooterState): DrawerFooterState => {
const styles = useStyles();

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

return state;
};
9 changes: 9 additions & 0 deletions packages/react-components/react-drawer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ export {
useDrawerBody_unstable,
} from './DrawerBody';
export type { DrawerBodyProps, DrawerBodySlots, DrawerBodyState } from './DrawerBody';

export {
DrawerFooter,
drawerFooterClassNames,
renderDrawerFooter_unstable,
useDrawerFooterStyles_unstable,
useDrawerFooter_unstable,
} from './DrawerFooter';
export type { DrawerFooterProps, DrawerFooterSlots, DrawerFooterState } from './DrawerFooter';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Drawer, DrawerBody, DrawerBodyProps } from '@fluentui/react-drawer';
import { makeStyles, shorthands, tokens } from '@fluentui/react-components';
import { Drawer, DrawerBody, DrawerBodyProps, DrawerFooter } from '@fluentui/react-drawer';
import { Button, makeStyles, shorthands, tokens } from '@fluentui/react-components';

const useStyles = makeStyles({
root: {
Expand All @@ -21,7 +21,7 @@ const useStyles = makeStyles({
},
});

const Header = (props: Partial<DrawerBodyProps>) => {
const Header = () => {
const styles = useStyles();

return (
Expand All @@ -31,19 +31,18 @@ const Header = (props: Partial<DrawerBodyProps>) => {
);
};

const Footer = (props: Partial<DrawerBodyProps>) => {
const styles = useStyles();

const Footer = () => {
return (
<footer className={styles.container}>
<button>Button</button>
</footer>
<DrawerFooter>
<Button appearance="primary">Primary</Button>
<Button>Secondary</Button>
</DrawerFooter>
);
};

const Body = (props: Partial<DrawerBodyProps>) => {
const Body = () => {
return (
<DrawerBody {...props}>
<DrawerBody>
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Doloribus nam aut amet similique, iure vel voluptates
cum cumque repellendus perferendis maiores officia unde in? Autem neque sequi maiores eum omnis. Lorem ipsum,
dolor sit amet consectetur adipisicing elit. Perspiciatis ipsam explicabo tempora ipsum saepe nam. Eum aliquid
Expand Down