-
Notifications
You must be signed in to change notification settings - Fork 286
docs: add Soroban storage strategies guide #2649
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2e1a941
add storage strategies guide with animated diagrams
marcelosalloum a1fea20
codex worked oncorrecting Soroban storage strategies guide
marcelosalloum 5440fd9
fix storage guide facts, diagram styling and animations
marcelosalloum dc78ebd
polish storage guide, add markdown-source plugin
marcelosalloum 9279b48
fix ttl animation, clarify tier and cap wording
marcelosalloum ee0d6fc
clarify strategies 7-8, fix swap-and-pop diagram
marcelosalloum e0d7376
polish strategy titles, s9 wording and diagrams
marcelosalloum 5df70cf
rework strategy 10 and its diagram, note cap-85
marcelosalloum f66e227
clarify decision path, cheatsheet, s11 diagram
marcelosalloum 1d9a9fe
add checkpoints strategy as s10, renumber s10-11 to s11-12
marcelosalloum c322537
make d1/d3/d7 animations finite, show allowance deadline checks
marcelosalloum 6d0e48d
drop the markdown-source dev middleware
marcelosalloum 2bb068a
apply review wording and formatting feedback
marcelosalloum 766eb90
correct snippet semantics and cost accounting
marcelosalloum 22ce567
relabel d5 ttl diagram as not to scale
marcelosalloum 19e1812
show bump-on-read via a balance getter
marcelosalloum 7a4716a
show diagram final frames when javascript is off
marcelosalloum eab9e61
cite oz smart account instead of passkey-kit
marcelosalloum 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| import React, { useEffect, useRef, useState } from "react"; | ||
| import "./diagrams.css"; | ||
|
|
||
| interface AnimatedDiagramProps { | ||
| id: string; | ||
| caption?: string; | ||
| children: React.ReactNode; | ||
| } | ||
|
|
||
| // Card that plays its CSS/SVG animations once it scrolls into view, with a | ||
| // replay button. Animations are gated behind the .play class (see diagrams.css). | ||
| export default function AnimatedDiagram({ | ||
| id, | ||
| caption, | ||
| children, | ||
| }: AnimatedDiagramProps) { | ||
| const ref = useRef<HTMLDivElement>(null); | ||
| // .play must live in React state: it gates animation-play-state in CSS, and | ||
| // an imperatively added class would be dropped on the next re-render. | ||
| const [playing, setPlaying] = useState(false); | ||
| const [restored, setRestored] = useState({ | ||
| instance: false, | ||
| persistent: false, | ||
| }); | ||
|
|
||
| useEffect(() => { | ||
| const el = ref.current; | ||
| if (!el) { | ||
| return undefined; | ||
| } | ||
| const io = new IntersectionObserver( | ||
| (entries) => { | ||
| entries.forEach((entry) => { | ||
| if (entry.isIntersecting) { | ||
| setPlaying(true); | ||
| io.unobserve(el); | ||
| } | ||
| }); | ||
| }, | ||
| { threshold: 0.45 }, | ||
| ); | ||
| io.observe(el); | ||
| return () => io.disconnect(); | ||
| }, []); | ||
|
|
||
| const replay = () => { | ||
| const el = ref.current; | ||
| if (!el) { | ||
| return; | ||
| } | ||
| setRestored({ instance: false, persistent: false }); | ||
| setPlaying(true); | ||
| // Toggling .play only pauses/resumes; to restart from frame 0 the | ||
| // animations themselves must be torn down and recreated. | ||
| const anims = el.querySelectorAll<HTMLElement | SVGElement>(".anim"); | ||
| anims.forEach((a) => { | ||
| a.style.animation = "none"; | ||
| }); | ||
| void (el as HTMLElement).offsetWidth; | ||
| anims.forEach((a) => { | ||
| a.style.animation = ""; | ||
| }); | ||
| }; | ||
|
|
||
| const className = [ | ||
| "ssd", | ||
| playing ? "play" : "", | ||
| restored.instance ? "restored-instance" : "", | ||
| restored.persistent ? "restored-persistent" : "", | ||
| ] | ||
| .filter(Boolean) | ||
| .join(" "); | ||
|
|
||
| return ( | ||
| <div className={className} id={id} ref={ref}> | ||
| <div className="diagram-controls"> | ||
| {id === "d0" ? ( | ||
| <> | ||
| <button | ||
| className="restore" | ||
| type="button" | ||
| aria-pressed={restored.instance} | ||
| onClick={() => | ||
| setRestored((current) => ({ ...current, instance: true })) | ||
| } | ||
| > | ||
| Restore instance | ||
| </button> | ||
| <button | ||
| className="restore" | ||
| type="button" | ||
| aria-pressed={restored.persistent} | ||
| onClick={() => | ||
| setRestored((current) => ({ ...current, persistent: true })) | ||
| } | ||
| > | ||
| Restore persistent entry | ||
| </button> | ||
| </> | ||
| ) : null} | ||
| <button className="replay" type="button" onClick={replay}> | ||
| {id === "d0" ? "β» Replay expiry" : "β» Replay"} | ||
| </button> | ||
| </div> | ||
| {children} | ||
| {caption ? <p className="caption">{caption}</p> : null} | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.