MCPcopy Index your code
hub / github.com/tinyplex/tinybase / updateNav

Function updateNav

site/js/common/common.ts:164–216  ·  view source on GitHub ↗
(
  {
    i: id,
    n: name,
    u: url,
    r: reflection,
    c: current,
    p: parent,
    o: open,
    _: children,
  }: NavNode,
  ul: HTMLElement,
)

Source from the content-addressed store, hash-verified

162};
163
164const updateNav = (
165 {
166 i: id,
167 n: name,
168 u: url,
169 r: reflection,
170 c: current,
171 p: parent,
172 o: open,
173 _: children,
174 }: NavNode,
175 ul: HTMLElement,
176): void => {
177 const nav = getNav();
178 let li = queryById(id);
179 if (li == null) {
180 li = createElement('li', ul, {id});
181 createElement('span', li);
182 const a = createElement('a', li, {href: url});
183 if (reflection) {
184 createElement('code', a, {}, name);
185 } else {
186 a.innerText = name;
187 }
188 if (parent) {
189 addClass(li, 'parent');
190 }
191 }
192 if (open) {
193 addClass(li, 'open');
194 }
195 if (children != null) {
196 const childUl: HTMLElement =
197 queryElement(li, 'ul') ?? createElement('ul', li);
198 children.forEach((child) => {
199 updateNav(child, childUl);
200 });
201 }
202 if (current) {
203 addClass(li, 'current');
204 doc.title = `${name} | ${SITE}`;
205 const liRect = li.getBoundingClientRect();
206 const navRect = nav.getBoundingClientRect();
207 if (liRect.top < navRect.top) {
208 nav.scrollBy(0, liRect.top - navRect.top);
209 } else if (liRect.bottom > navRect.bottom) {
210 nav.scrollBy(
211 0,
212 Math.min(liRect.bottom - navRect.bottom, liRect.top - navRect.top),
213 );
214 }
215 }
216};

Callers 1

goFunction · 0.85

Calls 5

queryByIdFunction · 0.85
createElementFunction · 0.85
addClassFunction · 0.85
queryElementFunction · 0.85
getNavFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…