Previews

No matching results.

x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<div data-controller="tree-view-menu" data-tree-view-menu-animate-value="true" class="elevate-tree-view-menu--container">
<div class="space-y-1">
<div class="elevate-tree-view-menu--container--directory" data-simple-sidebar-filter-target="directory">
<button data-action="click->tree-view-menu#toggle" aria-controls="tree-content-dashboard" aria-expanded="true" data-state="open" type="button" class="elevate-button elevate-button--size-s elevate-button--align-start elevate-tree-view-menu--button-folder">
<svg data-tree-view-menu-target="icon" class="folder-open" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M5,14.75h-.75c-1.105,0-2-.895-2-2V4.75c0-1.105,.895-2,2-2h1.825c.587,0,1.144,.258,1.524,.705l1.524,1.795h4.626c1.105,0,2,.895,2,2v1"></path>
<path d="M16.148,13.27l.843-3.13c.257-.953-.461-1.89-1.448-1.89H6.15c-.678,0-1.272,.455-1.448,1.11l-.942,3.5c-.257,.953,.461,1.89,1.448,1.89H14.217c.904,0,1.696-.607,1.931-1.48Z"></path>
</g>
</svg>
Dashboard
</button>
<div id="tree-content-dashboard" data-state="open" role="region" data-tree-view-menu-target="content" class="elevate-tree-view-menu--sublist">
<a data-simple-sidebar-filter-target="file" href="#" class="elevate-tree-view-menu--link-file elevate-tree-view-menu--link-file--active"><span class="elevate-tree-view-menu--link-file--icon elevate-icon elevate-icon--size--s">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewbox="0 0 18 18" focusable="false" aria-hidden="true">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M15.16,6.25h-3.41c-.552,0-1-.448-1-1V1.852"></path>
<path d="M2.75,14.25V3.75c0-1.105,.895-2,2-2h5.586c.265,0,.52,.105,.707,.293l3.914,3.914c.188,.188,.293,.442,.293,.707v7.586c0,1.105-.895,2-2,2H4.75c-1.105,0-2-.895-2-2Z"></path>
</g>
</svg>
</span>
Overview</a>
<a data-simple-sidebar-filter-target="file" href="#" class="elevate-tree-view-menu--link-file"><span class="elevate-tree-view-menu--link-file--icon elevate-icon elevate-icon--size--s">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewbox="0 0 18 18" focusable="false" aria-hidden="true">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M15.16,6.25h-3.41c-.552,0-1-.448-1-1V1.852"></path>
<path d="M2.75,14.25V3.75c0-1.105,.895-2,2-2h5.586c.265,0,.52,.105,.707,.293l3.914,3.914c.188,.188,.293,.442,.293,.707v7.586c0,1.105-.895,2-2,2H4.75c-1.105,0-2-.895-2-2Z"></path>
</g>
</svg>
</span>
Statistics</a>
<a data-simple-sidebar-filter-target="file" href="#" class="elevate-tree-view-menu--link-file"><span class="elevate-tree-view-menu--link-file--icon elevate-icon elevate-icon--size--s">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewbox="0 0 18 18" focusable="false" aria-hidden="true">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M15.16,6.25h-3.41c-.552,0-1-.448-1-1V1.852"></path>
<path d="M2.75,14.25V3.75c0-1.105,.895-2,2-2h5.586c.265,0,.52,.105,.707,.293l3.914,3.914c.188,.188,.293,.442,.293,.707v7.586c0,1.105-.895,2-2,2H4.75c-1.105,0-2-.895-2-2Z"></path>
</g>
</svg>
</span>
Activity Log</a>
</div>
</div>
<div class="elevate-tree-view-menu--container--directory" data-simple-sidebar-filter-target="directory">
<button data-action="click->tree-view-menu#toggle" aria-controls="tree-content-content" aria-expanded="true" data-state="open" type="button" class="elevate-button elevate-button--size-s elevate-button--align-start elevate-tree-view-menu--button-folder">
<svg data-tree-view-menu-target="icon" class="folder-open" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M5,14.75h-.75c-1.105,0-2-.895-2-2V4.75c0-1.105,.895-2,2-2h1.825c.587,0,1.144,.258,1.524,.705l1.524,1.795h4.626c1.105,0,2,.895,2,2v1"></path>
<path d="M16.148,13.27l.843-3.13c.257-.953-.461-1.89-1.448-1.89H6.15c-.678,0-1.272,.455-1.448,1.11l-.942,3.5c-.257,.953,.461,1.89,1.448,1.89H14.217c.904,0,1.696-.607,1.931-1.48Z"></path>
</g>
</svg>
Content
</button>
<div id="tree-content-content" data-state="open" role="region" data-tree-view-menu-target="content" class="elevate-tree-view-menu--sublist">
<a data-simple-sidebar-filter-target="file" href="#" class="elevate-tree-view-menu--link-file"><span class="elevate-tree-view-menu--link-file--icon elevate-icon elevate-icon--size--s">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewbox="0 0 18 18" focusable="false" aria-hidden="true">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M15.16,6.25h-3.41c-.552,0-1-.448-1-1V1.852"></path>
<path d="M2.75,14.25V3.75c0-1.105,.895-2,2-2h5.586c.265,0,.52,.105,.707,.293l3.914,3.914c.188,.188,.293,.442,.293,.707v7.586c0,1.105-.895,2-2,2H4.75c-1.105,0-2-.895-2-2Z"></path>
</g>
</svg>
</span>
Articles</a>
<a data-simple-sidebar-filter-target="file" href="#" class="elevate-tree-view-menu--link-file"><span class="elevate-tree-view-menu--link-file--icon elevate-icon elevate-icon--size--s">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewbox="0 0 18 18" focusable="false" aria-hidden="true">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M15.16,6.25h-3.41c-.552,0-1-.448-1-1V1.852"></path>
<path d="M2.75,14.25V3.75c0-1.105,.895-2,2-2h5.586c.265,0,.52,.105,.707,.293l3.914,3.914c.188,.188,.293,.442,.293,.707v7.586c0,1.105-.895,2-2,2H4.75c-1.105,0-2-.895-2-2Z"></path>
</g>
</svg>
</span>
Media Library</a>
<a data-simple-sidebar-filter-target="file" href="#" class="elevate-tree-view-menu--link-file"><span class="elevate-tree-view-menu--link-file--icon elevate-icon elevate-icon--size--s">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewbox="0 0 18 18" focusable="false" aria-hidden="true">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M15.16,6.25h-3.41c-.552,0-1-.448-1-1V1.852"></path>
<path d="M2.75,14.25V3.75c0-1.105,.895-2,2-2h5.586c.265,0,.52,.105,.707,.293l3.914,3.914c.188,.188,.293,.442,.293,.707v7.586c0,1.105-.895,2-2,2H4.75c-1.105,0-2-.895-2-2Z"></path>
</g>
</svg>
</span>
Tags & Categories</a>
</div>
</div>
<div class="elevate-tree-view-menu--container--directory" data-simple-sidebar-filter-target="directory">
<button data-action="click->tree-view-menu#toggle" aria-controls="tree-content-settings" aria-expanded="true" data-state="open" type="button" class="elevate-button elevate-button--size-s elevate-button--align-start elevate-tree-view-menu--button-folder">
<svg data-tree-view-menu-target="icon" class="folder-open" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M5,14.75h-.75c-1.105,0-2-.895-2-2V4.75c0-1.105,.895-2,2-2h1.825c.587,0,1.144,.258,1.524,.705l1.524,1.795h4.626c1.105,0,2,.895,2,2v1"></path>
<path d="M16.148,13.27l.843-3.13c.257-.953-.461-1.89-1.448-1.89H6.15c-.678,0-1.272,.455-1.448,1.11l-.942,3.5c-.257,.953,.461,1.89,1.448,1.89H14.217c.904,0,1.696-.607,1.931-1.48Z"></path>
</g>
</svg>
Settings
</button>
<div id="tree-content-settings" data-state="open" role="region" data-tree-view-menu-target="content" class="elevate-tree-view-menu--sublist">
<a data-simple-sidebar-filter-target="file" href="#" class="elevate-tree-view-menu--link-file"><span class="elevate-tree-view-menu--link-file--icon elevate-icon elevate-icon--size--s">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewbox="0 0 18 18" focusable="false" aria-hidden="true">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M15.16,6.25h-3.41c-.552,0-1-.448-1-1V1.852"></path>
<path d="M2.75,14.25V3.75c0-1.105,.895-2,2-2h5.586c.265,0,.52,.105,.707,.293l3.914,3.914c.188,.188,.293,.442,.293,.707v7.586c0,1.105-.895,2-2,2H4.75c-1.105,0-2-.895-2-2Z"></path>
</g>
</svg>
</span>
Profile Settings</a>
<a data-simple-sidebar-filter-target="file" href="#" class="elevate-tree-view-menu--link-file"><span class="elevate-tree-view-menu--link-file--icon elevate-icon elevate-icon--size--s">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewbox="0 0 18 18" focusable="false" aria-hidden="true">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M15.16,6.25h-3.41c-.552,0-1-.448-1-1V1.852"></path>
<path d="M2.75,14.25V3.75c0-1.105,.895-2,2-2h5.586c.265,0,.52,.105,.707,.293l3.914,3.914c.188,.188,.293,.442,.293,.707v7.586c0,1.105-.895,2-2,2H4.75c-1.105,0-2-.895-2-2Z"></path>
</g>
</svg>
</span>
Notifications</a>
<a data-simple-sidebar-filter-target="file" href="#" class="elevate-tree-view-menu--link-file"><span class="elevate-tree-view-menu--link-file--icon elevate-icon elevate-icon--size--s">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewbox="0 0 18 18" focusable="false" aria-hidden="true">
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M15.16,6.25h-3.41c-.552,0-1-.448-1-1V1.852"></path>
<path d="M2.75,14.25V3.75c0-1.105,.895-2,2-2h5.586c.265,0,.52,.105,.707,.293l3.914,3.914c.188,.188,.293,.442,.293,.707v7.586c0,1.105-.895,2-2,2H4.75c-1.105,0-2-.895-2-2Z"></path>
</g>
</svg>
</span>
API Access</a>
</div>
</div>
</div>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
entries = {
"Dashboard" => [
{ active: true, href: "#", text: "Overview" },
{ active: false, href: "#", text: "Statistics" },
{ active: false, href: "#", text: "Activity Log" }
],
"Content" => [
{ active: false, href: "#", text: "Articles" },
{ active: false, href: "#", text: "Media Library" },
{ active: false, href: "#", text: "Tags & Categories" }
],
"Settings" => [
{ active: false, href: "#", text: "Profile Settings" },
{ active: false, href: "#", text: "Notifications" },
{ active: false, href: "#", text: "API Access" }
]
}
render(Elevate::TreeViewMenuComponent.new(entries: entries, animate:))
Param Description Input

