Skip to content

Conversation

@kiraarghy
Copy link
Contributor

@kiraarghy kiraarghy commented Jun 14, 2019

This branch rewrites the core state management logic and animation logic.

The design philosophy behind this has been moving away from the top-down redux model to a more bottoms-up local-state model (though using reducers as I think they're easier to make sense of with state changes.)

This also implements a move to using React-Spring, which should allow users to implement their own artisan animations between slides, and between slide elements.

As it is this represents an MVP before moving onto the display and layouts API for slides.

Dominic Coelho and others added 8 commits June 12, 2019 16:30
1. Change Deck.js so that it provides a render prop to the child.

1. Modify Controls.js so that they accept dispatch prop and render buttons.

1. Modify test.mdx so that it renders Controls and a currentSlide value.
@kiraarghy
Copy link
Contributor Author

Pushed up most recent commits, had to go home due to migraine :(. Will hopefully look to documenting and fixing some issues with the current set-up but hopefully gives some insight into what's happening!

@narinluangrath
Copy link
Contributor

This looks great! Let me know what you think about my comments 😃

kiraarghy and others added 14 commits June 17, 2019 16:19
* Finished slide logic
* Started adding in documentation
* removed Controls as no longer needed.
- Only shows one slide element at a time
- Update test.mdx to better show this off
Implement react spring transitions
Fixed reverse transition
* added custom transitionEffect prop to Slide component.

* added default transitionEffect
Fixed JS example.

Moved back to using MDX example.
* Implemented springs for SlideElementWrappers
* SlideElementWrapper can accept custom springs now!
Added proptypes
1. Fixed proptypes
2. improved documentation
1. Refactors some code.

2. Added in eslint for hooks cause I'm bad

3. Added in keyboard  props to deck
Fixed some animation issues with precision.

Added configuration so when going backwards you could skip animations.

Stashed on this branch an experiment to skip animations if a user double-presses forwards, needs further study.
*/

// Keeps previous slide number for comparison later.
let prevSlideNum;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think using usePrevious might be more idiomatic. https://usehooks.com/usePrevious/
We might also run into problems with this global variable if we have multiple invocations of useSlide.

set({
opacity: 1
});
set({ from: transitionEffect.from, to: transitionEffect.to });
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we simplify this even further and drop the from case and just do set({ transitionEffect.to })? Seems to produce the same result I think.


const numberOfSlideElements = Array.isArray(children)
? children.filter(x => isComponentType(x, 'SlideElementWrapper')).length
? children.filter(x => isComponentType(x, 'SlideElementWrapper')).length + 1
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the + 1 for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ummmm I'm gonna remove it, thanks for picking it up!

defaultSlideEffect),
config: { precision: 0 },
unique: true,
immediate: rest.animationsWhenGoingBack ? false : state.immediate
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nit picky comment but could we pass animationsWhenGoingBack as an argument to useDeck? It might be nice to put all the "immediate" logic in one place. Not a big deal though, feel free to ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeaaah this is a great suggestion!

@kiraarghy kiraarghy marked this pull request as ready for review June 24, 2019 11:37
@kiraarghy kiraarghy changed the title Rewrite/add deck [WIP] Rewrite slide display and transition logic. Jun 24, 2019
Copy link
Contributor

@VirtualDOMinic VirtualDOMinic left a comment

Choose a reason for hiding this comment

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

LGTM!

Maybe add comment to explain immediate (from react-spring)

@kale-stew kale-stew merged commit 118288b into task/rewrite Jul 31, 2019
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.

5 participants