React-Framestack
yarn add react-framestack
Components
Stack
<Stack>/* ... */<Stack>
Props
stack
name for the stack; frames subscribe to a stackstartAt
initial index
Provides Context (subscribe through Frame)
index
selected framedispatch
trigger action (like Redux)dispatch("goForward")
dispatch("goForward")
dispatch("jumpTo", index)
Frame
<Frame = = ='slides'> <h1>One</h1><Frame>
Props
frame
hide unless frame matches indexexact
(defaults to true) if false, show if index is>=
frame instead of===
stack
(defaults to 'slides') stack to subscribe tochildren
function that takesdispatch
as an argument
Codepen)
Example: Building a Slideshow (import Stack Frame from 'react-framestack'
const lorem = `Lorem ipsum dolor sit amet`; const NavButton = navigate children ...props const handleClick = { e; e; ; }; return <span => children </span> ;; const Slide = next prev children <div ="slide" => children <NavButton = = > ← </NavButton> <NavButton = = > → </NavButton> </div>; const Title = children <h1>children</h1>; const Body = color = "black" children <p =>children</p>; // Helper to simplify eventsconst createSlide = { const next = ; const prev = ; return <Slide = => <Component /> </Slide> ;}; const SlideOne = ; const SlideTwo = ; const End = <div ="slide" => <p> <a ="#" => Restart </a> </p> </div>; const SlideShow = <Stack ="slides"> SlideOne SlideTwo End </Stack>;