app/assets/stylesheets/components/tree_view_menu.css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
@layer components {
.elevate-tree-view-menu--container {
@apply h-full w-full bg-white;
}
/* Hidden class for filtering */
.hidden {
@apply hidden;
}
.elevate-tree-view-menu--button-folder {
@apply flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-neutral-100 transition-colors duration-150 outline-hidden focus:underline;
}
.elevate-tree-view-menu--button-folder--active {
@apply bg-neutral-100;
}
.elevate-tree-view-menu--sublist {
@apply ml-4 pl-2 border-l border-neutral-200 space-y-1 overflow-hidden transition-[height];
}
.elevate-tree-view-menu--container--directory {
@apply overflow-hidden;
}
.elevate-tree-view-menu--link-file {
@apply flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-neutral-600 hover:bg-neutral-100 transition-colors duration-150 outline-hidden focus:underline;
}
.elevate-tree-view-menu--link-file--active {
@apply bg-neutral-100;
}
.elevate-tree-view-menu--link-file--icon {
@apply m-0 text-neutral-400;
}
}

app/assets/javascripts/components/tree_view_menu_controller.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static targets = ["icon", "content"];
static values = {
animate: { type: Boolean, default: true }, // Whether to animate the tree view
};
connect () {
this.isAnimating = false;
// Initialize any folders that should start open
this.element.querySelectorAll('[data-state="open"]').forEach((el) => {
const button = el.previousElementSibling;
if (button) {
const icon = button.querySelector('[data-tree-view-menu-target="icon"]');
if (icon) {
icon.classList.add("folder-open");
icon.innerHTML = this.openFolderSvg;
}
}
});
this.addKeyboardListeners();
}
disconnect () {
// Clean up any remaining event listeners
if (this.onTransitionEndBound) {
this.element.querySelectorAll('[data-tree-view-menu-target="content"]').forEach((content) => {
content.removeEventListener("transitionend", this.onTransitionEndBound);
});
}
this.element.removeEventListener("keydown", this.handleKeydownBound);
}
addKeyboardListeners () {
this.handleKeydownBound = this.handleKeydown.bind(this);
this.element.addEventListener("keydown", this.handleKeydownBound);
}
handleKeydown (event) {
const triggers = Array.from(this.element.querySelectorAll('button[data-action="click->tree-view-menu#toggle"]'));
const currentIndex = triggers.indexOf(document.activeElement);
if (currentIndex === -1) return;
switch (event.key) {
case "ArrowUp":
event.preventDefault();
let prevIndex = currentIndex;
do {
prevIndex = (prevIndex - 1 + triggers.length) % triggers.length;
} while (prevIndex !== currentIndex && this.isElementHidden(triggers[prevIndex]));
triggers[prevIndex].focus();
break;
case "ArrowDown":
event.preventDefault();
let nextIndex = currentIndex;
do {
nextIndex = (nextIndex + 1) % triggers.length;
} while (nextIndex !== currentIndex && this.isElementHidden(triggers[nextIndex]));
triggers[nextIndex].focus();
break;
case "Enter":
case " ":
event.preventDefault();
triggers[currentIndex].click();
break;
}
}
isElementHidden (element) {
let current = element;
while (current && current !== this.element) {
if (current.hasAttribute("hidden") || current.classList.contains("hidden")) {
return true;
}
current = current.parentElement;
}
return false;
}
toggle (event) {
const button = event.currentTarget;
const content = document.getElementById(button.getAttribute("aria-controls"));
const icon = button.querySelector('[data-tree-view-menu-target="icon"]');
// Prevent multiple animations from running simultaneously
if (this.isAnimating) return;
const isOpen = button.getAttribute("aria-expanded") === "true";
// Toggle aria attributes
button.setAttribute("aria-expanded", !isOpen);
content.setAttribute("data-state", isOpen ? "closed" : "open");
if (this.animateValue) {
this.isAnimating = true;
// Remove any existing transition listeners
content.removeEventListener("transitionend", this.onTransitionEndBound);
this.onTransitionEndBound = () => {
if (isOpen) {
content.setAttribute("hidden", "");
}
content.style.height = "";
content.style.transition = "";
content.removeEventListener("transitionend", this.onTransitionEndBound);
this.isAnimating = false;
};
content.addEventListener("transitionend", this.onTransitionEndBound);
if (isOpen) {
// Closing animation
const height = content.scrollHeight;
content.style.height = height + "px";
// Force a reflow
content.offsetHeight;
content.style.transition = "height 300ms ease-out";
content.style.height = "0";
} else {
// Opening animation
content.removeAttribute("hidden");
content.style.height = "0";
// Force a reflow
content.offsetHeight;
content.style.transition = "height 300ms ease-out";
const height = content.scrollHeight;
content.style.height = height + "px";
}
} else {
// No animation - just toggle visibility
if (isOpen) {
content.setAttribute("hidden", "");
} else {
content.removeAttribute("hidden");
}
}
// Update icons
if (isOpen) {
icon.classList.remove("folder-open");
icon.innerHTML = this.closedFolderSvg;
} else {
icon.classList.add("folder-open");
icon.innerHTML = this.openFolderSvg;
}
// Update button state
button.setAttribute("data-state", isOpen ? "closed" : "open");
}
get openFolderSvg () {
return `<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M5,14.75h-.75c-1.105,0-2-.895-2-2V4.75c0-1.105,.895-2,2-2h1.825c.587,0,1.144,.258,1.524,.705l1.524,1.795h4.626c1.105,0,2,.895,2,2v1"></path>
<path d="M16.148,13.27l.843-3.13c.257-.953-.461-1.89-1.448-1.89H6.15c-.678,0-1.272,.455-1.448,1.11l-.942,3.5c-.257,.953,.461,1.89,1.448,1.89H14.217c.904,0,1.696-.607,1.931-1.48Z"></path>
</g>`;
}
get closedFolderSvg () {
return `<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor">
<path d="M13.75,5.25c1.105,0,2,.895,2,2v5.5c0,1.105-.895,2-2,2H4.25c-1.105,0-2-.895-2-2V4.75c0-1.105,.895-2,2-2h1.825c.587,0,1.144,.258,1.524,.705l1.524,1.795h4.626Z"></path>
</g>`;
}
}