-
Notifications
You must be signed in to change notification settings - Fork 12
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
🕹 Move controls to embed node #142
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { SourceFileKind, type GenericNode } from 'myst-common'; | ||
import { useCellExecution } from './execute'; | ||
import { | ||
ArticleResetNotebook, | ||
ArticleRunNotebook, | ||
ArticleStatusBadge, | ||
} from './controls/ArticleCellControls'; | ||
import { JupyterIcon } from '@scienceicons/react/24/solid'; | ||
import { select } from 'unist-util-select'; | ||
import { useLinkProvider } from '@myst-theme/providers'; | ||
|
||
function EmbedWithControls({ | ||
outputKey, | ||
children, | ||
title = 'Jupyter Notebook', | ||
url, | ||
}: { | ||
outputKey: string; | ||
children?: React.ReactNode; | ||
title?: string; | ||
url?: string; | ||
}) { | ||
const { kind } = useCellExecution(outputKey); | ||
const Link = useLinkProvider(); | ||
const showControls = kind === SourceFileKind.Article; | ||
|
||
return ( | ||
<div className="shadow"> | ||
{showControls && ( | ||
<div className="sticky top-[60px] z-[2] w-full bg-gray-100/80 backdrop-blur dark:bg-neutral-800/80 py-1 px-2"> | ||
<div className="flex items-center"> | ||
<div className="flex items-center"> | ||
<JupyterIcon className="inline-block w-5 h-5" /> | ||
<span className="ml-2">Source:</span> | ||
{url && ( | ||
<Link to={url} className="ml-2 no-underline text-normal hover:underline"> | ||
{title} | ||
</Link> | ||
)} | ||
</div> | ||
<div className="flex-grow" /> | ||
<ArticleStatusBadge id={outputKey} /> | ||
<ArticleRunNotebook id={outputKey} /> | ||
<ArticleResetNotebook id={outputKey} /> | ||
</div> | ||
</div> | ||
)} | ||
<div className="mt-2">{children}</div> | ||
</div> | ||
); | ||
} | ||
|
||
export function Embed(node: GenericNode, children: React.ReactNode) { | ||
const output = select('output', node) as GenericNode; | ||
if (!output) return <>{children}</>; | ||
return ( | ||
<EmbedWithControls | ||
key={node.key} | ||
outputKey={output.key} | ||
title={node.source?.title} | ||
url={node.source?.url} | ||
> | ||
{children} | ||
</EmbedWithControls> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ export const ArticlePage = React.memo(function ({ article }: { article: PageLoad | |
</div> | ||
)} | ||
{canCompute && article.kind === SourceFileKind.Notebook && <NotebookToolbar showLaunch />} | ||
{canCompute && article.kind === SourceFileKind.Article && <NotebookToolbar />} | ||
{/* {canCompute && article.kind === SourceFileKind.Article && <NotebookToolbar />} */} | ||
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 have commented this out, but we may want to bring something like it back. 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 like the idea of making it figure oriented -- all we are losing here is the ability to "run all" in one go |
||
<ContentBlocks pageKind={article.kind} mdast={article.mdast as GenericParent} /> | ||
<Bibliography /> | ||
<ConnectionStatusTray /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.hover-card-content { | ||
animation-duration: 0.6s; | ||
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); | ||
z-index: 10; | ||
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. This is the only real style change for z-index. |
||
} | ||
.hover-card-content[data-side='top'] { | ||
animation-name: slideUp; | ||
|
@@ -32,9 +33,9 @@ | |
} | ||
|
||
.hover-document { | ||
@apply bg-white dark:bg-slate-800 text-sm rounded border border-gray-50 shadow-xl article; | ||
@apply text-sm bg-white border rounded shadow-xl dark:bg-slate-800 border-gray-50 article; | ||
} | ||
|
||
.hover-link { | ||
@apply text-blue-700 dark:text-blue-100 no-underline hover:text-blue-500 font-normal; | ||
@apply font-normal text-blue-700 no-underline dark:text-blue-100 hover:text-blue-500; | ||
} |
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.
I have moved the
embed -> output
node with controls here. This allows us to link to the notebook source.I am not totally happy with it, but I think it is better than the controls being fully on the right.