Skip to content
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

Coachmark: Migrate Coachmark and associated components to function components #13626

Merged
merged 73 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
21c2584
Copy Coachmark code to react-next to stage migration
MLoughry Jun 9, 2020
578df06
Change files
MLoughry Jun 9, 2020
879d2fd
Migrate Beak to function component
MLoughry Jun 9, 2020
3b2317f
Add stub function component for PositioningContainer
MLoughry Jun 9, 2020
daa5f10
Hoist default props and contentHost ref
MLoughry Jun 9, 2020
639b6a9
Hoist several refs
MLoughry Jun 9, 2020
7dd9ccf
Merge branch 'master' of github.com:microsoft/fluentui into react-nex…
MLoughry Jun 10, 2020
e758260
Fix lint issues
MLoughry Jun 10, 2020
688c4e9
Hoist event logic
MLoughry Jun 10, 2020
3e18ce7
Update API
MLoughry Jun 10, 2020
7a62abd
Cleanup
MLoughry Jun 10, 2020
b3c760c
Hoist heightOffset logic
MLoughry Jun 10, 2020
d864edc
Finish migration (with issues)
MLoughry Jun 10, 2020
b7e8c81
Revert to LKG, fixing example import
MLoughry Jun 10, 2020
180ae9d
Hoist positionedHost ref
MLoughry Jun 10, 2020
7a7a34f
Hoist target refs
MLoughry Jun 11, 2020
31c1d40
Hoist positions state
MLoughry Jun 11, 2020
21b61f2
Hoist setInitialFocus
MLoughry Jun 11, 2020
0f7acff
Hoist maxHeight
MLoughry Jun 11, 2020
b5539fd
Hoist auto-dismiss events
MLoughry Jun 11, 2020
9876e5f
Hoist heightOffset
MLoughry Jun 11, 2020
cdaaa8d
Complete PositioningContainer migration
MLoughry Jun 11, 2020
681336f
Merge branch 'master' of github.com:microsoft/fluentui into react-nex…
MLoughry Jun 11, 2020
82efc99
Remove extraneous shouldComponentUpdate
MLoughry Jun 11, 2020
2bf0648
Merge branch 'react-next-copy/Coachmark' into functional/Coachmark
MLoughry Jun 11, 2020
ffafadc
Hoist generic function
MLoughry Jun 11, 2020
a0ee77c
Create stub function component
MLoughry Jun 15, 2020
561732d
Hoist entityInnerHostElementRef
MLoughry Jun 15, 2020
7ddcbf5
Hoist isCollapsed state
MLoughry Jun 15, 2020
9ef37ea
Hoist positioned data
MLoughry Jun 15, 2020
2ac8300
Hoist beak positioning logic
MLoughry Jun 15, 2020
fd6498a
Hoist dismiss public method
MLoughry Jun 15, 2020
9affc04
Hoist document event logic
MLoughry Jun 15, 2020
8f04fb3
Hoist proximity handlers
MLoughry Jun 15, 2020
0a0db60
Hoist aria text logic
MLoughry Jun 15, 2020
a89ed7b
Cleanup unused state
MLoughry Jun 15, 2020
6373c6a
Hoist autofocus logic
MLoughry Jun 16, 2020
41dcd54
Hoist last of state
MLoughry Jun 16, 2020
ef8d8c2
Finish migration
MLoughry Jun 16, 2020
88ebd1f
Forward ref
MLoughry Jun 16, 2020
dd2b21f
Update API
MLoughry Jun 16, 2020
2c820d0
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Jun 16, 2020
2ce5e13
Change files
MLoughry Jun 16, 2020
8943fd0
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Jun 17, 2020
cf7232e
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Jun 18, 2020
1c1228f
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Jun 24, 2020
7ed9e54
Add Screener test
MLoughry Jun 24, 2020
f029a1e
Fix lint error
MLoughry Jun 24, 2020
21af779
Fix cropping of Coachmark story
MLoughry Jun 24, 2020
26478ff
Fix case where Coahmark starts expanded
MLoughry Jun 24, 2020
f7d63c3
Fix API file
MLoughry Jun 24, 2020
4397c67
Pull from react-next
MLoughry Jun 24, 2020
a88cd4c
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Jun 25, 2020
d917560
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Jul 13, 2020
ed37972
Fix bad merge
MLoughry Jul 13, 2020
ee705cd
Duplicate Coachamrk Screener test for OUFR
MLoughry Jul 13, 2020
806ca73
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Jul 14, 2020
b437a81
Remove headers
MLoughry Jul 15, 2020
8d1869a
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Jul 15, 2020
b136a1e
Handle removed props
MLoughry Jul 15, 2020
f6d5677
Deprecate Beak componentRef
MLoughry Jul 15, 2020
a59ce5b
Update packages/react-next/src/components/Coachmark/Coachmark.base.tsx
MLoughry Jul 15, 2020
0e7c864
Merge branch 'functional/Coachmark' of github.com:MLoughry/office-ui-…
MLoughry Jul 15, 2020
d97b7fe
Fix eslint deprecation errors
MLoughry Jul 15, 2020
b3f5264
Change files
MLoughry Jul 15, 2020
ff64863
Update API
MLoughry Jul 15, 2020
eb916f1
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Jul 20, 2020
1281ef2
Fix build error
MLoughry Jul 20, 2020
b1636ad
Fix build issues
MLoughry Jul 20, 2020
8de68f6
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Jul 21, 2020
9413063
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Aug 4, 2020
2c85db9
Remove rejected screener story
MLoughry Aug 4, 2020
889ece0
Merge branch 'master' of github.com:microsoft/fluentui into functiona…
MLoughry Aug 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/vr-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@uifabric/example-data": "^7.0.21",
"@uifabric/experiments": "^7.27.16",
"@uifabric/react-cards": "^0.110.14",
"@uifabric/react-hooks": "^7.7.1",
"@uifabric/set-version": "^7.0.19",
"office-ui-fabric-react": "^7.125.0",
"react": "16.8.6",
Expand Down
65 changes: 65 additions & 0 deletions apps/vr-tests/src/stories/Coachmark.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import * as React from 'react';
import Screener from 'screener-storybook/src/screener';
import { storiesOf } from '@storybook/react';
import { FabricDecorator } from '../utilities';
import { Coachmark, DirectionalHint, TeachingBubbleContent, Fabric } from 'office-ui-fabric-react';
import { useId } from '@uifabric/react-hooks';
import { DefaultButton } from 'office-ui-fabric-react';

