Process incoming story messages
This commit is contained in:
parent
df7cdfacc7
commit
eb91eb6fec
84 changed files with 4382 additions and 652 deletions
28
ts/util/leftPaneWidth.ts
Normal file
28
ts/util/leftPaneWidth.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { clamp } from 'lodash';
|
||||
import { isSorted } from './isSorted';
|
||||
import { strictAssert } from './assert';
|
||||
|
||||
export const MIN_WIDTH = 97;
|
||||
export const SNAP_WIDTH = 200;
|
||||
export const MIN_FULL_WIDTH = 280;
|
||||
export const MAX_WIDTH = 380;
|
||||
strictAssert(
|
||||
isSorted([MIN_WIDTH, SNAP_WIDTH, MIN_FULL_WIDTH, MAX_WIDTH]),
|
||||
'Expected widths to be in the right order'
|
||||
);
|
||||
|
||||
export function getWidthFromPreferredWidth(
|
||||
preferredWidth: number,
|
||||
{ requiresFullWidth }: { requiresFullWidth: boolean }
|
||||
): number {
|
||||
const clampedWidth = clamp(preferredWidth, MIN_WIDTH, MAX_WIDTH);
|
||||
|
||||
if (requiresFullWidth || clampedWidth >= SNAP_WIDTH) {
|
||||
return Math.max(clampedWidth, MIN_FULL_WIDTH);
|
||||
}
|
||||
|
||||
return MIN_WIDTH;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue