Files
jitsi-meet/react/features/custom-panel/reducer.ts
Hristo Terezov e672aaa35a feat(custom-panel): add resizable panel width with drag handle and persistence
Allow users to resize the custom panel by dragging a handle on its left
edge, matching the chat panel's resize UX. The panel width is persisted
via PersistenceRegistry so it survives page reloads.

Architectural changes:
- Split CustomPanel into container (resize/close) + CustomPanelContent (branding override)
- Split functions.ts into core functions + functions.custom.ts (branding override)
- Split middleware.web.ts into orchestrator + middleware.custom.web.ts (branding override)
- Chat max size now accounts for custom panel width for mutual awareness

	test-localStorage1.html
2026-03-30 13:36:29 -05:00

124 lines
2.7 KiB
TypeScript

import PersistenceRegistry from '../base/redux/PersistenceRegistry';
import ReducerRegistry from '../base/redux/ReducerRegistry';
import {
CUSTOM_PANEL_CLOSE,
CUSTOM_PANEL_OPEN,
SET_CUSTOM_PANEL_ENABLED,
SET_CUSTOM_PANEL_IS_RESIZING,
SET_CUSTOM_PANEL_WIDTH,
SET_USER_CUSTOM_PANEL_WIDTH
} from './actionTypes';
import { DEFAULT_CUSTOM_PANEL_WIDTH } from './constants';
/**
* The state of the custom panel feature.
*/
export interface ICustomPanelState {
/**
* Whether the custom panel feature is enabled.
* This can be toggled dynamically via console.
*/
enabled: boolean;
/**
* Whether the custom panel is currently open.
*/
isOpen: boolean;
/**
* Whether the user is currently resizing the custom panel.
*/
isResizing: boolean;
/**
* The width state of the custom panel.
*/
width: {
/**
* The current display width in pixels.
*/
current: number;
/**
* The user-preferred width set via drag resize, or null if not set.
*/
userSet: number | null;
};
}
const DEFAULT_STATE: ICustomPanelState = {
enabled: false,
isOpen: false,
isResizing: false,
width: {
current: DEFAULT_CUSTOM_PANEL_WIDTH,
userSet: null
}
};
/**
* Persist only the width subtree so the user's preferred panel width
* survives page reloads.
*/
PersistenceRegistry.register('features/custom-panel', {
enabled: true,
width: true
});
/**
* Listen for actions that mutate the custom panel state.
*/
ReducerRegistry.register(
'features/custom-panel', (state: ICustomPanelState = DEFAULT_STATE, action): ICustomPanelState => {
switch (action.type) {
case CUSTOM_PANEL_CLOSE:
return {
...state,
isOpen: false
};
case CUSTOM_PANEL_OPEN:
return {
...state,
isOpen: true
};
case SET_CUSTOM_PANEL_ENABLED:
return {
...state,
enabled: action.enabled
};
case SET_CUSTOM_PANEL_WIDTH:
return {
...state,
width: {
...state.width,
current: action.width
}
};
case SET_USER_CUSTOM_PANEL_WIDTH:
return {
...state,
width: {
current: action.width,
userSet: action.width
}
};
case SET_CUSTOM_PANEL_IS_RESIZING:
return {
...state,
isResizing: action.resizing
};
default:
return state;
}
}
);