-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
88 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
const treeview = document.querySelector('.treeview'); | ||
|
||
function toggleNode(event) { | ||
const li = event.target.closest('li'); | ||
const ul = li.querySelector('ul'); | ||
if (ul) { | ||
ul.classList.toggle('hidden'); | ||
const isOpen = !ul.classList.contains('hidden'); | ||
const icon = li.querySelector('.tree-view-icon'); | ||
const block = li.querySelector('div'); | ||
if(isOpen) { | ||
icon.style.transform = 'rotate(-90deg)'; | ||
block.classList.add('active'); | ||
} | ||
else { | ||
icon.style.transform = ''; | ||
block.classList.remove('active'); | ||
} | ||
|
||
const nodeId = li.getAttribute('data-id'); | ||
console.log(nodeId); | ||
sessionStorage.setItem(nodeId, isOpen); | ||
console.log(sessionStorage.key('concept-')); | ||
} | ||
} | ||
|
||
treeview.querySelectorAll('.toggle').forEach(toggle => { | ||
toggle.addEventListener('click', toggleNode); | ||
}); | ||
|
||
treeview.querySelectorAll('li[data-id]').forEach(li => { | ||
const nodeId = li.getAttribute('data-id'); | ||
const isOpen = sessionStorage.getItem(nodeId) === 'true'; | ||
const ul = li.querySelector('ul'); | ||
if (ul && isOpen) { | ||
ul.classList.remove('hidden'); | ||
console.log(nodeId); | ||
li.querySelector('.tree-view-icon').style.transform = 'rotate(-90deg)'; | ||
li.querySelector('div').classList.add('active'); | ||
} | ||
}); | ||
|
||
}); | ||
|
||
window.addEventListener("load", function () { | ||
const treeview = document.querySelector('.treeview'); | ||
treeview.querySelectorAll('div.open-concept').forEach(div => { | ||
div.addEventListener('dblclick', (e) => { | ||
const route = e.currentTarget.dataset.openConceptRoute; | ||
console.log('click', e.currentTarget.dataset); | ||
window.location.href = route; | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<svg data-accordion-icon class="w-3 h-3 rotate-180 shrink-0" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6"> | ||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5 5 1 1 5" /> | ||
<svg class="w-4 h-4 transition-transform delay-50 shrink-0 tree-view-icon dark:text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="currentColor" class="size-6"> | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5 8.25 12l7.5-7.5" /> | ||
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
@php | ||
$active = 'bg-blue-200 dark:bg-sky-950 hover:bg-blue-200 dark:hover:bg-sky-950 text-black dark:text-white outline-1 outline-blue-500 dark:outline-blue-500 outline'; | ||
@endphp | ||
|
||
<div id="accordion-nested-parent" data-accordion="open" class="w-full cursor-pointer" data-active-classes="{{ $active }}" data-inactive-classes="text-inherit"> | ||
<ul class="pb-12 treeview"> | ||
@foreach ($concepts as $concept) | ||
@include('components.tree-view.tree-item', ['concept' => $concept]) | ||
@include('components.tree-view.tree-item', ['concept' => $concept]) | ||
@endforeach | ||
</div> | ||
</ul> | ||
@once | ||
@vite(['resources/js/tree.js']) | ||
@endonce | ||
|
||
|
||
|
||
|