Skip to content

Commit 0b3e330

Browse files
committed
minor #1420 Update the design of the source code modal (javiereguiluz)
This PR was squashed before being merged into the main branch. Discussion ---------- Update the design of the source code modal The modal window that displays the source code of controller/template is nice. But the current design is troublesome. It displays the controller code on top of the template code. It doesn't look good many times because controller/templates are too long: ![source-code-modal-before](https://user-images.githubusercontent.com/73419/236446446-8981f360-ee43-4230-ad99-13cc068a623b.png) This PR proposes to use tabs to display controller and template side-by-side: ![source-code-modal-after](https://user-images.githubusercontent.com/73419/236446491-313ab2e9-0fed-4632-9419-afe87959f80f.png) Commits ------- 37d7a1c Update the design of the source code modal
2 parents 4768343 + 37d7a1c commit 0b3e330

13 files changed

+77
-43
lines changed

assets/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import './styles/app.scss';
44
import 'bootstrap/js/dist/alert';
55
import 'bootstrap/js/dist/collapse';
66
import 'bootstrap/js/dist/dropdown';
7+
import 'bootstrap/js/dist/tab';
78
import 'bootstrap/js/dist/modal';
89
import 'jquery'
910

assets/styles/app.scss

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@import "~bootstrap/scss/button-group";
1919
@import "~bootstrap/scss/input-group";
2020
// @import "~bootstrap/scss/custom-forms";
21-
// @import "~bootstrap/scss/nav";
21+
@import "~bootstrap/scss/nav";
2222
@import "~bootstrap/scss/navbar";
2323
// @import "~bootstrap/scss/card";
2424
@import "~bootstrap/scss/breadcrumb";
@@ -289,25 +289,38 @@ footer #footer-resources i {
289289
margin-left: 0.5em
290290
}
291291

292-
#sourceCodeModal h3 {
293-
font-size: $font-default;
294-
margin-top: 0
295-
}
292+
#sourceCodeModal {
293+
.modal-header {
294+
border-bottom: 0;
295+
padding: 1rem 1rem 0;
296296

297-
#sourceCodeModal h3 small {
298-
color: $gray-700;
299-
font-size: 80%
300-
}
297+
h3 { font-size: 18px; margin-top: 0; }
298+
}
301299

