Skip to content

Commit 4a2f3b4

Browse files
committed
Add fullscreen mode for view projects
1 parent 2f43544 commit 4a2f3b4

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

templates/repo/projects/view.tmpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content repository projects view-project">
33
{{template "repo/header" .}}
4-
<div class="ui container padded">
4+
<div class="ui container padded projects-view-top">
55
<div class="flex-text-block tw-justify-end tw-mb-4">
6+
<a class="ui small button toggle-fullscreen">Fullscreen</a>
67
<a class="ui small button" href="{{.RepoLink}}/labels">{{ctx.Locale.Tr "repo.labels"}}</a>
78
<a class="ui small button" href="{{.RepoLink}}/milestones">{{ctx.Locale.Tr "repo.milestones"}}</a>
89
<a class="ui small primary button" href="{{.RepoLink}}/issues/new/choose?project={{.Project.ID}}">{{ctx.Locale.Tr "repo.issues.new"}}</a>
910
</div>
1011
</div>
11-
<div class="ui container fluid padded">
12+
<div class="ui container fluid padded projects-view-bottom">
1213
{{template "projects/view" .}}
1314
</div>
1415
</div>

web_src/css/features/projects.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,26 @@
9898
.card-ghost * {
9999
opacity: 0;
100100
}
101+
102+
.is-fullscreen.projects-view-top,
103+
.is-fullscreen.projects-view-bottom .ui.container {
104+
position: fixed;
105+
z-index: 1000;
106+
top: 0;
107+
left: 0;
108+
right: 0;
109+
margin: 0 !important;
110+
width: 100%;
111+
max-width: 100%;
112+
background-color: var(--color-body);
113+
}
114+
115+
.is-fullscreen.projects-view-bottom .ui.container {
116+
top: 36px;
117+
}
118+
119+
.is-fullscreen #project-board {
120+
position: absolute;
121+
top: 120px;
122+
left: 0;
123+
}

web_src/js/features/repo-projects.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {contrastColor} from '../utils/color.ts';
2+
import {toggleClass, toggleElem} from '../utils/dom.ts';
23
import {createSortable} from '../modules/sortable.ts';
34
import {POST, request} from '../modules/fetch.ts';
45
import {fomanticQuery} from '../modules/fomantic/base.ts';
@@ -139,7 +140,41 @@ function initRepoProjectColumnEdit(writableProjectBoard: Element): void {
139140
});
140141
}
141142

143+
function initRepoProjectToggleFullScreen(): void {
144+
const el = document.querySelector('.toggle-fullscreen');
145+
el.addEventListener('click', () => {
146+
const isFullScreen = el.getAttribute('data-fullscreen') === 'true';
147+
148+
// hide other elements
149+
const headerEl = document.querySelector('#navbar');
150+
const contentEl = document.querySelector('.page-content');
151+
const footerEl = document.querySelector('.page-footer');
152+
toggleElem(headerEl, isFullScreen);
153+
toggleElem(contentEl, isFullScreen);
154+
toggleElem(footerEl, isFullScreen);
155+
156+
el.innerHTML = isFullScreen ? 'Fullscreen' : 'Exit';
157+
el.setAttribute('data-fullscreen', String(!isFullScreen));
158+
toggleClass(el, 'is-fullscreen');
159+
160+
const fullScreenEl1 = document.querySelector('.projects-view-top');
161+
const fullScreenEl2 = document.querySelector('.projects-view-bottom');
162+
const outerEl = document.querySelector('.full.height');
163+
toggleClass(fullScreenEl1, 'is-fullscreen');
164+
toggleClass(fullScreenEl2, 'is-fullscreen');
165+
if (isFullScreen) {
166+
contentEl.append(fullScreenEl1);
167+
contentEl.append(fullScreenEl2);
168+
} else {
169+
outerEl.append(fullScreenEl1);
170+
outerEl.append(fullScreenEl2);
171+
}
172+
});
173+
}
174+
142175
export function initRepoProject(): void {
176+
initRepoProjectToggleFullScreen();
177+
143178
const writableProjectBoard = document.querySelector('#project-board[data-project-borad-writable="true"]');
144179
if (!writableProjectBoard) return;
145180

0 commit comments

Comments
 (0)