diff options
author | Minteck <contact@minteck.org> | 2022-10-18 08:59:09 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-10-18 08:59:09 +0200 |
commit | 2c4ae43e688a9873e86211ea0e7aeb9ba770dd77 (patch) | |
tree | 17848d95522dab25d3cdeb9c4a6450e2a234861f /includes/mobilenav.inc | |
parent | 108525534c28013cfe1897c30e4565f9893f3766 (diff) | |
download | pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.gz pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.bz2 pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.zip |
Update
Diffstat (limited to 'includes/mobilenav.inc')
-rw-r--r-- | includes/mobilenav.inc | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/includes/mobilenav.inc b/includes/mobilenav.inc new file mode 100644 index 0000000..ed778ec --- /dev/null +++ b/includes/mobilenav.inc @@ -0,0 +1,88 @@ +<?php global $navigation; global $isLoggedIn; ?> +<div id="mobile-navigation"> + <div id="mobile-navigation-container" class="container" style="display: grid; grid-template-columns: repeat(<?= count(array_values(array_filter($navigation, function ($item) use ($isLoggedIn) { + return !$item["admin"] || $isLoggedIn; + }))) + 1 ?>, 1fr); height: 100%;"> + <a title="Cold Haze" data-bs-toggle="tooltip" href="/" id="mobile-navigation-item--logo" class="tooltip-nohelp mobile-navigation-item"> + <img src="/assets/logo/newlogo.png" alt="" style="width:24px;vertical-align: middle;"> + </a> + <?php foreach ($navigation as $id => $item): if (!$item["admin"] || $isLoggedIn): ?> + <a onclick="toggleMobileNavigation('<?= $id ?>');" title="<?= $item["name"] ?>" data-bs-toggle="tooltip" id="mobile-navigation-item-<?= $id ?>" class="tooltip-nohelp mobile-navigation-item"> + <img src="<?= $item["icon"] ?>" <?php if ($item["invert"]): ?>class="dropdown-icon"<?php endif; ?> alt="" style="width:24px;vertical-align: middle;"> + </a> + <?php endif; endforeach; ?> + </div> +</div> + +<div id="mobile-navigation-box-container" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 48px; background-color: rgba(0, 0, 0, .75); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 99999; overflow: auto;"> + <?php foreach ($navigation as $id => $item): if (!$item["admin"] || $isLoggedIn): ?> + <div id="mobile-navigation-box-<?= $id ?>" style="display: none; margin-top: 10px; margin-bottom: 10px;" class="mobile-navigation-box container"> + <div class="pane-group-title"> + <img src="<?= $item["icon"] ?>" <?php if ($item["invert"]): ?>class="dropdown-icon"<?php endif; ?> alt="" style="width:24px;vertical-align: middle;"> + <span style="vertical-align: middle;"><?= $item["name"] ?></span> + </div> + + <?php foreach ($item["items"] as $category): ?> + <div class="pane-group-category <?= $category["minimal"] ? "pane-group-category-minimal" : "" ?>" <?= $category["minimal"] ? 'style="display: grid; grid-template-columns: repeat(' . count($category["items"]) . ', 1fr); grid-gap: 10px;"' : "" ?>> + <?php if (isset($category["name"])): ?> + <div class="pane-group-category-title"><?= $category["name"] ?></div> + <?php endif; ?> + <?php foreach ($category["items"] as $link): ?> + <a class="pane-group-item" href="<?= $link["link"] ?>"> + <img src="<?= $link["icon"] ?>" <?php if ($link["invert"]): ?>class="dropdown-icon"<?php endif; ?> alt="" style="width:24px; border-radius: 5px; vertical-align: middle;"> + <?php if (!$category["minimal"]): ?><span style="vertical-align: middle;<?= isset($link["stepped"]) ? "color: $link[stepped];" : "" ?>"><?= isset($link["stepped"]) ? "<b>$link[name]</b>" : $link["name"] ?></span><?php endif; ?> + </a> + <?php endforeach; ?> + </div> + <?php endforeach; ?> + </div> + <?php endif; endforeach; ?> +</div> + +<style> + .mobile-navigation-item { + display: flex; + cursor: pointer; + align-items: center; + justify-content: center; + } + + .mobile-navigation-item:hover { + background: rgba(255, 255, 255, .1); + } + + .mobile-navigation-item:active, .mobile-navigation-item:focus, .mobile-navigation-item.open { + background: rgba(255, 255, 255, .25); + } +</style> + +<script> + function closeMobileNavigation() { + document.getElementById("mobile-navigation-box-container").style.display = "none"; + document.body.style.overflow = ""; + + Array.from(document.getElementsByClassName("mobile-navigation-item")).forEach((i) => { + i.classList.remove("open"); + }); + + Array.from(document.getElementsByClassName("mobile-navigation-box")).forEach((i) => { + i.style.display = "none"; + }); + } + + function openMobileNavigation(id) { + document.getElementById("mobile-navigation-item-" + id).classList.add("open"); + document.body.style.overflow = "hidden"; + document.getElementById("mobile-navigation-box-container").style.display = "block"; + document.getElementById("mobile-navigation-box-" + id).style.display = "block"; + } + + function toggleMobileNavigation(id) { + if (document.getElementById("mobile-navigation-box-" + id).style.display !== "block") { + closeMobileNavigation(); + openMobileNavigation(id); + } else { + closeMobileNavigation(); + } + } +</script>
\ No newline at end of file |