feat: add code explorer for the examples#371
Merged
tannerlinsley merged 45 commits intomainfrom Mar 21, 2025
Merged
Conversation
✅ Deploy Preview for tanstack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
d673bae to
1e2231d
Compare
RegiByte
reviewed
Mar 21, 2025
Comment on lines
+105
to
+138
| const [expandedFolders, setExpandedFolders] = React.useState<Set<string>>( | ||
| () => { | ||
| const expanded = new Set<string>() | ||
| if (githubContents) { | ||
| const flattened = recursiveFlattenGithubContents(githubContents) | ||
| if (flattened.every((f) => f.depth === 0)) { | ||
| return expanded | ||
| } | ||
|
|
||
| // if the currentPath matches, then open | ||
| for (const file of flattened) { | ||
| if (file.path === currentPath) { | ||
| // Open all ancestors directories | ||
| const dirs = flattedOnlyToDirs(githubContents) | ||
| const ancestors = file.path.split('/').slice(0, -1) | ||
|
|
||
| while (ancestors.length > 0) { | ||
| const ancestor = ancestors.join('/') | ||
|
|
||
| if (dirs.some((d) => d.path === ancestor)) { | ||
| expanded.add(ancestor) | ||
| ancestors.pop() | ||
| } else { | ||
| break | ||
| } | ||
| } | ||
|
|
||
| break | ||
| } | ||
| } | ||
| } | ||
| return expanded | ||
| } | ||
| ) |
There was a problem hiding this comment.
I am amazed by the simplicity and effectiveness of this PR! Thank's for sharing!
LeCarbonator
pushed a commit
to LeCarbonator/tanstack.com
that referenced
this pull request
Jan 11, 2026
* Initial attempt at adding static code snippets above sandboxes * convert to file explorer * fix full screen stuff * fetch main file using server fn * use queryOptions * move more to query * move all fetching to Query * no need the assertion * adhere to rules of hooks * starting to wire up fs reads and don't store the entire file in state * initial mocking of the fs fetch * get fs working * make state reactive * make the urls bookmark-able * sort nodes and do not make the route tree depth exponential * more files to ignore * sidebar to retain the active state * more restrictions * fullscreen from current active tab * restrict which folders can be default opened * better icons * more mobile friendly stuff * close sidebar by default on mobile * border cleanup * better fs mocking of the github api * remove unnecessary divs * less layout shift * import icons using `?url` * prepare for determining the starting file path on the server * get the initial filename * eslint rules-of-hooks warning * default open to the current directory * fixup some incorrect fallback behaviour on the starting file * add more preference dirs * break up code explorer ui elements into smaller components * move some state down components tree * improve file explorer tree ui/ux * mobile improvements * add authorization using GITHUB_TOKEN * use `dotenv-cli` instead * update folder icons --------- Co-authored-by: Kevin Van Cott <kevinvandy656@gmail.com> Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.