-
Notifications
You must be signed in to change notification settings - Fork 59
link to dynamic shader playgrounds #223
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
Open
itsdouges
wants to merge
8
commits into
main
Choose a base branch
from
dynamic-playground
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9ca7907
feat: update open paper link
itsdouges 67b338b
chore: open in paper
itsdouges d1d3da9
chore: set app url
itsdouges e2101b3
chore: use serialize params
itsdouges db0763c
fix: correct url
itsdouges e0c65f1
fix: defer applying params
itsdouges bff72a1
chore: comment
itsdouges fc06d4a
chore: replace margin params
itsdouges 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,6 +4,9 @@ import { ShaderDef } from '@/shader-defs/shader-def-types'; | |
| import { Leva } from 'leva'; | ||
| import { CopyButton } from './copy-button'; | ||
| import { useState } from 'react'; | ||
| import kebabCase from 'lodash-es/kebabCase'; | ||
|
|
||
| const appUrl = process.env.NODE_ENV === 'development' ? 'http://localhost:5173' : 'https://app.paper.design'; | ||
|
|
||
| export function ShaderContainer({ | ||
| children, | ||
|
|
@@ -16,28 +19,36 @@ export function ShaderContainer({ | |
| return ( | ||
| <div className="md:mb-24"> | ||
| {shaderDef && currentParams && ( | ||
| <div className="flex h-80 items-center justify-between border-t border-current/10 dark:border-current/20"> | ||
|
Contributor
Author
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. all style changes are from the tw prettier plugin running over the code. |
||
| <div className="border-current/10 dark:border-current/20 flex h-80 items-center justify-between border-t"> | ||
| <h1 className="text-3xl font-[330] lowercase">{shaderDef.name}</h1> | ||
|
|
||
| <div className="hidden items-center gap-24 lg:flex"> | ||
| <CopyLinkButton | ||
| shaderDef={shaderDef} | ||
| currentParams={currentParams} | ||
| className="-mx-8 flex h-32 items-center gap-8 rounded-md px-8 outline-0 outline-focus transition-colors hover:bg-backplate-2 focus-visible:outline-2 active:bg-backplate-3 squircle:rounded-lg" | ||
| className="outline-focus hover:bg-backplate-2 active:bg-backplate-3 squircle:rounded-lg -mx-8 flex h-32 items-center gap-8 rounded-md px-8 outline-0 transition-colors focus-visible:outline-2" | ||
| /> | ||
|
|
||
| <a | ||
| href="https://app.paper.design" | ||
| href={`${appUrl}/playground/${kebabCase(shaderDef.name)}`} | ||
| target="_blank" | ||
| className="-mx-8 flex h-32 items-center gap-8 rounded-md px-8 outline-0 outline-focus transition-colors hover:bg-backplate-2 focus-visible:outline-2 active:bg-backplate-3 squircle:rounded-lg" | ||
| className="outline-focus hover:bg-backplate-2 active:bg-backplate-3 squircle:rounded-lg -mx-8 flex h-32 items-center gap-8 rounded-md px-8 outline-0 transition-colors focus-visible:outline-2" | ||
| onClick={(e) => { | ||
| if (e.currentTarget instanceof HTMLAnchorElement) { | ||
| // We defer applying params until the click to avoid serializing too much into HTML. | ||
| e.preventDefault(); | ||
| const fullUrl = `${e.currentTarget.href}#${serializeParams(currentParams as Record<string, SerializableValue>, shaderDef.params)}`; | ||
| window.open(fullUrl, e.currentTarget.target); | ||
| } | ||
| }} | ||
| > | ||
| <svg width="14" height="14" viewBox="0 0 14 14" fill="currentcolor"> | ||
| <path d="M12.2041 0.0107422C13.2128 0.113003 14 0.964351 14 2V12L13.9893 12.2041C13.8938 13.1457 13.1457 13.8938 12.2041 13.9893L12 14H6V13H12C12.5523 13 13 12.5523 13 12V2C13 1.48233 12.6067 1.05623 12.1025 1.00488L12 1H2C1.48232 1 1.05621 1.39333 1.00488 1.89746L1 2V8H0V2C0 0.89543 0.89543 0 2 0H12L12.2041 0.0107422Z" /> | ||
| <path d="M8 9.5V6.5C7.99921 6.36201 7.94251 6.23434 7.85143 6.14433C7.80398 6.09744 7.74949 6.06198 7.69139 6.03794C7.63244 6.01349 7.56779 6 7.5 6H4.5C4.22386 6 4 6.22386 4 6.5C4 6.77614 4.22386 7 4.5 7H6.29289L0.146453 13.1464C-0.0488175 13.3417 -0.0488175 13.6583 0.146453 13.8536C0.341713 14.0488 0.658292 14.0488 0.853552 13.8536L7 7.70711V9.5C7 9.77614 7.22386 10 7.5 10C7.77614 10 8 9.77614 8 9.5Z" /> | ||
| </svg> | ||
|
|
||
| <span> | ||
| open <span style={{ fontFeatureSettings: '"ss01"' }}>Paper</span> | ||
| open in <span style={{ fontFeatureSettings: '"ss01"' }}>Paper</span> | ||
| </span> | ||
| </a> | ||
| </div> | ||
|
|
@@ -48,7 +59,7 @@ export function ShaderContainer({ | |
| <ResizableShader>{children}</ResizableShader> | ||
|
|
||
| <div | ||
| className="absolute -top-4 -right-332 hidden w-300 overflow-auto rounded-xl bg-(--color-leva-background) pb-4 has-[[data-leva-container]>[style*='display:none']]:hidden lg:block squircle:rounded-2xl" | ||
| className="-right-332 w-300 bg-(--color-leva-background) squircle:rounded-2xl absolute -top-4 hidden overflow-auto rounded-xl pb-4 has-[[data-leva-container]>[style*='display:none']]:hidden lg:block" | ||
| style={{ | ||
| boxShadow: ` | ||
| rgba(58, 34, 17, 0.1) 0px 4px 40px -8px, | ||
|
|
@@ -116,13 +127,13 @@ function ResizableShader({ children }: React.PropsWithChildren) { | |
|
|
||
| return ( | ||
| <div | ||
| className="flex aspect-4/3 *:size-full *:max-h-full not-has-[[data-paper-shader]]:bg-header xs:aspect-3/2 md:aspect-16/9" | ||
| className="aspect-4/3 not-has-[[data-paper-shader]]:bg-header xs:aspect-3/2 md:aspect-16/9 flex *:size-full *:max-h-full" | ||
| onPointerMove={(event) => setCanStartResize(event.altKey)} | ||
| onPointerLeave={() => setCanStartResize(false)} | ||
| > | ||
| <div | ||
| data-resizable={canStartResize || undefined} | ||
| className="flex overflow-hidden *:size-full data-resizable:resize [[style*='width']]:resize" | ||
| className="data-resizable:resize [[style*='width']]:resize flex overflow-hidden *:size-full" | ||
| > | ||
| {children} | ||
| </div> | ||
|
|
||
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.
because
marginisn't available in paper I've switched it out for the individual props