-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/thebe v2 - interactive figures in articles #136
Merged
Merged
Changes from 52 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
ca326e2
🤔wip
stevejpurves 64b6a32
🤺 basic scope persisted across navigation
stevejpurves 00a9460
👷🏽build requests
stevejpurves b5c57eb
🛤 parallel builds
stevejpurves f52df10
📡 fetching dependency mdast on demand
stevejpurves 74f22e5
🗺fix navigation logic
stevejpurves a5efd80
🍱 prepping for notebook build step
stevejpurves 2e32add
🔧 use standard selector arg ordering
stevejpurves 5741d21
🪐 move to jupyter package
stevejpurves 09e4e11
🎥📒 notebook and rendermime added to scope
stevejpurves efde2c1
🐐ready for session start
stevejpurves 9ae03d8
🖥 server started & beginning session startup
stevejpurves b67ac7d
🚀 sessions are started
stevejpurves 0dad078
🧲 cells attach to the DOM in articles
stevejpurves bf3fa3e
⚡️ execution
stevejpurves c6cd741
🙏 session creation happening as expected
stevejpurves 0ba558b
🏗 loading core on demand
stevejpurves f341a1d
🛟 outputs from execution are preserved across navigation
stevejpurves 8b1e7f3
🎚reset all
stevejpurves cbd6654
🪝extended execution hooks
stevejpurves 7f9a39a
🚥 start of toolbar UI
stevejpurves 376b86d
🎛 notebook UI controls
stevejpurves 52d6e16
🏃♀️autorun
stevejpurves dbbde15
♻️ session restarts on reconnect
stevejpurves 0a6eb0e
🕵️♀️ debug not log
stevejpurves 1052db1
🎒port to new exec scope provider
stevejpurves 428731d
☎️ button uniformity
stevejpurves f255251
📤 adding connection tray back in
stevejpurves db667a3
⏭towards immediate execution
stevejpurves deec502
📚z index change for toc
stevejpurves ae21e3c
⏳busy status 1
stevejpurves 0d187dd
🚀 launch is back
stevejpurves 7ce280c
🕹some controls available on figures
stevejpurves b4e5b05
☎️ meaningful article controls
stevejpurves 455ec5e
🎛 buttons
stevejpurves fcee577
🛠 fix bad var name
stevejpurves afd973d
🧥load thebe styles again
stevejpurves 45b3778
👊🏽 📦🔒pumb `thebe` packages to get unpatched styles
stevejpurves 94a0ba7
🔧 fixed power in individual figures
stevejpurves 66c2bbe
🔧 fix reset behaviour
stevejpurves 2607ff7
🛠fix resetall
stevejpurves 60df62b
💭renaming
stevejpurves c526827
👔 final styles
stevejpurves 0ec804c
♻ busy status on restarts
stevejpurves 8d5be08
🌗dark mode
stevejpurves d835a1e
🐑 lint
stevejpurves 2e5a7b5
🌀 reinstate binder badge and frontmatter block
stevejpurves 59cfc66
⚠️ added error tray component
stevejpurves c20e74d
💚 tests green
stevejpurves 3eeb188
📖 Table of contents indent for index page
rowanc1 2fcb4b8
👆 `pointer-events-none` on execute controls
rowanc1 705088a
📦 Fix tsconfig
rowanc1 2e9e504
📦 Make vitest stop when running `test`.
rowanc1 6292f0a
🤫 Remove console logs
rowanc1 9067da0
⎌ Revert z-index change
rowanc1 d44ea52
📖 Update error message
rowanc1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@myst-theme/site': patch | ||
--- | ||
|
||
Fix the table of contents indentation |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,62 @@ | ||
import { useEffect, useState } from 'react'; | ||
import type { PassiveCellRenderer } from 'thebe-core'; | ||
import type { IThebeNotebookError } from 'thebe-react'; | ||
import { useThebeLoader } from 'thebe-react'; | ||
|
||
function ErrorDecoration({ children, idx }: React.PropsWithChildren<{ idx?: number }>) { | ||
return ( | ||
<div className="relative py-3 mx-2 my-8 border rounded"> | ||
<div className="absolute z-10 flex items-center bg-white -top-3 -left-2"> | ||
{idx && <div className="ml-1 text-sm text-gray-500">cell #: {idx}</div>} | ||
</div> | ||
<div className="mx-3">{children}</div> | ||
</div> | ||
); | ||
} | ||
|
||
function ErrorTrayMessage({ errors }: { errors: IThebeNotebookError[] }) { | ||
const { core } = useThebeLoader(); | ||
|
||
const [cells, setCells] = useState<PassiveCellRenderer[]>([]); | ||
const [refs, setRefs] = useState<((node: HTMLDivElement) => void)[]>([]); | ||
|
||
useEffect(() => { | ||
if (!core) return; | ||
const cs = errors.map(() => new core.PassiveCellRenderer('any')); | ||
setRefs( | ||
errors.map((_, idx) => (node: any) => { | ||
if (node) { | ||
cs[idx].attachToDOM(node); | ||
cs[idx].render(errors[idx].error ?? []); | ||
} | ||
}), | ||
); | ||
setCells(cells); | ||
}, [core, errors]); | ||
|
||
if (!core) return null; | ||
return ( | ||
<div> | ||
{errors.map((error, idx) => ( | ||
<div className="min-w-[400px]"> | ||
<ErrorDecoration idx={error.index}> | ||
<div className="z-100" key={error.id} ref={refs[idx]}></div> | ||
</ErrorDecoration> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export function ErrorTray({ errors }: { errors: IThebeNotebookError[] }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should also be radix in the future. |
||
return ( | ||
<div className="relative px-4 pt-3 mt-8 text-sm text-red-600 border border-red-400 rounded border-1"> | ||
<div> | ||
<span className="font-bold">Error</span> - a page refresh may resolve this. If not, shutdown | ||
this simulation and start another. If the error persists please contact support with a | ||
screenshot of this page, including the error message below. | ||
</div> | ||
<ErrorTrayMessage errors={errors} /> | ||
</div> | ||
); | ||
} |
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,54 @@ | ||
import { useThebeServer } from 'thebe-react'; | ||
import { useNotebookExecution } from '../execute/hooks'; | ||
import { Reset, Run, SpinnerStatusButton } from './Buttons'; | ||
|
||
import { selectAreExecutionScopesBuilding } from '../execute'; | ||
|
||
export function ArticleStatusBadge({ id }: { id: string }) { | ||
const { connect, connecting } = useThebeServer(); | ||
const { slug, state, start, ready, executionCount } = useNotebookExecution(id); | ||
|
||
const building = selectAreExecutionScopesBuilding(state, slug); | ||
|
||
const handleStart = () => { | ||
connect(); | ||
start(); | ||
}; | ||
|
||
return ( | ||
<SpinnerStatusButton | ||
ready={ready} | ||
busy={building || connecting} | ||
modified={executionCount != null} | ||
onClick={handleStart} | ||
/> | ||
); | ||
} | ||
|
||
export function ArticleRunNotebook({ id }: { id: string }) { | ||
const { ready, cellIsExecuting, notebookIsBusy, execute } = useNotebookExecution(id); | ||
if (!ready) return null; | ||
return ( | ||
<Run | ||
ready={ready} | ||
executing={cellIsExecuting} | ||
disabled={notebookIsBusy} | ||
onClick={execute} | ||
title="Run the notebook that creates this figure" | ||
/> | ||
); | ||
} | ||
|
||
export function ArticleResetNotebook({ id }: { id: string }) { | ||
const { ready, notebookIsResetting, notebookIsBusy, reset } = useNotebookExecution(id); | ||
if (!ready) return null; | ||
return ( | ||
<Reset | ||
ready={ready} | ||
resetting={notebookIsResetting} | ||
disabled={notebookIsBusy} | ||
onClick={reset} | ||
title="Reset the figure to its original state and restart the kernel" | ||
/> | ||
); | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking forward to this. :)