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

docs: Add demo to homepage #882

Merged
merged 31 commits into from Mar 2, 2022
Merged

docs: Add demo to homepage #882

merged 31 commits into from Mar 2, 2022

Conversation

samestep
Copy link
Collaborator

@samestep samestep commented Feb 8, 2022

Description

This PR adds a new Demo component which cycles through a fixed collection of trios/variations (changing every 5 seconds), showing the Substance program and animating the diagram's convergence at 60 fps.

Implementation strategy and design decisions

We expected that it would be straightforward to embed a React component in the Docusaurus site, but it was not. @wodeni and @maxkrieger put in a lot of effort to get this working, including replacing the build systems for a few of our packages. This also involved an upgrade to (among other dependencies) Docusaurus itself, which required us to update the filenames of some of our images from the tutorials.

Also, as part of this PR, I essentially completely rewrote the Simple Penrose diagram component. Now it has more features and also implements its React state management in a somewhat more idiomatic way.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new ESLint warnings
  • I have reviewed any generated changes to the diagrams/ folder

Open questions

The Demo component UI is still pretty barebones:

  • its size on the Docusaurus site is defined in terms of pixels
  • it doesn't have any buttons to navigate among the different examples
  • it doesn't give any way to look at the underlying Domain or Style programs
  • it doesn't give any visual indication of the 5-second countdown

@joshsunshine suggested that perhaps @hsharriman might be able to help improve this UI in the future.

Also, we need some spicier diagrams to actually show in the Demo component on the homepage. Perhaps @keenancrane has some up his sleeve?

@cloudflare-pages
Copy link

cloudflare-pages bot commented Feb 8, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5cae24b
Status: ✅  Deploy successful!
Preview URL: https://153eff7d.penrose-panes.pages.dev

View logs

@codecov
Copy link

codecov bot commented Feb 8, 2022

Codecov Report

Merging #882 (72a0119) into main (4b749ae) will increase coverage by 0.28%.
The diff coverage is 91.30%.

❗ Current head 72a0119 differs from pull request most recent head 5cae24b. Consider uploading reports for the commit 5cae24b to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #882      +/-   ##
==========================================
+ Coverage   67.51%   67.79%   +0.28%     
==========================================
  Files          62       62              
  Lines        8206     8120      -86     
  Branches     1774     1769       -5     
==========================================
- Hits         5540     5505      -35     
+ Misses       2659     2608      -51     
  Partials        7        7              
Impacted Files Coverage Δ
packages/core/src/types/ad.ts 100.00% <ø> (ø)
packages/core/src/utils/Util.ts 59.48% <ø> (-4.89%) ⬇️
packages/core/src/contrib/Minkowski.ts 97.56% <89.47%> (-2.44%) ⬇️
packages/core/src/engine/Autodiff.ts 81.41% <100.00%> (+6.79%) ⬆️
packages/core/src/engine/AutodiffFunctions.ts 50.16% <100.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b749ae...5cae24b. Read the comment docs.

@samestep samestep marked this pull request as ready for review February 24, 2022 22:57
@samestep samestep requested a review from wodeni February 24, 2022 22:57
@maxkrieger
Copy link
Member

btw I disabled netlify because they greedily tried to bill us just for using the free version - we'll want to switch to cloudflare pages (and nestle panes in the same build since it doesn't support monorepos)

Copy link
Member

@wodeni wodeni left a comment

Choose a reason for hiding this comment

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

Looks great to me! Everything very clean :P. The syntax highlighting issue (see below) is the most important thing to look into for me.

packages/components/src/Listing.tsx Outdated Show resolved Hide resolved
packages/components/src/Listing.tsx Show resolved Hide resolved
const stepped = stepUntilConvergence(initState);
this.penroseState = resample(await prepareState(compilerResult.value));
} else {
console.log(showError(compilerResult.error));
Copy link
Member

Choose a reason for hiding this comment

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

Not in scope: should probably do better error handling like rendering errors on the canvas directly.

};

renderCanvas = async (state: PenroseState | undefined) => {
componentDidUpdate = async (prevProps: ISimpleProps) => {
if (
Copy link
Member

Choose a reason for hiding this comment

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

A little surprised that prop updates need to be handled this manually. Wondering if we are leveraging the React lifecycle fully.

>
<Listing value={example.sub} width={props.width} height={props.width} />
<div style={{ width: props.width, height: props.width }}>
<Simple
Copy link
Member

Choose a reason for hiding this comment

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

Nice refactoring of Simple! Maybe this is not "simple" anymore... we should probably rename it to Diagram or something.

@@ -1,12 +1,12 @@
export const oneSet = {
Copy link
Member

Choose a reason for hiding this comment

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

Seems like there's a way to reference to static files in storybook. Perhaps we can just load files from examples directly: https://storybook.js.org/docs/react/configure/images-and-assets#serving-static-files-via-storybook-configuration.

packages/components/build.js Outdated Show resolved Hide resolved
packages/docs-site/src/pages/index.js Show resolved Hide resolved
@samestep samestep requested a review from wodeni March 1, 2022 18:23
Copy link
Member

@wodeni wodeni left a comment

Choose a reason for hiding this comment

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

Looks great to me! Let's merge it

width: string;
height: string;
}) => {
const env = compileDomain(domain).unsafelyUnwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Not in scope: same thing as the diagram component, some error handling would be good.

@samestep samestep merged commit c0552dd into main Mar 2, 2022
@samestep samestep deleted the homepage-demo branch March 2, 2022 20:26
@samestep samestep mentioned this pull request May 11, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants