Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/okikio/native. An initiative which aims to make it easy to create complex, light-weight, and perfor okikio.github.io/native
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201---// import SidebarSection from "./SidebarSection.astro";import Logo from "./Logo.astro";import glob from "fast-glob";const paths = await glob('docs/**/*.md');
function isObject(obj) { return typeof obj === 'object' && obj !== null && obj !== undefined}
// Capitalize first letter of each wordlet capitalize = (str) => { return str .replace(/-/g, " ") .replace(/\w\S*/g, (txt) => (txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()) ) .replace(/api/gi, "API") .replace(/css/gi, "CSS");};
const obj = {}; function deepGet(obj, path) { var length = path.length; for (var i = 0; i < length; i++) { if (obj == null) return void 0; obj = obj[path[i]]; } return length ? obj : void 0;}function deepSet(obj, path, value) { var length = path.length; for (var i = 0; i < length; i++) { if (!isObject(obj[path[i]])) { obj[path[i]] = {}; } if (i == length - 1) { obj[path[i]] = value; }
obj = obj[path[i]]; } return length ? obj : void 0;}paths.forEach(p => { let path = p.replace("docs/", "").replace(/\.md$/, ""); deepSet(obj, path.split("/"), "/" + path);}) ---
<style lang="scss"> aside { font-size: 0.9em; min-width: 300px; @apply lt-sm:-translate-x-full; @apply py-2 min-w-[250px] lg:min-w-[300px]; @apply fixed lt-sm:h-full lt-sm:w-full sm:relative left-0 top-0; }
.sticky { @apply sm:sticky h-full max-h-screen top-0 w-full flex flex-col; }
.scroll-shadow-top, .scroll-shadow-bottom { @apply from-white dark:from-black to-transparent z-10 flex-shrink-0; @apply w-full h-16 pointer-events-none; }
.scroll-shadow-top { @apply bg-gradient-to-b translate-y-full; transform: translateY(99%); } .scroll-shadow-bottom { @apply bg-gradient-to-t -translate-y-full; transform: translateY(-99%); }
.scroll { @apply relative w-full overflow-auto px-5 py-10; }
details { .content { padding-left: 2ch; @apply py-2; }
summary::marker { content: ""; }
summary, a { @apply relative cursor-pointer py-2; padding-left: 2ch;
&:before { font-family: FluentSystemIcons-Regular !important; font-style: normal; font-weight: normal !important; font-variant: normal; text-transform: none; line-height: 1;
-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
content: "► "; content: "\f2af";
@apply absolute left-0 top-1/2; @apply text-2xl text-blue-600 dark:text-gray-400/60; transform: translate(0, -50%); } }
summary:before { transition: transform 0.2s ease-in-out; transform: translate(0, -50%) rotateZ(0deg); }
&[open] > summary { @apply text-blue-500;
&:before { // content: "▼ "; // content: "\f2a2"; transform: translate(0, -50%) rotateZ(90deg); } }
a { @apply border-none block font-light; @apply no-underline py-3 text-black/75 dark:text-blue-300/80; word-break: break-word; padding-left: 3ch; font-size: 0.9em;
&:before { transform: translate(calc((1em - 2px) / 2), -50%); @apply w-px h-full border-l-[1px] border-dashed border-gray-500/60; content: ""; }
& + details { @apply pt-6; }
&.active { @apply text-blue-500;
&:before { @apply border-solid border-blue-500/80; } } } }</style>
<aside> <Logo /> <div class="sticky"> <div class="scroll-shadow-top"></div> <div class="scroll"> { () => { let generate = (input, depth = 1) => { let _keys = Object.keys(input).sort((a, b) => (a == "index" ? -1 : b == "index" ? 1 : 0) );
return Promise.all( _keys.map((item) => isObject(input[item]) ? ( <details> <summary> <p>{["animate", "emitter", "manager", "native"].includes(item) ? `@okikio/${item}` : capitalize(item)}</p> </summary>
<div class="content">{depth >= 6 ? null : generate(input[item], depth + 1)}</div> </details> ) : (<a href={input[item].replace(new RegExp("\/index$"), "/")}>{item == "index" ? "Overview" : capitalize(item)}</a>) // (<SidebarSection item={item} details={input[item]} content={depth >= 5 ? null : generate(input[item], depth + 1)} />) ) ); };
return generate(obj); } } </div>
<div class="scroll-shadow-bottom"></div> </div></aside>
<script src={Astro.resolve("../ts/sidebar.mjs")} type="module"></script>