Skip to content

Commit

Permalink
update sketch icon for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Sep 4, 2024
1 parent ca83aca commit 54f54dc
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 5 deletions.
Binary file added src/assets/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions src/assets/icons/sketch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
--blue-400: #6b8afb;
--blue-500: #4a6ff3;
--blue-600: #234cda;
--blue-600-filter: brightness(0) saturate(100%) invert(21%) sepia(100%) saturate(3335%)
hue-rotate(227deg) brightness(88%) contrast(94%);
--alert-100: #ffcfd8;
--alert-200: #ff8096;
--alert-300: #f35471;
Expand Down
20 changes: 19 additions & 1 deletion src/css/responsive.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,26 @@
display: none;
}
#sketch {
display: none;
}
#sketch-mobile {
display: flex !important;
flex-direction: column;
gap: 2px;
align-items: center;
padding: 0.4rem;
border-radius: 4px;
}
#sketch-mobile-icon {
margin-top: 2px;
}
.sketch-mobile-activated {
background: var(--blue-050);
#sketch-mobile-icon {
filter: var(--blue-600-filter);
}
}
#download-cli {
display: none;
}
#zoom-container {
display: none;
Expand Down
6 changes: 5 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
>
<a
class="nav-menu-item"
id="download-cli"
target="_blank"
href="https://github.com/terrastruct/d2#install"
>
Expand Down Expand Up @@ -215,6 +216,9 @@
</label>
</div>
</div>
<div id="sketch-mobile" style="display: none">
<img id="sketch-mobile-icon" src="assets/icons/sketch.svg" class="btn-icon" />
</div>
</div>
<div id="render-toolbar-right" class="workstation-toolbar-right">
<div id="export" class="btn-menu-container">
Expand Down Expand Up @@ -330,7 +334,7 @@
</a>
</div>
<div class="footer-vertical-divider">|</div>
<div class="footer-bottom-content">&copy; 2023 Terrastruct, Inc.</div>
<div class="footer-bottom-content">&copy; 2024 Terrastruct, Inc.</div>
</div>
</div>
<script src="js/vendor/panzoom.js"></script>
Expand Down
20 changes: 17 additions & 3 deletions src/js/modules/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import QueryParams from "../lib/queryparams";

function init() {
readQueryParam();
document.getElementById("sketch-checkbox").addEventListener("change", toggleSketch);
document.getElementById("sketch-checkbox").addEventListener("change", (e) => toggleSketch(e.target.checked));
document.getElementById("sketch-mobile-icon").addEventListener("click", () => toggleSketch(QueryParams.get("sketch") === "0"));
updateMobileIcon(QueryParams.get("sketch") === "1");
}

function readQueryParam() {
Expand All @@ -24,9 +26,9 @@ function readQueryParam() {
}
}

function toggleSketch(e) {
function toggleSketch(on) {
const icon = document.getElementById("sketch-toggle-icon");
if (e.target.checked) {
if (on) {
icon.src = "assets/icons/toggle_check.svg";
QueryParams.set("sketch", "1");
} else {
Expand All @@ -36,6 +38,18 @@ function toggleSketch(e) {
if (Editor.getDiagramSVG()) {
Editor.compile();
}

updateMobileIcon(on);
}

function updateMobileIcon(on) {
const icon = document.getElementById("sketch-mobile");

if (on) {
icon.classList.add("sketch-mobile-activated");
} else {
icon.classList.remove("sketch-mobile-activated");
}
}

function getValue() {
Expand Down

0 comments on commit 54f54dc

Please sign in to comment.