Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com> Co-authored-by: Julius Marminge <[email protected]>
23 lines
776 B
TypeScript
23 lines
776 B
TypeScript
export const THREAD_SIDEBAR_WIDTH_STORAGE_KEY = "chat_thread_sidebar_width";
|
|
const THREAD_SIDEBAR_DEFAULT_WIDTH = 16 * 16;
|
|
export const THREAD_SIDEBAR_MIN_WIDTH = 13 * 16;
|
|
export const THREAD_MAIN_CONTENT_MIN_WIDTH = 40 * 16;
|
|
|
|
export function resolveThreadSidebarMaximumWidth(viewportWidth: number): number {
|
|
return Math.max(
|
|
THREAD_SIDEBAR_MIN_WIDTH,
|
|
Math.floor(viewportWidth) - THREAD_MAIN_CONTENT_MIN_WIDTH,
|
|
);
|
|
}
|
|
|
|
export function resolveInitialThreadSidebarWidth(
|
|
storedWidth: number | null,
|
|
viewportWidth: number,
|
|
): number {
|
|
const preferredWidth =
|
|
storedWidth === null
|
|
? THREAD_SIDEBAR_DEFAULT_WIDTH
|
|
: Math.max(THREAD_SIDEBAR_MIN_WIDTH, storedWidth);
|
|
return Math.min(preferredWidth, resolveThreadSidebarMaximumWidth(viewportWidth));
|
|
}
|