const CoachmarkUsage = ({ isCollapsed = true }: { isCollapsed?: boolean }) => {
const targetId = useId();
return (
<>
<div id={targetId}>
<DefaultButton text="Click me!" />
</div>
<Coachmark
target={`#${targetId}`}
positioningContainerProps={{
directionalHint: DirectionalHint.rightTopEdge,
doNotLayer: false,
}}
ariaAlertText="A Coachmark has appeared"
ariaDescribedBy={'coachmark-desc1'}
ariaLabelledBy={'coachmark-label1'}
ariaDescribedByText={'Press enter or alt + C to open the Coachmark notification'}
ariaLabelledByText={'Coachmark notification'}
isCollapsed={isCollapsed}
>
<TeachingBubbleContent
headline="Example Title"
hasCloseButton={true}
closeButtonAriaLabel="Close"
primaryButtonProps={{
text: 'Try it',
}}
secondaryButtonProps={{
text: 'Try it',
}}
ariaDescribedBy={'example-description1'}
ariaLabelledBy={'example-label1'}
>
Welcome to the land of Coachmarks!
</TeachingBubbleContent>
</Coachmark>
</>
);
};

storiesOf('Coachmark', module)
.addDecorator(FabricDecorator)
.addDecorator(story =>
// prettier-ignore
<Screener
steps={new Screener.Steps()
.snapshot('default', { cropTo: '.ms-PositioningContainer' })
.end()}
>
{story()}
</Screener>,
)
.addStory('Collapsed', () => (
<Fabric>
<CoachmarkUsage />
</Fabric>
));
70 changes: 70 additions & 0 deletions apps/vr-tests/src/stories/CoachmarkNext.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import * as React from 'react';
MLoughry marked this conversation as resolved.
Show resolved Hide resolved
import Screener from 'screener-storybook/src/screener';
import { storiesOf } from '@storybook/react';
import { FabricDecorator } from '../utilities';
import { Coachmark, DirectionalHint, TeachingBubbleContent, Fabric } from '@fluentui/react-next';
import { useId } from '@uifabric/react-hooks';
import { DefaultButton } from 'office-ui-fabric-react';

