Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@
{

@github-actions github-actions Bot Jul 14, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.chromium.png 12 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 743 Changed
vr-tests-react-components/ProgressBar converged 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - High Contrast.default.chromium.png 100 Changed
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness.default.chromium.png 138 Changed
vr-tests-react-components/TagPicker 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - High Contrast.disabled input hover.chromium.png 1319 Changed
vr-tests-react-components/TagPicker.disabled - RTL.chromium.png 635 Changed
vr-tests-react-components/TagPicker.disabled.disabled input hover.chromium.png 677 Changed

There were 3 duplicate changes discarded. Check the build logs for more information.

"type": "minor",
"comment": "Migrate Rotate from outAngle/inAngle to graph-level fromAngle/restAngle/toAngle parameters, and make rotateAtom a neutral directed fromAngle/toAngle atom",
"packageName": "@fluentui/react-motion-components-preview",
"email": "robertpenner@microsoft.com",
"dependentChangeType": "patch"
}
7 changes: 7 additions & 0 deletions change/@fluentui-react-nav-rotate-presence.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: migrate NavCategoryItem to the graph-level Rotate angle parameters",
"packageName": "@fluentui/react-nav",
"email": "robertpenner@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ export const FadeSnappy: PresenceComponent<FadeParams>;
export const Rotate: PresenceComponent<RotateParams>;

// @public
export const rotateAtom: ({ direction, duration, easing, delay, axis, outAngle, inAngle, }: RotateAtomParams) => AtomMotion;
export const rotateAtom: ({ duration, easing, delay, axis, fromAngle, toAngle, }: RotateAtomParams) => AtomMotion;

// @public (undocumented)
export type RotateParams = BasePresenceParams & AnimateOpacity & {
axis?: Axis3D;
outAngle?: number;
inAngle?: number;
fromAngle?: number;
restAngle?: number;
toAngle?: number;
};

// @public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,152 +2,57 @@ import { motionTokens } from '@fluentui/react-motion';
import { rotateAtom } from './rotate-atom';

