v0.1.4 2490b00

maximizable.ts RawHistoryFolder

1import type { Action } from 'svelte/action';
2interface MaximizableParameters {
3  enabled?: boolean;
4  padding?: number;
5}
6
7interface MaximizableAttributes {
8  onmaximize?: (e: CustomEvent<{ 
9    isMaximized: boolean;
10    width: number;
11    height: number;
12    x: number;
13    y: number;
14  }>) => void;
15}
16
17interface StoredState {
18  width: number;
19  height: number;
20  x: number;
21  y: number;
22}
23
24export const maximizable: Action<HTMLDivElement, MaximizableParameters, MaximizableAttributes> = (node, params = {}) => {
25  const {
26    enabled = true,
27    padding = 0
28  } = params;
29
30  let isMaximized = false;
31  let storedState: StoredState | null = null;
32
33  function maximize() {
34    if (!enabled || isMaximized) return;
35
36    // Store current state
37    storedState = {
38      width: node.offsetWidth,
39      height: node.offsetHeight,
40      x: parseInt(node.style.left) || 0,
41      y: parseInt(node.style.top) || 0
42    };
43
44    // Set maximized state
45    const maxWidth = window.innerWidth - (padding * 2);
46    const maxHeight = window.innerHeight - (padding * 2);
47    
48    node.style.width = `${maxWidth}px`;
49    node.style.height = `${maxHeight}px`;
50    node.style.left = `${padding}px`;
51    node.style.top = `${padding}px`;
52    
53    isMaximized = true;
54
55    node.dispatchEvent(new CustomEvent('maximize', {
56      detail: { 
57        isMaximized: true,
58        width: maxWidth,
59        height: maxHeight,
60        x: padding,
61        y: padding
62      }
63    }));
64  }
65
66  function restore() {
67    if (!enabled || !isMaximized || !storedState) return;
68
69    // Restore previous state
70    node.style.width = `${storedState.width}px`;
71    node.style.height = `${storedState.height}px`;
72    node.style.left = `${storedState.x}px`;
73    node.style.top = `${storedState.y}px`;
74
75    isMaximized = false;
76
77    node.dispatchEvent(new CustomEvent('maximize', {
78      detail: { 
79        isMaximized: false,
80        ...storedState
81      }
82    }));
83  }
84
85  function toggle() {
86    if (isMaximized) {
87      restore();
88    } else {
89      maximize();
90    }
91  }
92
93  // Expose methods to the node
94  Object.assign(node, {
95    maximize,
96    restore,
97    toggleMaximize: toggle,
98    isMaximized: () => isMaximized
99  });
100
101  return {
102    update(newParams: MaximizableParameters) {
103      Object.assign(params, newParams);
104    },
105    destroy() {
106      // Clean up if needed
107    }
108  };
109}; 

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 3

Tags 8

↑↓ moveenter openesc close