Line data Source code
1 2355 : export const MEDIA_ASSET_GRID_MODE = {
2 : gridSmall: 'grid-small',
3 : grid: 'grid'
4 : } as const
5 :
6 2355 : export const MEDIA_ASSET_VIEW_MODE = {
7 : list: 'list',
8 : ...MEDIA_ASSET_GRID_MODE
9 : } as const
10 :
11 : // TODO: Introduce a shared ValueOf<T> for object-value unions across the codebase.
12 : export type MediaAssetGridMode =
13 : (typeof MEDIA_ASSET_GRID_MODE)[keyof typeof MEDIA_ASSET_GRID_MODE]
14 :
15 : export type MediaAssetViewMode =
16 : (typeof MEDIA_ASSET_VIEW_MODE)[keyof typeof MEDIA_ASSET_VIEW_MODE]
17 :
18 103 : export function getMediaAssetGridColumns(mode: MediaAssetGridMode): string {
19 : const minWidth = mode === MEDIA_ASSET_GRID_MODE.gridSmall ? 128 : 240
20 103 : return `repeat(auto-fill, minmax(min(${minWidth}px, 30vw), 1fr))`
21 : }
|