Private
Public Access
1
0

feat: Fluent UI Outlook Lite + connections mockup

This commit is contained in:
2026-04-14 18:52:25 +00:00
parent 1199eff6c3
commit dfa4010406
34820 changed files with 1003813 additions and 205 deletions

View File

@@ -0,0 +1,109 @@
import { motionTokens, createPresenceComponent, createPresenceComponentVariant } from '@fluentui/react-motion';
import { sizeEnterAtom, sizeExitAtom, whitespaceAtom } from './collapse-atoms';
import { fadeAtom } from '../../atoms/fade-atom';
/**
* Define a presence motion for collapse/expand
*
* @param element - The element to apply the collapse motion to
* @param duration - Time (ms) for the enter transition (expand). Defaults to the `durationNormal` value (200 ms)
* @param easing - Easing curve for the enter transition. Defaults to the `curveEasyEaseMax` value
* @param delay - Time (ms) to delay the entire enter transition. Defaults to 0
* @param exitDuration - Time (ms) for the exit transition (collapse). Defaults to the `duration` param for symmetry
* @param exitEasing - Easing curve for the exit transition. Defaults to the `easing` param for symmetry
* @param exitDelay - Time (ms) to delay the entire exit transition. Defaults to the `delay` param for symmetry
* @param staggerDelay - Time (ms) offset between the size and opacity animations. Defaults to 0
* @param exitStaggerDelay - Time (ms) offset between the size and opacity animations on exit. Defaults to the `staggerDelay` param for symmetry
* @param sizeDuration - Time (ms) for the size animation during enter. Defaults to `duration` for unified timing
* @param opacityDuration - Time (ms) for the opacity animation during enter. Defaults to `sizeDuration` for synchronized timing
* @param exitSizeDuration - Time (ms) for the size animation during exit. Defaults to `exitDuration` for unified timing
* @param exitOpacityDuration - Time (ms) for the opacity animation during exit. Defaults to `exitSizeDuration` for synchronized timing
* @param animateOpacity - Whether to animate the opacity. Defaults to `true`
* @param orientation - The orientation of the size animation. Defaults to `'vertical'` to expand/collapse the height
* @param outSize - Size for the out state (collapsed). Defaults to `'0px'`
*/ const collapsePresenceFn = ({ element, // Primary duration controls (simple API)
duration = motionTokens.durationNormal, exitDuration = duration, // Granular duration controls with smart defaults (advanced API)
sizeDuration = duration, opacityDuration = sizeDuration, exitSizeDuration = exitDuration, exitOpacityDuration = exitSizeDuration, // Other timing controls
easing = motionTokens.curveEasyEaseMax, delay = 0, exitEasing = easing, exitDelay = delay, staggerDelay = 0, exitStaggerDelay = staggerDelay, // Animation controls
animateOpacity = true, orientation = 'vertical', outSize = '0px' })=>{
// ----- ENTER -----
// The enter transition is an array of up to 3 motion atoms: size, whitespace and opacity.
// For enter: size expands first, then opacity fades in after staggerDelay
const enterAtoms = [
// Apply global delay to size atom - size expansion starts first
sizeEnterAtom({
orientation,
duration: sizeDuration,
easing,
element,
outSize,
delay
}),
whitespaceAtom({
direction: 'enter',
orientation,
duration: sizeDuration,
easing,
delay
})
];
// Fade in only if animateOpacity is true. Otherwise, leave opacity unaffected.
if (animateOpacity) {
enterAtoms.push(fadeAtom({
direction: 'enter',
duration: opacityDuration,
easing,
delay: delay + staggerDelay
}));
}
// ----- EXIT -----
// The exit transition is an array of up to 3 motion atoms: opacity, size and whitespace.
// For exit: opacity fades out first, then size collapses after exitStaggerDelay
const exitAtoms = [];
// Fade out only if animateOpacity is true. Otherwise, leave opacity unaffected.
if (animateOpacity) {
exitAtoms.push(fadeAtom({
direction: 'exit',
duration: exitOpacityDuration,
easing: exitEasing,
delay: exitDelay
}));
}
exitAtoms.push(sizeExitAtom({
orientation,
duration: exitSizeDuration,
easing: exitEasing,
element,
delay: exitDelay + exitStaggerDelay,
outSize
}), whitespaceAtom({
direction: 'exit',
orientation,
duration: exitSizeDuration,
easing: exitEasing,
delay: exitDelay + exitStaggerDelay
}));
return {
enter: enterAtoms,
exit: exitAtoms
};
};
/** A React component that applies collapse/expand transitions to its children. */ export const Collapse = createPresenceComponent(collapsePresenceFn);
export const CollapseSnappy = createPresenceComponentVariant(Collapse, {
duration: motionTokens.durationFast
});
export const CollapseRelaxed = createPresenceComponentVariant(Collapse, {
duration: motionTokens.durationSlower
});
/** A React component that applies collapse/expand transitions with delayed fade to its children. */ export const CollapseDelayed = createPresenceComponentVariant(Collapse, {
// Enter timing per motion design spec
sizeDuration: motionTokens.durationNormal,
opacityDuration: motionTokens.durationSlower,
staggerDelay: motionTokens.durationNormal,
// Exit timing per motion design spec
exitSizeDuration: motionTokens.durationNormal,
exitOpacityDuration: motionTokens.durationSlower,
exitStaggerDelay: motionTokens.durationSlower,
// Easing per motion design spec
easing: motionTokens.curveEasyEase,
exitEasing: motionTokens.curveEasyEase
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,100 @@
// ----- SIZE -----
const sizeValuesForOrientation = (orientation, element)=>{
const sizeName = orientation === 'horizontal' ? 'maxWidth' : 'maxHeight';
const overflowName = orientation === 'horizontal' ? 'overflowX' : 'overflowY';
const measuredSize = orientation === 'horizontal' ? element.scrollWidth : element.scrollHeight;
const toSize = `${measuredSize}px`;
return {
sizeName,
overflowName,
toSize
};
};
export const sizeEnterAtom = ({ orientation, duration, easing, element, outSize = '0', delay = 0 })=>{
const { sizeName, overflowName, toSize } = sizeValuesForOrientation(orientation, element);
return {
keyframes: [
{
[sizeName]: outSize,
[overflowName]: 'hidden'
},
{
[sizeName]: toSize,
offset: 0.9999,
[overflowName]: 'hidden'
},
{
[sizeName]: 'unset',
[overflowName]: 'unset'
}
],
duration,
easing,
delay,
fill: 'both'
};
};
export const sizeExitAtom = ({ orientation, duration, easing, element, delay = 0, outSize = '0' })=>{
const { sizeName, overflowName, toSize } = sizeValuesForOrientation(orientation, element);
return {
keyframes: [
{
[sizeName]: toSize,
[overflowName]: 'hidden'
},
{
[sizeName]: outSize,
[overflowName]: 'hidden'
}
],
duration,
easing,
delay,
fill: 'both'
};
};
// ----- WHITESPACE -----
// Whitespace animation includes padding and margin.
const whitespaceValuesForOrientation = (orientation)=>{
// horizontal whitespace collapse
if (orientation === 'horizontal') {
return {
paddingStart: 'paddingInlineStart',
paddingEnd: 'paddingInlineEnd',
marginStart: 'marginInlineStart',
marginEnd: 'marginInlineEnd'
};
}
// vertical whitespace collapse
return {
paddingStart: 'paddingBlockStart',
paddingEnd: 'paddingBlockEnd',
marginStart: 'marginBlockStart',
marginEnd: 'marginBlockEnd'
};
};
/**
* A collapse animates an element's height to zero,
but the zero height does not eliminate padding or margin in the box model.
So here we generate keyframes to animate those whitespace properties to zero.
*/ export const whitespaceAtom = ({ direction, orientation, duration, easing, delay = 0 })=>{
const { paddingStart, paddingEnd, marginStart, marginEnd } = whitespaceValuesForOrientation(orientation);
// The keyframe with zero whitespace is at the start for enter and at the end for exit.
const offset = direction === 'enter' ? 0 : 1;
const keyframes = [
{
[paddingStart]: '0',
[paddingEnd]: '0',
[marginStart]: '0',
[marginEnd]: '0',
offset
}
];
return {
keyframes,
duration,
easing,
delay,
fill: 'both'
};
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,137 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /**
* Helper to validate the structure of a collapse motion object.
* Returns validation data that can be used with Jest expectations.
*/ export function getCollapseMotionValidation(motion) {
return {
enterCount: motion.enter.length,
exitCount: motion.exit.length,
hasEnterOpacity: motion.enter.length === 3 && 'opacity' in (motion.enter[2].keyframes[0] || {}),
hasExitOpacity: motion.exit.length === 3 && 'opacity' in (motion.exit[0].keyframes[0] || {}),
enterStructure: motion.enter.map((atom)=>({
hasKeyframes: Array.isArray(atom.keyframes),
hasDuration: typeof atom.duration === 'number',
hasEasing: typeof atom.easing === 'string',
hasDelay: typeof atom.delay === 'number'
})),
exitStructure: motion.exit.map((atom)=>({
hasKeyframes: Array.isArray(atom.keyframes),
hasDuration: typeof atom.duration === 'number',
hasEasing: typeof atom.easing === 'string',
hasDelay: typeof atom.delay === 'number'
}))
};
}
/**
* Helper to extract timing information from collapse motion atoms.
*/ export function getCollapseTimingInfo(motion, animateOpacity = true) {
var _motion_enter_, _motion_enter_1, _motion_enter_2, _motion_exit_, _motion_exit_1, _motion_exit_2, _motion_exit_3, _motion_exit_4;
var _motion_enter__delay, _motion_enter__delay1, _motion_enter__delay2;
const enterDelays = {
size: (_motion_enter__delay = (_motion_enter_ = motion.enter[0]) === null || _motion_enter_ === void 0 ? void 0 : _motion_enter_.delay) !== null && _motion_enter__delay !== void 0 ? _motion_enter__delay : 0,
whitespace: (_motion_enter__delay1 = (_motion_enter_1 = motion.enter[1]) === null || _motion_enter_1 === void 0 ? void 0 : _motion_enter_1.delay) !== null && _motion_enter__delay1 !== void 0 ? _motion_enter__delay1 : 0,
opacity: animateOpacity ? (_motion_enter__delay2 = (_motion_enter_2 = motion.enter[2]) === null || _motion_enter_2 === void 0 ? void 0 : _motion_enter_2.delay) !== null && _motion_enter__delay2 !== void 0 ? _motion_enter__delay2 : 0 : undefined
};
var _motion_exit__delay, _motion_exit__delay1, _motion_exit__delay2, _motion_exit__delay3, _motion_exit__delay4;
const exitDelays = animateOpacity ? {
opacity: (_motion_exit__delay = (_motion_exit_ = motion.exit[0]) === null || _motion_exit_ === void 0 ? void 0 : _motion_exit_.delay) !== null && _motion_exit__delay !== void 0 ? _motion_exit__delay : 0,
size: (_motion_exit__delay1 = (_motion_exit_1 = motion.exit[1]) === null || _motion_exit_1 === void 0 ? void 0 : _motion_exit_1.delay) !== null && _motion_exit__delay1 !== void 0 ? _motion_exit__delay1 : 0,
whitespace: (_motion_exit__delay2 = (_motion_exit_2 = motion.exit[2]) === null || _motion_exit_2 === void 0 ? void 0 : _motion_exit_2.delay) !== null && _motion_exit__delay2 !== void 0 ? _motion_exit__delay2 : 0
} : {
size: (_motion_exit__delay3 = (_motion_exit_3 = motion.exit[0]) === null || _motion_exit_3 === void 0 ? void 0 : _motion_exit_3.delay) !== null && _motion_exit__delay3 !== void 0 ? _motion_exit__delay3 : 0,
whitespace: (_motion_exit__delay4 = (_motion_exit_4 = motion.exit[1]) === null || _motion_exit_4 === void 0 ? void 0 : _motion_exit_4.delay) !== null && _motion_exit__delay4 !== void 0 ? _motion_exit__delay4 : 0
};
return {
enter: enterDelays,
exit: exitDelays
};
}
/**
* Helper to extract duration information from collapse motion atoms.
*/ export function getCollapseDurationInfo(motion, animateOpacity = true) {
var _motion_enter_, _motion_enter_1, _motion_enter_2, _motion_exit_, _motion_exit_1, _motion_exit_2, _motion_exit_3, _motion_exit_4;
var _motion_enter__duration, _motion_enter__duration1, _motion_enter__duration2;
const enterDurations = {
size: (_motion_enter__duration = (_motion_enter_ = motion.enter[0]) === null || _motion_enter_ === void 0 ? void 0 : _motion_enter_.duration) !== null && _motion_enter__duration !== void 0 ? _motion_enter__duration : 0,
whitespace: (_motion_enter__duration1 = (_motion_enter_1 = motion.enter[1]) === null || _motion_enter_1 === void 0 ? void 0 : _motion_enter_1.duration) !== null && _motion_enter__duration1 !== void 0 ? _motion_enter__duration1 : 0,
opacity: animateOpacity ? (_motion_enter__duration2 = (_motion_enter_2 = motion.enter[2]) === null || _motion_enter_2 === void 0 ? void 0 : _motion_enter_2.duration) !== null && _motion_enter__duration2 !== void 0 ? _motion_enter__duration2 : 0 : undefined
};
var _motion_exit__duration, _motion_exit__duration1, _motion_exit__duration2, _motion_exit__duration3, _motion_exit__duration4;
const exitDurations = animateOpacity ? {
opacity: (_motion_exit__duration = (_motion_exit_ = motion.exit[0]) === null || _motion_exit_ === void 0 ? void 0 : _motion_exit_.duration) !== null && _motion_exit__duration !== void 0 ? _motion_exit__duration : 0,
size: (_motion_exit__duration1 = (_motion_exit_1 = motion.exit[1]) === null || _motion_exit_1 === void 0 ? void 0 : _motion_exit_1.duration) !== null && _motion_exit__duration1 !== void 0 ? _motion_exit__duration1 : 0,
whitespace: (_motion_exit__duration2 = (_motion_exit_2 = motion.exit[2]) === null || _motion_exit_2 === void 0 ? void 0 : _motion_exit_2.duration) !== null && _motion_exit__duration2 !== void 0 ? _motion_exit__duration2 : 0
} : {
size: (_motion_exit__duration3 = (_motion_exit_3 = motion.exit[0]) === null || _motion_exit_3 === void 0 ? void 0 : _motion_exit_3.duration) !== null && _motion_exit__duration3 !== void 0 ? _motion_exit__duration3 : 0,
whitespace: (_motion_exit__duration4 = (_motion_exit_4 = motion.exit[1]) === null || _motion_exit_4 === void 0 ? void 0 : _motion_exit_4.duration) !== null && _motion_exit__duration4 !== void 0 ? _motion_exit__duration4 : 0
};
return {
enter: enterDurations,
exit: exitDurations
};
}
/**
* Helper to analyze orientation-specific properties in collapse atoms.
*/ export function getCollapseOrientationInfo(motion, animateOpacity = true) {
const enterSizeAtom = motion.enter[0];
const enterWhitespaceAtom = motion.enter[1];
const exitOffset = animateOpacity ? 1 : 0;
const exitSizeAtom = motion.exit[exitOffset];
const exitWhitespaceAtom = motion.exit[exitOffset + 1];
return {
enter: {
sizeProperties: Object.keys((enterSizeAtom === null || enterSizeAtom === void 0 ? void 0 : enterSizeAtom.keyframes[0]) || {}),
whitespaceProperties: Object.keys((enterWhitespaceAtom === null || enterWhitespaceAtom === void 0 ? void 0 : enterWhitespaceAtom.keyframes[0]) || {})
},
exit: {
sizeProperties: Object.keys((exitSizeAtom === null || exitSizeAtom === void 0 ? void 0 : exitSizeAtom.keyframes[0]) || {}),
whitespaceProperties: Object.keys((exitWhitespaceAtom === null || exitWhitespaceAtom === void 0 ? void 0 : exitWhitespaceAtom.keyframes[0]) || {})
}
};
}
/**
* Helper to analyze size atom keyframes for validation.
*/ export function getSizeAtomInfo(sizeAtom, direction) {
const keyframes = sizeAtom.keyframes;
const properties = Object.keys(keyframes[0] || {});
return {
keyframeCount: keyframes.length,
properties,
hasOffset: direction === 'enter' ? 'offset' in (keyframes[1] || {}) : false,
hasFill: 'fill' in sizeAtom,
fillValue: sizeAtom.fill,
firstFrameValues: keyframes[0] || {},
lastFrameValues: keyframes[keyframes.length - 1] || {}
};
}
/**
* Helper to analyze whitespace atom keyframes for validation.
*/ export function getWhitespaceAtomInfo(whitespaceAtom, direction) {
const keyframe = whitespaceAtom.keyframes[0] || {};
return {
properties: Object.keys(keyframe),
offset: keyframe.offset,
expectedOffset: direction === 'enter' ? 0 : 1,
hasFill: 'fill' in whitespaceAtom,
fillValue: whitespaceAtom.fill,
isVertical: 'paddingBlockStart' in keyframe,
isHorizontal: 'paddingInlineStart' in keyframe
};
}
/**
* Helper to compare opacity handling between two motion objects.
*/ export function getOpacityComparisonInfo(withOpacity, withoutOpacity) {
return {
withOpacity: {
enterCount: withOpacity.enter.length,
exitCount: withOpacity.exit.length,
hasEnterOpacity: withOpacity.enter.length === 3,
hasExitOpacity: withOpacity.exit.length === 3
},
withoutOpacity: {
enterCount: withoutOpacity.enter.length,
exitCount: withoutOpacity.exit.length,
hasEnterOpacity: false,
hasExitOpacity: false
}
};
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export { };

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Collapse/collapse-types.ts"],"sourcesContent":["import type { BasePresenceParams, AnimateOpacity } from '../../types';\n\nexport type CollapseOrientation = 'horizontal' | 'vertical';\n\n/**\n * Duration properties for granular timing control in Collapse animations.\n */\nexport type CollapseDurations = {\n /** Time (ms) for the size animation during enter. Defaults to `duration` for unified timing. */\n sizeDuration?: number;\n\n /** Time (ms) for the opacity animation during enter. Defaults to `sizeDuration` for synchronized timing. */\n opacityDuration?: number;\n\n /** Time (ms) for the size animation during exit. Defaults to `exitDuration` for unified timing. */\n exitSizeDuration?: number;\n\n /** Time (ms) for the opacity animation during exit. Defaults to `exitSizeDuration` for synchronized timing. */\n exitOpacityDuration?: number;\n};\n\nexport type CollapseParams = BasePresenceParams &\n AnimateOpacity &\n CollapseDurations & {\n /** The orientation of the size animation. Defaults to `'vertical'` to expand/collapse the height. */\n orientation?: CollapseOrientation;\n\n /** Size for the out state (collapsed). Defaults to `'0px'`. */\n outSize?: string;\n\n /**\n * Time (ms) to delay the inner stagger between size and opacity animations.\n * On enter this delays the opacity after size; on exit this delays the size after opacity.\n * Defaults to 0.\n */\n staggerDelay?: number;\n\n /**\n * Time (ms) to delay the inner stagger during exit. Defaults to the `staggerDelay` param for symmetry.\n */\n exitStaggerDelay?: number;\n };\n"],"names":[],"mappings":"AAqBA,WAoBI"}

View File

@@ -0,0 +1 @@
export { Collapse, CollapseDelayed, CollapseRelaxed, CollapseSnappy } from './Collapse';

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Collapse/index.ts"],"sourcesContent":["export { Collapse, CollapseDelayed, CollapseRelaxed, CollapseSnappy } from './Collapse';\nexport type { CollapseParams, CollapseDurations } from './collapse-types';\n"],"names":["Collapse","CollapseDelayed","CollapseRelaxed","CollapseSnappy"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,eAAe,EAAEC,eAAe,EAAEC,cAAc,QAAQ,aAAa"}