use crate::writers::write_to_file;
use eyre::Error;
pub fn create_grapesjs_component() -> Result<(), Error> {
let html = r#"
<div id="gjs" style="height: 100%; overflow: hidden; width: 100%;">
<div style="margin:100px 100px 25px; padding:25px; font:caption">
{% if html_content %}
{{html_content|safe}}
{% else %}
Welcome to the editor grab a block from the right and drag it here
{% endif %}
</div>
</div>
<style>
body,
html {
height: 80%;
margin: 0;
}
.gjs-block {
padding: 0 !important;
width: 100% !important;
min-height: auto !important;
}
.gjs-block svg {
width: 100%;
}
.change-theme-button {
width: 40px;
height: 40px;
border-radius: 50%;
margin: 5px;
}
.change-theme-button:focus {
/* background-color: yellow; */
outline: none;
box-shadow: 0 0 0 2pt #c5c5c575;
}
.gjs-pn-views-container {
height: auto !important;
}
</style>
"#;
let path = "src/views/components/grapesjs.html.tera";
std::fs::File::create(path)?;
std::fs::metadata(path)?;
write_to_file(path, html.as_bytes())?;
Ok(())
}
pub fn add_grapesjs_to_header() -> Result<(), Error> {
let html = r#"
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
<script src="https://unpkg.com/grapesjs"></script>
<script src="https://unpkg.com/grapesjs-preset-webpage"></script>
<script src="https://unpkg.com/grapesjs-script-editor"></script>
<script src="https://unpkg.com/@rustyroad/editor"></script>
<script src="https://unpkg.com/idb@7.1.1/build/umd.js"></script>
"#;
let path = "src/views/sections/header.html.tera";
let mut contents = String::new();
contents.push_str(html);
write_to_file(path, contents.as_bytes())?;
Ok(())
}