const CoachmarkUsage = ({ isCollapsed = true }: { isCollapsed?: boolean }) => {
const targetId = useId();
return (
<>
<div id={targetId}>
<DefaultButton text="Click me!" />
</div>
<Coachmark
target={`#${targetId}`}
positioningContainerProps={{
directionalHint: DirectionalHint.rightTopEdge,
doNotLayer: false,
}}
ariaAlertText="A Coachmark has appeared"
ariaDescribedBy={'coachmark-desc1'}
ariaLabelledBy={'coachmark-label1'}
ariaDescribedByText={'Press enter or alt + C to open the Coachmark notification'}
ariaLabelledByText={'Coachmark notification'}
isCollapsed={isCollapsed}
>
<TeachingBubbleContent
headline="Example Title"
hasCloseButton={true}
closeButtonAriaLabel="Close"
primaryButtonProps={{
text: 'Try it',
}}
secondaryButtonProps={{
text: 'Try it',
}}
ariaDescribedBy={'example-description1'}
ariaLabelledBy={'example-label1'}
>
Welcome to the land of Coachmarks!
</TeachingBubbleContent>
</Coachmark>
</>
);
};

storiesOf('Coachmark Next', module)
.addDecorator(FabricDecorator)
.addDecorator(story =>
// prettier-ignore
<Screener
steps={new Screener.Steps()
.snapshot('default', { cropTo: '.ms-PositioningContainer' })
.end()}
>
{story()}
</Screener>,
)
.addStory('Collapsed', () => (
<Fabric>
<CoachmarkUsage />
</Fabric>
))
.addStory('Expanded', () => (
<Fabric>
<CoachmarkUsage isCollapsed={false} />
</Fabric>
));
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Migrate Coachmark and associated components to function components",
"packageName": "@fluentui/react-next",
"email": "miclo@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-06-16T19:31:01.423Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Add deprecation notices",
"packageName": "office-ui-fabric-react",
"email": "miclo@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-07-15T18:41:40.248Z"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2395,8 +2395,10 @@ export interface ICoachmarkStyleProps {
entityHostHeight?: string;
entityHostWidth?: string;
height?: string;
// @deprecated
isBeaconAnimating: boolean;
isCollapsed: boolean;
// @deprecated
isMeasured: boolean;
isMeasuring: boolean;
theme?: ITheme;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface IBeak {}
export interface IBeakProps extends IBaseProps<IBeak> {
/**
* All props for your component are to be defined here.
* @deprecated
*/
componentRef?: IRefObject<IBeak>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ export function getStyles(props: ICoachmarkStyleProps): ICoachmarkStyles {
beaconColorTwo,
delayBeforeCoachmarkAnimation,
isCollapsed,
// eslint-disable-next-line deprecation/deprecation
isBeaconAnimating,
isMeasuring,
// eslint-disable-next-line deprecation/deprecation
isMeasured,
entityHostHeight,
entityHostWidth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export interface ICoachmarkStyleProps {

/**
* Is the beacon currently animating.
* @deprecated Property is never used
*/
isBeaconAnimating: boolean;

Expand All @@ -241,6 +242,7 @@ export interface ICoachmarkStyleProps {

/**
* Is the Coachmark finished measuring the dimensions of innerHostElement
* @deprecated Value is always the inverse of `isMeasuring`
*/
isMeasured: boolean;

Expand Down
9 changes: 9 additions & 0 deletions packages/react-next/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Breaking changes

### Beak

- Removed empty `IBeak` interface
- Removed `componentRef` prop

### SpinButton

- Simplified props to `ISpinButtonStyles` to include only the parts of the component to bring inline with
Expand All @@ -16,6 +21,10 @@
- Deprecated `onRenderLabel`.
- Added `label`/`checkmark` slot props.

### Coachmark

- Removed `isBeaconAnimating` and `isMeasured` style props

### Pivot

- Removed deprecated and redundant props from v7, including: `initialSelectedKey` and `defaultSelectedIndex`. Use `selectedKey` or `defaultSelectedKey` to define the selected tab, and provide `itemKey` on pivot item children.
Expand Down
89 changes: 11 additions & 78 deletions packages/react-next/etc/react-next.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { IWithResponsiveModeState } from 'office-ui-fabric-react/lib/utilities/d
import { Point } from 'office-ui-fabric-react/lib/Utilities';
import { Position } from 'office-ui-fabric-react/lib/utilities/positioning';
import * as React from 'react';
import { RectangleEdge } from 'office-ui-fabric-react/lib/utilities/positioning';
import { ReactNode } from 'react';
import { Selection } from 'office-ui-fabric-react/lib/Selection';
import { SlotProp } from '@fluentui/react-compose';
import { SlotProps } from '@fluentui/react-compose';
Expand Down Expand Up @@ -115,25 +115,7 @@ export const Coachmark: React.FunctionComponent<ICoachmarkProps>;
export const COACHMARK_ATTRIBUTE_NAME = "data-coachmarkid";

// @public (undocumented)
export class CoachmarkBase extends React.Component<ICoachmarkProps, ICoachmarkState> implements ICoachmark {
constructor(props: ICoachmarkProps);
// (undocumented)
componentDidMount(): void;
// (undocumented)
componentDidUpdate(prevProps: ICoachmarkProps, prevState: ICoachmarkState): void;
// (undocumented)
componentWillUnmount(): void;
// (undocumented)
static defaultProps: Partial<ICoachmarkProps>;
// (undocumented)
dismiss: (ev?: Event | React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLElement, MouseEvent> | undefined) => void;
// (undocumented)
render(): JSX.Element;
// (undocumented)
shouldComponentUpdate(newProps: ICoachmarkProps, newState: ICoachmarkState): boolean;
// (undocumented)
UNSAFE_componentWillReceiveProps(newProps: ICoachmarkProps): void;
}
export const CoachmarkBase: React.ForwardRefExoticComponent<ICoachmarkProps & React.RefAttributes<HTMLDivElement>>;

// @public (undocumented)
export const ColorPickerGridCell: React.FunctionComponent<IColorPickerGridCellProps>;
Expand Down Expand Up @@ -415,7 +397,7 @@ export interface ICoachmark {
}

// @public
export interface ICoachmarkProps extends React.ClassAttributes<CoachmarkBase> {
export interface ICoachmarkProps {
ariaAlertText?: string;
ariaDescribedBy?: string;
ariaDescribedByText?: string;
Expand All @@ -427,6 +409,7 @@ export interface ICoachmarkProps extends React.ClassAttributes<CoachmarkBase> {
beakHeight?: number;
// @deprecated
beakWidth?: number;
children?: React.ReactNode;
className?: string;
// @deprecated
collapsed?: boolean;
Expand Down Expand Up @@ -456,24 +439,6 @@ export interface ICoachmarkProps extends React.ClassAttributes<CoachmarkBase> {
width?: number;
}

// @public (undocumented)
export interface ICoachmarkState {
alertText?: string;
beakBottom?: string;
beakLeft?: string;
beakRight?: string;
beakTop?: string;
entityInnerHostRect: IEntityRect;
isBeaconAnimating: boolean;
isCollapsed: boolean;
isMeasured: boolean;
isMeasuring: boolean;
isMouseInProximity: boolean;
targetAlignment?: RectangleEdge;
targetPosition?: RectangleEdge;
transformOrigin?: string;
}

// @public
export interface ICoachmarkStyleProps {
beaconColorOne?: string;
Expand All @@ -486,9 +451,7 @@ export interface ICoachmarkStyleProps {
entityHostHeight?: string;
entityHostWidth?: string;
height?: string;
isBeaconAnimating: boolean;
isCollapsed: boolean;
isMeasured: boolean;
isMeasuring: boolean;
theme?: ITheme;
transformOrigin?: string;
Expand Down Expand Up @@ -638,9 +601,9 @@ export interface IEditingSelectedPeopleItemStylesProps {
// @public
export interface IEntityRect {
// (undocumented)
height: number;
height?: number;
// (undocumented)
width: number;
width?: number;
}

// @public (undocumented)
Expand Down Expand Up @@ -1153,6 +1116,7 @@ export interface IPositioningContainerProps extends IBaseProps<IPositioningConta
ariaLabelledBy?: string;
backgroundColor?: string;
bounds?: IRectangle;
children?: ReactNode;
className?: string;
componentRef?: IRefObject<IPositioningContainer>;
coverTarget?: boolean;
Expand All @@ -1178,12 +1142,6 @@ export interface IPositioningContainerProps extends IBaseProps<IPositioningConta
useTargetPoint?: boolean;
}

// @public (undocumented)
export interface IPositioningContainerState {
heightOffset?: number;
positions?: IPositionedData;
}

// @public @deprecated (undocumented)
export type IPositioningContainerTypes = IPositioningContainerProps;

Expand Down Expand Up @@ -1941,35 +1899,7 @@ export namespace personaSize {
export const Popup: React.ForwardRefExoticComponent<IPopupProps & React.RefAttributes<HTMLDivElement>>;

// @public (undocumented)
export class PositioningContainer extends React.Component<IPositioningContainerProps, IPositioningContainerState> implements PositioningContainer {
constructor(props: IPositioningContainerProps);
// (undocumented)
componentDidMount(): void;
// (undocumented)
componentDidUpdate(): void;
// (undocumented)
componentWillUnmount(): void;
// (undocumented)
static defaultProps: IPositioningContainerProps;
// @deprecated
dismiss: (ev?: Event | React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLElement, MouseEvent> | undefined) => void;
// (undocumented)
protected _dismissOnLostFocus(ev: Event): void;
// (undocumented)
protected _dismissOnScroll(ev: Event): void;
// (undocumented)
protected _onComponentDidMount: () => void;
// (undocumented)
onResize: (ev?: Event | React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLElement, MouseEvent> | undefined) => void;
// (undocumented)
render(): JSX.Element | null;
// (undocumented)
protected _setInitialFocus: () => void;
// (undocumented)
UNSAFE_componentWillMount(): void;
// (undocumented)
UNSAFE_componentWillUpdate(newProps: IPositioningContainerProps): void;
}
export const PositioningContainer: React.ForwardRefExoticComponent<IPositioningContainerProps & React.RefAttributes<HTMLDivElement>>;

// @public (undocumented)
export const presenceBoolean: (presence: PersonaPresence) => {
Expand Down Expand Up @@ -2096,6 +2026,9 @@ export const Toggle: React.FunctionComponent<IToggleProps & React.RefAttributes<
// @public (undocumented)
export const ToggleBase: import("@fluentui/react-compose").ComponentWithAs<"div", IToggleProps>;

// @public (undocumented)
export function useHeightOffset({ finalHeight }: IPositioningContainerProps, contentHost: React.RefObject<HTMLDivElement | null>): number;

// @public
export const useLink: (props: ILinkProps, forwardedRef: React.Ref<HTMLElement>) => any;

Expand Down