describe('rotateAtom', () => {
it('creates enter keyframes with rotation from angle to 0', () => {
it('creates directed keyframes from one angle to another', () => {
const atom = rotateAtom({
direction: 'enter',
duration: 300,
easing: motionTokens.curveEasyEase,
outAngle: -90,
fromAngle: -90,
toAngle: 45,
});

expect(atom).toMatchObject({
duration: 300,
easing: motionTokens.curveEasyEase,
keyframes: [{ rotate: 'z -90deg' }, { rotate: 'z 0deg' }],
keyframes: [{ rotate: 'z -90deg' }, { rotate: 'z 45deg' }],
});
});

it('creates exit keyframes with rotation from 0 to inAngle', () => {
const atom = rotateAtom({
direction: 'exit',
duration: 250,
easing: motionTokens.curveAccelerateMin,
outAngle: -90,
inAngle: 90,
});

expect(atom).toMatchObject({
duration: 250,
easing: motionTokens.curveAccelerateMin,
keyframes: [{ rotate: 'z 90deg' }, { rotate: 'z -90deg' }],
});
});

it('uses default angle when not provided', () => {
const atom = rotateAtom({
direction: 'enter',
duration: 300,
});
it('uses default angle endpoints when not provided', () => {
const atom = rotateAtom({ duration: 300 });

expect(atom.keyframes).toEqual([{ rotate: 'z -90deg' }, { rotate: 'z 0deg' }]);
});

it('uses default easing when not provided', () => {
const atom = rotateAtom({
direction: 'enter',
duration: 300,
outAngle: 45,
});
const atom = rotateAtom({ duration: 300, fromAngle: 45 });

expect(atom.easing).toBe(motionTokens.curveLinear);
});

it('uses default axis when not provided', () => {
const atom = rotateAtom({
direction: 'enter',
duration: 300,
outAngle: 180,
});

expect(atom.keyframes[0]).toEqual({ rotate: 'z 180deg' });
expect(atom.keyframes[1]).toEqual({ rotate: 'z 0deg' });
});

it('applies custom outAngle and inAngle values', () => {
const atom = rotateAtom({
direction: 'enter',
duration: 300,
outAngle: 180,
inAngle: 45,
});

expect(atom.keyframes).toEqual([{ rotate: 'z 180deg' }, { rotate: 'z 45deg' }]);
});

it('handles different rotation axes', () => {
const atomX = rotateAtom({
direction: 'enter',
duration: 300,
axis: 'x',
outAngle: 45,
});
const atomX = rotateAtom({ duration: 300, axis: 'x', fromAngle: 45, toAngle: 0 });
const atomY = rotateAtom({ duration: 300, axis: 'y', fromAngle: 45, toAngle: 0 });
const atomZ = rotateAtom({ duration: 300, axis: 'z', fromAngle: 45, toAngle: 0 });

const atomY = rotateAtom({
direction: 'enter',
duration: 300,
axis: 'y',
outAngle: 45,
});

const atomZ = rotateAtom({
direction: 'enter',
duration: 300,
axis: 'z',
outAngle: 45,
});

expect(atomX.keyframes[0]).toEqual({ rotate: 'x 45deg' });
expect(atomY.keyframes[0]).toEqual({ rotate: 'y 45deg' });
expect(atomZ.keyframes[0]).toEqual({ rotate: 'z 45deg' });
});

it('uses inAngle when direction is exit', () => {
const atom = rotateAtom({
direction: 'exit',
duration: 300,
outAngle: -90,
inAngle: 45,
});

expect(atom.keyframes).toEqual([{ rotate: 'z 45deg' }, { rotate: 'z -90deg' }]);
});

it('uses default inAngle when not provided', () => {
const atom = rotateAtom({
direction: 'exit',
duration: 300,
outAngle: -90,
});

expect(atom.keyframes).toEqual([{ rotate: 'z 0deg' }, { rotate: 'z -90deg' }]);
expect(atomX.keyframes).toEqual([{ rotate: 'x 45deg' }, { rotate: 'x 0deg' }]);
expect(atomY.keyframes).toEqual([{ rotate: 'y 45deg' }, { rotate: 'y 0deg' }]);
expect(atomZ.keyframes).toEqual([{ rotate: 'z 45deg' }, { rotate: 'z 0deg' }]);
});

it('handles positive and negative angle values', () => {
const atomPositive = rotateAtom({
direction: 'enter',
duration: 300,
outAngle: 90,
});
const atom = rotateAtom({ duration: 300, fromAngle: 90, toAngle: -45 });

const atomNegative = rotateAtom({
direction: 'enter',
duration: 300,
outAngle: -45,
});

expect(atomPositive.keyframes[0]).toEqual({ rotate: 'z 90deg' });
expect(atomNegative.keyframes[0]).toEqual({ rotate: 'z -45deg' });
expect(atom.keyframes).toEqual([{ rotate: 'z 90deg' }, { rotate: 'z -45deg' }]);
});

it('includes all expected properties in the returned atom', () => {
it('includes timing properties in the returned atom', () => {
const atom = rotateAtom({
direction: 'enter',
duration: 400,
delay: 50,
easing: 'ease-in-out',
axis: 'x',
outAngle: 180,
inAngle: 45,
fromAngle: 180,
toAngle: 45,
});

expect(atom).toMatchObject({
Expand All @@ -157,23 +62,4 @@ describe('rotateAtom', () => {
delay: 50,
});
});

it('creates proper keyframes for enter and exit directions', () => {
const enterAtom = rotateAtom({
direction: 'enter',
duration: 300,
outAngle: -90,
inAngle: 0,
});

const exitAtom = rotateAtom({
direction: 'exit',
duration: 300,
outAngle: -90,
inAngle: 0,
});

expect(enterAtom.keyframes).toEqual([{ rotate: 'z -90deg' }, { rotate: 'z 0deg' }]);
expect(exitAtom.keyframes).toEqual([{ rotate: 'z 0deg' }, { rotate: 'z -90deg' }]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import type { BaseAtomParams } from '../types';

type Axis3D = NonNullable<RotateParams['axis']>;

interface RotateAtomParams extends BaseAtomParams {
interface RotateAtomParams extends Omit<BaseAtomParams, 'direction'> {
axis?: Axis3D;
/** Rotation angle for the out state (exited) in degrees. Defaults to -90. */
outAngle?: number;
/** Rotation angle for the in state (entered) in degrees. Defaults to 0. */
inAngle?: number;
/** Rotation angle at the start of the directed motion in degrees. Defaults to -90. */
fromAngle?: number;
/** Rotation angle at the end of the directed motion in degrees. Defaults to 0. */
toAngle?: number;
}

const createRotateValue = (axis: Axis3D, angle: number): string => {
Expand All @@ -19,33 +19,24 @@ const createRotateValue = (axis: Axis3D, angle: number): string => {

/**
* Generates a motion atom object for a rotation around a single axis.
* @param direction - The functional direction of the motion: 'enter' or 'exit'.
* @param duration - The duration of the motion in milliseconds.
* @param easing - The easing curve for the motion. Defaults to `motionTokens.curveLinear`.
* @param axis - The axis of rotation: 'x', 'y', or 'z'. Defaults to 'y'.
* @param outAngle - Rotation angle for the out state (exited) in degrees. Defaults to -90.
* @param inAngle - Rotation angle for the in state (entered) in degrees. Defaults to 0.
* @param fromAngle - Rotation angle at the start of the directed motion in degrees. Defaults to -90.
* @param toAngle - Rotation angle at the end of the directed motion in degrees. Defaults to 0.
* @param delay - Time (ms) to delay the animation. Defaults to 0.
* @returns A motion atom object with rotate keyframes and the supplied duration and easing.
*/
export const rotateAtom = ({
direction,
duration,
easing = motionTokens.curveLinear,
delay = 0,
axis = 'z',
outAngle = -90,
inAngle = 0,
}: RotateAtomParams): AtomMotion => {
const keyframes = [{ rotate: createRotateValue(axis, outAngle) }, { rotate: createRotateValue(axis, inAngle) }];
if (direction === 'exit') {
keyframes.reverse();
}

return {
keyframes,
duration,
easing,
delay,
};
};
fromAngle = -90,
toAngle = 0,
}: RotateAtomParams): AtomMotion => ({
keyframes: [{ rotate: createRotateValue(axis, fromAngle) }, { rotate: createRotateValue(axis, toAngle) }],
duration,
easing,
delay,
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
import type { AtomMotion, AtomMotionFn, PresenceMotion, PresenceMotionFn } from '@fluentui/react-motion';
import { motionTokens } from '@fluentui/react-motion';
import { expectPresenceMotionFunction, expectPresenceMotionArray } from '../../testing/testUtils';
import type { RotateParams } from './rotate-types';
import { Rotate } from './Rotate';

const element = document.createElement('div');

function getDefinition<T>(component: object, description: string): T {
const symbol = Object.getOwnPropertySymbols(component).find(candidate => candidate.description === description);

if (!symbol) {
throw new Error(`Expected ${description} on component`);
}

return (component as Record<symbol, T>)[symbol];
}

function getPresence(params: RotateParams = {}): PresenceMotion {
const definition = getDefinition<PresenceMotionFn<RotateParams>>(Rotate, 'PRESENCE_MOTION_DEFINITION');
return definition({ element, ...params });
}

function getProjection(component: object, params: RotateParams = {}): AtomMotion[] {
const definition = getDefinition<AtomMotionFn<RotateParams>>(component, 'MOTION_DEFINITION');
const motion = definition({ element, ...params });
return Array.isArray(motion) ? motion : [motion];
}

describe('Rotate', () => {
it('stores its motion definition as a static function', () => {
expectPresenceMotionFunction(Rotate);
Expand All @@ -9,4 +35,68 @@ describe('Rotate', () => {
it('generates a motion definition from the static function', () => {
expectPresenceMotionArray(Rotate);
});

it('projects from to rest on enter and rest to to on exit', () => {
const presence = getPresence({ fromAngle: -45, restAngle: 15, toAngle: 120, animateOpacity: false });

expect((presence.enter as AtomMotion[])[0].keyframes).toEqual([{ rotate: 'z -45deg' }, { rotate: 'z 15deg' }]);
expect((presence.exit as AtomMotion[])[0].keyframes).toEqual([{ rotate: 'z 15deg' }, { rotate: 'z 120deg' }]);
});

it('defaults the exit destination to the entry origin', () => {
const presence = getPresence({ fromAngle: 35, restAngle: 5, animateOpacity: false });

expect((presence.exit as AtomMotion[])[0].keyframes).toEqual([{ rotate: 'z 5deg' }, { rotate: 'z 35deg' }]);
expect(getProjection(Rotate.Out, { fromAngle: 35, restAngle: 5, animateOpacity: false })[0].keyframes).toEqual([
{ rotate: 'z 5deg' },
{ rotate: 'z 35deg' },
]);
});

it('keeps factory-generated In and Out projections on the shared RotateParams record', () => {
const params: RotateParams = {
fromAngle: -30,
restAngle: 10,
toAngle: 80,
axis: 'x',
animateOpacity: false,
};

expect(getProjection(Rotate.In, params)[0].keyframes).toEqual([{ rotate: 'x -30deg' }, { rotate: 'x 10deg' }]);
expect(getProjection(Rotate.Out, params)[0].keyframes).toEqual([{ rotate: 'x 10deg' }, { rotate: 'x 80deg' }]);
});

it('applies entry and exit timing to the corresponding projections', () => {
const params: RotateParams = {
duration: 150,
easing: motionTokens.curveEasyEase,
delay: 25,
exitDuration: 275,
exitEasing: motionTokens.curveAccelerateMid,
exitDelay: 40,
animateOpacity: false,
};

expect(getProjection(Rotate.In, params)[0]).toMatchObject({ duration: 150, easing: params.easing, delay: 25 });
expect(getProjection(Rotate.Out, params)[0]).toMatchObject({
duration: 275,
easing: params.exitEasing,
delay: 40,
});
});

it('uses entry duration and delay as exit timing fallbacks', () => {
expect(getProjection(Rotate.Out, { duration: 180, delay: 30, animateOpacity: false })[0]).toMatchObject({
duration: 180,
easing: motionTokens.curveAccelerateMax,
delay: 30,
});
});

it('preserves opacity composition and supports disabling it', () => {
expect(getProjection(Rotate.In)[1].keyframes).toEqual([{ opacity: 0 }, { opacity: 1 }]);
expect(getProjection(Rotate.Out)[1].keyframes).toEqual([{ opacity: 1 }, { opacity: 0 }]);
expect(getProjection(Rotate.In, { animateOpacity: false })).toHaveLength(1);
expect(getProjection(Rotate.Out, { animateOpacity: false })).toHaveLength(1);
});
});
Loading
Loading