Open bsherin opened 1 month ago
I created a code resource that makes it possible to keep them local.
def insert_styles(the_styles):
script = f"""
<div id="my-output"></div>
<script id='myScript'>
function getEnclosingDivId() {{
var scriptTag = document.getElementById('myScript');
var enclosingDiv = scriptTag.closest('.main-root');
var divId = enclosingDiv ? enclosingDiv.id : null;
return divId
}}
var divId = getEnclosingDivId();
var div = document.getElementById('my-output');
div.innerHTML = `
<style>
#${{divId}} {{
{the_styles}
}}
</style>`
</script>
"""
print(script)
create some good way of applying styles to notebooks or at least keeping them local