Skip to content

Commit 33aada5

Browse files
Merge pull request AngelaRemolina#18 from angelasofiaremolinagutierrez/output-style
Output style
2 parents 8a94bea + da2b499 commit 33aada5

33 files changed

Lines changed: 4221 additions & 426 deletions

File tree

runestone/activecode/js/activecode_brython.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,46 +29,51 @@ export default class BrythonActiveCode extends ActiveCode {
2929
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/styles/default.min.css">
3030
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/highlight.min.js"></script>
3131
<style>
32+
html, body{
33+
height: max-content; width: 100%;
34+
}
35+
.container-pre{
36+
background: white; font-size: 13px; line-height: 1.42857143; border: 1px solid #ccc; border-radius: 4px;
37+
position: fixed; bottom: 0px; width: 94%; max-height: 200px; overflow: auto; clear: both; resize: both; transform: scale(1, -1);
38+
}
3239
pre {
33-
position: absolute; font-size: 13px; width: 94%; padding: 9.5px; line-height: 1.42857143; border: 1px ; border-radius: 4px;
34-
overflow: auto; height: 200px; clear: both; position: sticky; top: 0; resize: both; background: white;
40+
position: sticky; padding: 12px; transform: scale(1, -1);
3541
}
3642
code{
3743
border: 1px solid #ccc; border-radius: 4px;
3844
}
3945
</style>
4046
</head>
41-
<body onload='brython()' >
42-
<pre id="consolePre">
43-
<code id="consoleCode"></code>
44-
</pre>
47+
<body onload='brython()'>
4548
<script type='text/python'>
4649
import sys
4750
from browser import document, html
51+
import traceback
4852
49-
logger = document['consoleCode']
50-
preElem = document['consolePre']
53+
preElem = html.PRE()
54+
logger = html.CODE()
55+
container = html.DIV()
56+
container.classList.add("container-pre")
57+
preElem <= logger
58+
container <= preElem
5159
class NewOut:
5260
def write(self, data):
5361
logger.innerHTML += str(data)
5462
5563
sys.stderr = sys.stdout = NewOut()
56-
</script>
57-
<script type="text/python3">
58-
from browser import document, html
59-
import sys
60-
import traceback
6164
6265
def my_exec(code):
6366
try:
6467
exec(code, locals())
65-
preElem = document['consolePre']
6668
preElem.style.visibility = "visible"
67-
document['consoleCode'].classList.add("plaintext")
68-
out_header = document.createElement("h3")
69+
out_header = document.createElement("text")
6970
out_header.innerHTML = "Output"
7071
out_header.style.font = "24px 'Arial'"
72+
logger.classList.add("plaintext")
73+
preElem.prepend(document.createElement("br"))
74+
preElem.prepend(document.createElement("br"))
7175
preElem.prepend(out_header)
76+
document <= container
7277
except SyntaxError as err:
7378
error_class = err.__class__.__name__
7479
detail = err.args[0]
@@ -88,23 +93,23 @@ def my_exec(code):
8893
# This is only done if an Exception was catched
8994
result = f"'{error_class}': {detail} {line_number}"
9095
print(result)
91-
logger = document['consoleCode']
92-
preElem = document['consolePre']
9396
# Styling the pre element for error
9497
error_header = document.createElement("h3")
9598
error_header.innerHTML = "Error"
9699
error_header.style.font = "24px 'Arial'"
97100
preElem.prepend(error_header)
98101
preElem.style.visibility = "visible"
99-
preElem.style.top = "5px"
100102
preElem.style.backgroundColor = "#f2dede"
101103
preElem.style.border = "1px solid #ebccd1"
102104
logger.classList.add("python")
103105
106+
document <= container
107+
104108
my_exec("""${prog}
105109
""")
106110
107111
document <= html.SCRIPT("hljs.highlightAll();")
112+
document <= html.SCRIPT("let container = document.querySelector('.container-pre'); let height = container.offsetHeight; document.body.style.paddingBottom = String(height)+'px';")
108113
</script>
109114
</body>
110115
</html>

runestone/dist/node_modules_moment_locale_sync_recursive_-runestone_activecode_js_acfactory_js.bundle.js

Lines changed: 45 additions & 30 deletions
Large diffs are not rendered by default.

runestone/dist/runestone.bundle.js

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

runestone/dist/runestone_clickableArea_js_timedclickable_js.bundle.js

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

runestone/dist/runestone_codelens_js_codelens_js.bundle.js

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

runestone/dist/runestone_codelens_js_pytutor-embed_bundle_js.bundle.js

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

runestone/dist/runestone_common_js_runestonebase_js.bundle.js

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

runestone/dist/runestone_datafile_js_datafile_js.bundle.js

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

runestone/dist/runestone_dragndrop_js_timeddnd_js.bundle.js

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

runestone/dist/runestone_fitb_js_timedfitb_js.bundle.js

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

0 commit comments

Comments
 (0)