302-
#sourceCodeModal pre {
303-
margin-bottom: 2em;
304-
padding: 0;
305-
display: block;
306-
word-break: break-all;
307-
word-wrap: break-word;
300+
.nav-tabs {
301+
border-bottom-color: #95a5a6;
302+
margin-bottom: 15px;
303+
304+
.nav-link { font-size: 16px; }
305+
.nav-link.active { border-color: #95a5a6 #95a5a6 #fff; }
306+
.nav-link:not(.active):hover { border-color: transparent; text-decoration: underline; }
307+
}
308+
309+
.tab-content {
310+
.file-link { font-size: 16px; margin: 0 0 10px 5px; }
311+
}
312+
313+
pre {
314+
margin-bottom: 0;
315+
padding: 0;
316+
display: block;
317+
word-break: break-all;
318+
word-wrap: break-word;
308319

309-
code {
310-
white-space: pre-wrap;
320+
code {
321+
border-radius: 6px;
322+
white-space: pre-wrap;
323+
}
311324
}
312325
}
313326

public/build/42.5aced7b3.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

public/build/928.0e3059b2.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/42.5aced7b3.js.LICENSE.txt renamed to public/build/928.0e3059b2.js.LICENSE.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
2323
*/
2424

25+
/*!
26+
* Bootstrap tab.js v4.6.2 (https://getbootstrap.com/)
27+
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
28+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
29+
*/
30+
2531
/*!
2632
* Bootstrap util.js v4.6.2 (https://getbootstrap.com/)
2733
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
File renamed without changes.

public/build/app.09886d85.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/app.3a149582.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/app.8d5ecae9.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/build/app.e7ad18f4.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/build/entrypoints.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"js": [
55
"/build/runtime.5feae901.js",
66
"/build/41.64983f8e.js",
7-
"/build/42.5aced7b3.js",
8-
"/build/app.8d5ecae9.js"
7+
"/build/928.0e3059b2.js",
8+
"/build/app.09886d85.js"
99
],
1010
"css": [
11-
"/build/42.76194c5a.css",
12-
"/build/app.e7ad18f4.css"
11+
"/build/928.76194c5a.css",
12+
"/build/app.3a149582.css"
1313
]
1414
},
1515
"admin": {
@@ -27,10 +27,10 @@
2727
"integrity": {
2828
"/build/runtime.5feae901.js": "sha384-Dj9HEwBUNZIrIUOJJ4vOrf8e+X7fhJTYGYb0F/RJLrIo5qMTyh/mBApfQI4FmH8F",
2929
"/build/41.64983f8e.js": "sha384-XfOM8D6kvkEmauUMaczMxByKTBpbb9/aDqt1hPMgWDJh1X2ZQu5rIyRn3Ipx+rmn",
30-
"/build/42.5aced7b3.js": "sha384-wqPte8ueaLTZwKszn5yK/iS5GuSBYNuwZtNs5G6BWGzGI17VoFv2lXNHwQbeTCWh",
31-
"/build/app.8d5ecae9.js": "sha384-2UhLzumRcZ9rIylCmaGHxKCG1IFSEarrvMs4G6qEzE0Hl0lnrNc+e9jB8gZijjaf",
32-
"/build/42.76194c5a.css": "sha384-PoA8WLGz/za3OOW7qjoDiv5f8mBVtREO35Z70PFH8PVIdu1+nWVUEetA6Q1o6DhV",
33-
"/build/app.e7ad18f4.css": "sha384-AX8sd4a5GkOjaVooLq9t+zDI/fqugWjeU5OP+fHkycws0R/G5zaM8UZ4qx32gTNi",
30+
"/build/928.0e3059b2.js": "sha384-KjnlXhwQ0i93knq1SMzG1q6DBwLVJszQEwEQQhCSkiWbtamCjJIwvE/EQf+Sj7tL",
31+
"/build/app.09886d85.js": "sha384-4l0f6J9YNcH3yqxVehcZCX4fNgWG3y3lvsGqK0kxdMJvcFUZwtauRSDYlL4PBLCJ",
32+
"/build/928.76194c5a.css": "sha384-PoA8WLGz/za3OOW7qjoDiv5f8mBVtREO35Z70PFH8PVIdu1+nWVUEetA6Q1o6DhV",
33+
"/build/app.3a149582.css": "sha384-nfrD0DNMpZazGQQAucFPYcE1VsR4Gg5Wut28sAVfEpTl6T5xVyF5D0qoc7GtumrW",
3434
"/build/384.af623ff4.js": "sha384-DTkf7hVvZ08YUepoH5wzP+thJm6maRzLe8KxUgIc2OajdJkoSDct0pJMEPYcEEeF",
3535
"/build/admin.747eb0c9.js": "sha384-vDe3FhM5HnWbM4nEdbmSv8AB5n/PfPJv0y0Goloka7w6jppc6di5LpKD1A252aFg",
3636
"/build/admin.2b1a6c83.css": "sha384-ikQwASTRPK0sjWtW//EXsUjqkjNxc2Yndtt0m5a/I/qE+qEoikXP5ailZKDaqtN9"

public/build/manifest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"build/app.css": "/build/app.e7ad18f4.css",
3-
"build/app.js": "/build/app.8d5ecae9.js",
2+
"build/app.css": "/build/app.3a149582.css",
3+
"build/app.js": "/build/app.09886d85.js",
44
"build/admin.css": "/build/admin.2b1a6c83.css",
55
"build/admin.js": "/build/admin.747eb0c9.js",
66
"build/runtime.js": "/build/runtime.5feae901.js",
77
"build/206.b003fa5f.js": "/build/206.b003fa5f.js",
88
"build/41.64983f8e.js": "/build/41.64983f8e.js",
9-
"build/42.76194c5a.css": "/build/42.76194c5a.css",
10-
"build/42.5aced7b3.js": "/build/42.5aced7b3.js",
9+
"build/928.76194c5a.css": "/build/928.76194c5a.css",
10+
"build/928.0e3059b2.js": "/build/928.0e3059b2.js",
1111
"build/630.ed629036.js": "/build/630.ed629036.js",
1212
"build/384.af623ff4.js": "/build/384.af623ff4.js",
1313
"build/images/fa-solid-900.svg": "/build/images/fa-solid-900.7a8b4f13.svg",

templates/debug/source_code.html.twig

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,37 @@
1111
<div class="modal-dialog modal-xl">
1212
<div class="modal-content">
1313
<div class="modal-header">
14-
<h4 class="modal-title"><i class="fa fa-code" aria-hidden="true"></i> {{ 'title.source_code'|trans }}</h4>
14+
<h5 class="modal-title"><i class="fa fa-code" aria-hidden="true"></i> {{ 'title.source_code'|trans }}</h5>
1515
<button type="button" class="close" data-dismiss="modal" aria-label="{{ 'action.close'|trans }}">
1616
<span aria-hidden="true">&times;</span>
1717
</button>
1818
</div>
1919

2020
<div class="modal-body">
21-
{% if controller %}
22-
<h3><a href="https://symfony.com/doc/current/controller.html" target="_blank">{{ 'title.controller_code'|trans }}</a><small class="float-right">{{ controller.file_path|format_file(controller.starting_line) }}</small></h3>
23-
<pre><code class="php">{{ controller.source_code }}</code></pre>
24-
{% else %}
25-
<h3><a href="https://symfony.com/doc/current/controller.html">{{ 'title.controller_code'|trans }}</a></h3>
26-
<pre><code>{{ 'not_available'|trans }}</code></pre>
27-
{% endif %}
21+
<ul class="nav nav-tabs" id="myTab" role="tablist">
22+
<li class="nav-item">
23+
<a class="nav-link active" id="controller-tab" data-toggle="tab" href="#controller-code" role="tab" aria-controls="home" aria-selected="true" target="_blank">{{ 'title.controller_code'|trans }}</a>
24+
</li>
25+
<li class="nav-item">
26+
<a class="nav-link" id="template-tab" data-toggle="tab" href="#template-code" role="tab" aria-controls="profile" aria-selected="false" target="_blank">{{ 'title.twig_template_code'|trans }}</a>
27+
</li>
28+
</ul>
2829

29-
<h3><a href="https://symfony.com/doc/current/templates.html" target="_blank">{{ 'title.twig_template_code'|trans }}</a><small class="float-right">{{ template.file_path|format_file(template.starting_line) }}</small></h3>
30-
<pre><code class="twig">{{ template.source_code }}</code></pre>
30+
<div class="tab-content" id="myTabContent">
31+
<div class="tab-pane show active" id="controller-code" role="tabpanel" aria-labelledby="controller-tab">
32+
{% if controller %}
33+
<p class="file-link">{{ controller.file_path|format_file(controller.starting_line) }}</p>
34+
<pre><code class="php">{{ controller.source_code }}</code></pre>
35+
{% else %}
36+
<pre><code>{{ 'not_available'|trans }}</code></pre>
37+
{% endif %}
38+
</div>
39+
40+
<div class="tab-pane" id="template-code" role="tabpanel" aria-labelledby="template-tab">
41+
<p class="file-link">{{ template.file_path|format_file(template.starting_line) }}</p>
42+
<pre><code class="twig">{{ template.source_code }}</code></pre>
43+
</div>
44+
</div>
3145
</div>
3246
</div>
3347
</div>

0 commit comments

Comments
 (0)