Skip to content

Commit 9284012

Browse files
committed
Disable side-by-side below md breakpoint
Monaco already disabled this on an undefined breakpoint. Align it with bootstraps breakpoint and also hide the UI element to select the mode.
1 parent bc093b1 commit 9284012

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

webapp/public/js/domjudge.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,14 @@ function initDiffEditorTab(editorId, diffId, submissionId, models) {
14591459
const navItem = document.getElementById(`${diffId}-link`);
14601460
const isDeleted = !(submissionId in models);
14611461

1462+
// Set breakpoint to bootstrap's md, subtract the 2*1.5rem page padding, 4px borders,
1463+
// and 1px for difference in inclusion/exclusion of the breakpoint in monaco vs bootstrap.
1464+
const computedStyle = getComputedStyle(document.body)
1465+
const breakpointMd = parseInt(computedStyle.getPropertyValue('--bs-breakpoint-md'));
1466+
const rootPadding = parseInt(computedStyle.fontSize) * 3;
1467+
const borders = 4;
1468+
const breakpoint = breakpointMd - rootPadding + borders - 1;
1469+
14621470
const diffEditor = monaco.editor.createDiffEditor(
14631471
document.getElementById(diffId), {
14641472
scrollbar: {
@@ -1470,6 +1478,8 @@ function initDiffEditorTab(editorId, diffId, submissionId, models) {
14701478
automaticLayout: true,
14711479
readOnly: true,
14721480
theme: getCurrentEditorTheme(),
1481+
renderSideBySideInlineBreakpoint: breakpoint,
1482+
useInlineViewWhenSpaceIsLimited: true,
14731483
});
14741484

14751485
const updateMode = (diffMode) => {

webapp/templates/jury/partials/submission_diff.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
{%- endfor %}
3636
</select>
3737
</div>
38-
<div class="diff-mode btn-group">
38+
<div class="diff-mode btn-group d-none d-md-inline-flex">
3939
<a href="#" role="button" class="btn btn-secondary btn-sm pe-none" aria-disabled="true"><i class="fas fa-plus-minus"></i></a>
4040
{%- for mode_id, mode in diff_modes %}
4141
<input type="radio" class="btn-check" name="{{ editor_id }}-mode" id="{{ editor_id }}-{{ mode_id }}" value="{{ mode_id }}" autocomplete="off">

0 commit comments

Comments
 (0)