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

🚀 MVP launch buttons for JupyterHub & MyBinder #503

Merged
merged 21 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
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
327 changes: 265 additions & 62 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion packages/frontmatter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"dependencies": {
"@headlessui/react": "^1.7.15",
"@heroicons/react": "^2.0.18",
"@radix-ui/react-popover": "^1.0.6",
"@radix-ui/react-form": "^0.1.0",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-popover": "^1.1.2",
"@radix-ui/react-tabs": "^1.1.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏼

"@scienceicons/react": "^0.0.6",
"classnames": "^2.3.2",
"myst-common": "*",
Expand Down
13 changes: 13 additions & 0 deletions packages/frontmatter/src/FrontmatterBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { JupyterIcon, OpenAccessIcon, GithubIcon, TwitterIcon } from '@scienceic
import { LicenseBadges } from './licenses.js';
import { DownloadsDropdown } from './downloads.js';
import { AuthorAndAffiliations, AuthorsList } from './Authors.js';
import { LaunchButton } from './LaunchButton.js';

function ExternalOrInternalLink({
to,
Expand Down Expand Up @@ -187,20 +188,29 @@ export function Journal({
);
}

export type LaunchOptions = {
repo: string;
location: string;
binder?: string;
jupyterhub?: string;
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't love this; I think instead frontmatter should be resolved according to https://mystmd.org/guide/frontmatter#table-frontmatter. But, for now, let's just get this in.

export function FrontmatterBlock({
frontmatter,
kind = SourceFileKind.Article,
authorStyle = 'block',
hideBadges,
hideExports,
className,
launchOptions,
}: {
frontmatter: Omit<PageFrontmatter, 'parts'>;
kind?: SourceFileKind;
authorStyle?: 'block' | 'list';
hideBadges?: boolean;
hideExports?: boolean;
className?: string;
launchOptions?: LaunchOptions;
}) {
if (!frontmatter) return null;
const {
Expand All @@ -226,6 +236,8 @@ export function FrontmatterBlock({
const hasHeaders = !!subject || !!venue || !!volume || !!issue;
const hasDateOrDoi = !!doi || !!date;
const showHeaderBlock = hasHeaders || (hasBadges && !hideBadges) || (hasExports && !hideExports);
const hideLaunch: boolean = false;

if (!title && !subtitle && !showHeaderBlock && !hasAuthors && !hasDateOrDoi) {
// Nothing to show!
return null;
Expand Down Expand Up @@ -267,6 +279,7 @@ export function FrontmatterBlock({
</>
)}
{!hideExports && <DownloadsDropdown exports={(downloads ?? exports) as any} />}
{!hideLaunch && launchOptions && <LaunchButton {...launchOptions} />}
</div>
)}
{title && <h1 className="mb-0">{title}</h1>}
Expand Down
Loading
Loading