Skip to content
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

🪐 Launch binder for article theme #239

Merged
merged 22 commits into from
Oct 3, 2023
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
60dbf47
⏫ add launch button to sub pages
stevejpurves Sep 28, 2023
b3c6c54
🎚optionally load thebelite
stevejpurves Sep 28, 2023
13ca796
simple launch, independent binders
stevejpurves Sep 28, 2023
ff92417
launch from supporting docs
stevejpurves Sep 28, 2023
b1248c3
style tweaks
stevejpurves Sep 28, 2023
4f93c2f
🔧 fix react type issue
stevejpurves Sep 28, 2023
39dd855
🍕 consume latest `thebe` changes
stevejpurves Sep 28, 2023
2c65a0c
🚛 move launch binder button
stevejpurves Sep 28, 2023
c51cec8
🛠 fixing pageloader to include recently added `location` field
stevejpurves Sep 28, 2023
2621a16
🚀 launch to a specific name
stevejpurves Sep 28, 2023
4f939be
🔌 binder connection and launch with location
stevejpurves Sep 28, 2023
078cc56
remove debug logging
stevejpurves Sep 28, 2023
4beb59a
auto open binder link after server ready
stevejpurves Sep 28, 2023
f9d7aba
⚠️ show connection error
stevejpurves Sep 28, 2023
37e8b0f
👮🏻enable full override of theeb configuration by a parent theme
stevejpurves Sep 28, 2023
f5e9475
🛟 get connection status tray on top
stevejpurves Sep 28, 2023
969ca76
🗑 remove binder badge option
stevejpurves Sep 28, 2023
25075ac
👩🏾‍🍳 dont bake in custom providers
stevejpurves Sep 28, 2023
b5ba95d
add ErrorTray, NotebookToolbar and placeholder for options
stevejpurves Sep 28, 2023
01f6f67
👊🏽 thebe
stevejpurves Sep 28, 2023
5b7f149
👊🏽👊🏽 thebe
stevejpurves Sep 28, 2023
4049f9c
Merge branch 'main' into feat/binder-for-articles
rowanc1 Oct 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions packages/jupyter/src/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import type { SourceFileKind } from 'myst-spec-ext';
import React, { useContext } from 'react';
import { ThebeServerProvider } from 'thebe-react';
import { ExtendedCoreOptions, thebeFrontmatterToOptions } from './utils';
import { type ExtendedCoreOptions, thebeFrontmatterToOptions } from './utils';
import type { GenericParent } from 'myst-common';
import { SiteManifest } from 'myst-config';
import { RepoProviderSpec } from 'thebe-core';
import type { SiteManifest } from 'myst-config';
import type { RepoProviderSpec } from 'thebe-core';

function makeThebeOptions(
siteManifest: SiteManifest | undefined,
overrides?: { thebe?: false },
optionsOverrideFn = (opts?: ExtendedCoreOptions) => opts,
): {
options?: ExtendedCoreOptions;
githubBadgeUrl?: string;
binderBadgeUrl?: string;
} {
if (!siteManifest || overrides?.thebe === false) return {};
if (!siteManifest) return {};
// TODO there may be multiple projects?
// useProjectManifest?
const mainProject = siteManifest?.projects?.[0];
Expand All @@ -27,7 +27,8 @@ function makeThebeOptions(
binderBadgeUrl,
);

const options = thebeFrontmatter ? optionsFromFrontmatter : undefined;
const options = optionsOverrideFn(thebeFrontmatter ? optionsFromFrontmatter : undefined);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a parent theme is able to fully manipulate the options, guarding against undesirable options (e..g connecting to a foreign binder) coming in from the myst site, or just being able to patch certain options appropriately for where there parent theme is used/deployed.


return {
options,
githubBadgeUrl,
Expand All @@ -45,17 +46,17 @@ const ThebeOptionsContext = React.createContext<ThebeOptionsContextType>({});

export function ConfiguredThebeServerProvider({
siteManifest,
overrides,
optionOverrideFn,
customRepoProviders,
children,
}: React.PropsWithChildren<{
siteManifest?: SiteManifest;
overrides?: any;
optionOverrideFn?: (opts?: ExtendedCoreOptions) => ExtendedCoreOptions;
customRepoProviders?: RepoProviderSpec[];
}>) {
const thebe = React.useMemo(
() => makeThebeOptions(siteManifest, overrides),
[siteManifest, overrides],
() => makeThebeOptions(siteManifest, optionOverrideFn),
[siteManifest, optionOverrideFn],
);

if (!siteManifest) return <>{children}</>;
Expand Down