No Stepper Component? (is it now the use-steps hook?)
See original GitHub issuePrerequisites
Feel free to delete this section if you have checked off all of the following.
- I’ve searched open issues to make sure I’m not opening a duplicate issue
- I have read through the docs before asking a question
- [
^8.0.1
] I am using the latest version of Spectacle
Describe Your Environment
What version of Spectacle are you using? (can be found by running npm list spectacle
):
8.0.1
What version of React are you using? (can be found by running npm list react
):
17.0.2
What browser are you using? Firefox
What machine are you on? macOS
Describe the Problem
Stepper is advertised on the docs, and is mentioned in the changelog, which links to PR https://github.com/FormidableLabs/spectacle/pull/843 which seems to add a components/stepper.js
file, but that never made it to the main
branch. Did this functionality get merged into some other object? In any case there’s a mismatch between the docs and the code.
Expected behavior: [What you expect to happen]
import { Stepper } from 'spectacle';
then i guess being able to use it…
Actual behavior: [What actually happens]
export 'Stepper' (imported as 'Stepper') was not found in 'spectacle' (possible exports: Appear, Box, CodePane, CodeSpan, Deck, DeckContext, FlexBox, FullScreen, FullSizeImage, Grid, Heading, Image, Link, ListItem, Markdown, MarkdownPreHelper, MarkdownSlide, MarkdownSlideSet, Notes, OrderedList, Progress, Quote, Slide, SlideContext, SpectacleLogo, Table, TableBody, TableCell, TableHeader, TableRow, Text, UnorderedList, defaultTheme, indentNormalizer, isolateNotes, mdxComponentMap, removeNotes)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11 (11 by maintainers)
Top GitHub Comments
@sneakers-the-rat hi there! Sorry this has taken so long. I actually wrote the majority of the new code, so here’s the 411.
Your analysis of the
useSteps
hook is more or less accurate. Essentially, this is the mechanism which allows you to write components which “participate” in the presentation flow by rendering theplaceholder
return value in addition to other components. (“placeholder divs” are how theDeck
component detects slides, and howSlide
components detect steps.)The idea is to allow exactly the kind of behavior you’re looking for without the need to use render props. Here’s some example code:
Which you’ll notice is very similar to what you wrote!
All that being said, there is an actual bug here: the
<Appear />
component was intended to replace<Stepper>
, but after looking into it a bit it seems like its “multiple step” functionality was removed for some reason. I’m going to open a PR to add that back, and to add additional documentation for the various hooks.Ok figured out how to step through an .svg (using anime.js), and generally how to add custom step logic to slides, definitely worth documenting bc you can do stuff like this which is good:
Here’s what i’ve been making, for reference (no roastin’ allowed): https://github.com/sneakers-the-rat/infrastructure-presentation/blob/2e23e79d9b65ed583a4bd13f501d226ed3e27673/src/components/svg_animator.js
After exporting the hooks and contexts (see https://github.com/FormidableLabs/spectacle/pull/1019 and https://github.com/sneakers-the-rat/spectacle/commits/export_context ) the way it seems to work is like this — probably messing something up b/c still not sure intended use, but hey if it works…
useSteps
useSteps
seems to add steps to a slide, it takes astepIndex
param but not quite sure what it does, and returns a few props, most important of which is theplaceholder
. So to add steps to a slide, in some component do something like this:and then make sure the placeholder is included in your
render
/return
methodSlideContext
SlideContext
seems to have the notion of the current step in it, so you can use it in a component eg. as state or withuseEffect
like this, eg. with the material ui collapse component in the above gif:A really hacky way of using it is to do something like ^^ with another component that just adds steps to a slide like this:
so eg. you could do something like this in an
.mdx
slide: