Skip to content

Commit

Permalink
Simplify dynamic styles
Browse files Browse the repository at this point in the history
  • Loading branch information
agatemosu committed Jul 30, 2024
1 parent 499d626 commit f765754
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
3 changes: 0 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
<link rel="icon" href="./assets/icon.svg" />
<link rel="stylesheet" href="./styles/main.css" />
<script src="./script.js" type="module"></script>

<link rel="preload" href="./assets/check.svg" as="image" />
<style id="dynamic-styles"></style>

<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@simonwep/pickr/dist/themes/monolith.min.css"
Expand Down
9 changes: 1 addition & 8 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const clearColor = "#778899";

const mainContainer = document.querySelector("main");
const imagesBar = document.querySelector("#images-bar");
const dynamicStyles = document.querySelector("#dynamic-styles");
const exportContainer = document.querySelector("#export-container");
const exportedImage = document.querySelector("#exported-image");
const blackout = document.querySelector("#blackout");
Expand Down Expand Up @@ -227,13 +226,7 @@ function addContainerDrag(container) {
}

function dynamicStyle(checkbox) {
const importText = `@import "./styles/${checkbox.id}.css";`;

if (checkbox.checked) {
dynamicStyles.innerHTML += importText;
} else {
dynamicStyles.innerHTML = dynamicStyles.innerHTML.replace(importText, "");
}
document.body.classList.toggle(checkbox.id, checkbox.checked);
}

async function exportImage() {
Expand Down
2 changes: 1 addition & 1 deletion styles/square-img.css → styles/dynamic-styles.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.tier-element {
body.square-img .tier-element {
background-position: center;
background-size: cover;
width: 80px;
Expand Down
1 change: 1 addition & 0 deletions styles/main.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "./blackout.css";
@import "./buttons.css";
@import "./dynamic-styles.css";
@import "./export.css";
@import "./pickr.css";
@import "./tier-label.css";
Expand Down

0 comments on commit f765754

Please sign in to comment.