Coder Social home page Coder Social logo

lederer / react-showtime Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 0.0 7.05 MB

Mount & unmount React elements with CSS transitions

Home Page: https://react-showtime.dev

License: Apache License 2.0

HTML 2.35% JavaScript 95.12% CSS 0.29% TypeScript 2.24%
react css-transitions

react-showtime's People

Contributors

cloudniner avatar colekettler avatar dependabot[bot] avatar lederer avatar rajadain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-showtime's Issues

Add bounce keyword for easing

Consider a "bounce" keyword for easing that's a canned cubic-bezier.

Tricky bit is it would need to automatically apply different (inverted) versions to showEasing and hideEasing.

Set up CI release publishing workflow

We should create a GitHub Actions workflow to publish releases to npm under the Azavea account. Releases will be semantically versioned and tagged on main.

We should also create a release template that details how to version and tag a release so that it will correctly trigger this workflow.

Honor prefers-reduced-motion

When a user has prefers-reduced-motion enabled, we should honor it by disabling all react-showtime transitions.

Potentially add an overridePrefersReducedMotion boolean prop to override it?

Release 0.2.0

  • Start a new release branch:
$ git flow release start X.Y.Z
  • Bump version in package.json to X.Y.Z:
$ yarn version --no-git-tag-version --new-version X.Y.Z
  • Rotate CHANGELOG.md (following Keep a Changelog principles)
  • Ensure outstanding changes are committed:
$ git status # Is the git staging area clean?
$ git add package.json CHANGELOG.md
$ git commit -m "X.Y.Z"
  • Publish the release branch:
$ git flow release publish X.Y.Z
  • Finish and publish the release branch:
    • When prompted, keep default commit messages
    • Use X.Y.Z as the tag message
$ git flow release finish -p X.Y.Z

Release 0.3.5

  • Start a new release branch:
$ git flow release start X.Y.Z
  • Bump version in package.json to X.Y.Z:
$ yarn version X.Y.Z
  • Rotate CHANGELOG.md (following Keep a Changelog principles)
  • Ensure outstanding changes are committed:
$ git status # Is the git staging area clean?
$ git add package.json CHANGELOG.md
$ git commit -m "X.Y.Z"
  • Publish the release branch:
$ git flow release publish X.Y.Z
  • Finish and publish the release branch:
    • When prompted, keep default commit messages
    • Use X.Y.Z as the tag message
$ git flow release finish -p X.Y.Z

Release 0.3.7

  • Start a new release branch:
$ git flow release start X.Y.Z
  • Bump version in package.json to X.Y.Z:
$ yarn version X.Y.Z
  • Rotate CHANGELOG.md (following Keep a Changelog principles)
  • Ensure outstanding changes are committed:
$ git status # Is the git staging area clean?
$ git add package.json CHANGELOG.md
$ git commit -m "X.Y.Z"
  • Publish the release branch:
$ git flow release publish X.Y.Z
  • Finish and publish the release branch:
    • When prompted, keep default commit messages
    • Use X.Y.Z as the tag message
$ git flow release finish -p X.Y.Z

Support asymmetric per-property transitions

This may not be worth the additional API complexity and ambiguity, but it might be convenient to support show/hide{Value, Duration, Delay, Easing} within per-property transitions.

Eg:

transition: {
  height: 0,
  opacity: {
    value: 0,
    showDelay: 100,
    showDuration: 150,
    hideDelay: 25,
    hideDuration: 125
  }
}

The same outcome is already possible by defining a distinct showTransition and hideTransition, but that can be a bit annoying when both have exactly the same properties and only the per-property values and/or timings are different.

OTOH promoting multiple ways of doing the same thing has its own drawbacks.

Another drawback: We'd have to ignore per-property show* if erroneously supplied within a hideTransition, and vice versa.

But it's worth considering. I've found myself wanting to express transitions this way at times.

Release 0.3.2

  • Start a new release branch:
$ git flow release start X.Y.Z
  • Bump version in package.json to X.Y.Z:
$ yarn version X.Y.Z
  • Rotate CHANGELOG.md (following Keep a Changelog principles)
  • Ensure outstanding changes are committed:
$ git status # Is the git staging area clean?
$ git add package.json CHANGELOG.md
$ git commit -m "X.Y.Z"
  • Publish the release branch:
$ git flow release publish X.Y.Z
  • Finish and publish the release branch:
    • When prompted, keep default commit messages
    • Use X.Y.Z as the tag message
$ git flow release finish -p X.Y.Z

Release 0.1.0

  • Start a new release branch:
$ git flow release start X.Y.Z
  • Bump version in package.json to X.Y.Z:
$ yarn version --no-git-tag-version --new-version X.Y.Z
  • Rotate CHANGELOG.md (following Keep a Changelog principles)
  • Ensure outstanding changes are committed:
$ git status # Is the git staging area clean?
$ git add package.json CHANGELOG.md
$ git commit -m "X.Y.Z"
  • Publish the release branch:
$ git flow release publish X.Y.Z
  • Finish and publish the release branch:
    • When prompted, keep default commit messages
    • Use X.Y.Z as the tag message
$ git flow release finish -p X.Y.Z

Support keyframes

Consider supporting keyframes for multi-step animations. Would require using CSS animation instead of transition, at least when the keyframes setting is present.

Gatsby Build Issue

Describe the bug
This library does not work with Gatsby as it uses the window object which is not available during gatsby builds.

To Reproduce
Steps to reproduce (if the above description doesn't cover it):

  1. Use the useShowtime hook in a project
  2. Run a gatsby build
  3. See error

Expected behavior
Build should work.

Screenshots


 ERROR #95312 

"window" is not available during server side rendering.

See our docs page for more info on this error: https://gatsby.dev/debug-html


  549 |
  550 | function useEventListener(eventName, handler) {
> 551 |   var element = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
      | ^
  552 |   // This allows the effect below to always get latest handler ...
  553 |   // ... without needing to pass it in effect deps array ...
  554 |   // ... and potentially cause effect to re-run every render.


  WebpackError: ReferenceError: window is not defined
  
  - index.es.js:551 
    [my-gatsby-site]/[react-showtime]/dist/index.es.js:551:1
  
  - index.es.js:677 
    [my-gatsby-site]/[react-showtime]/dist/index.es.js:677:1
  
  - Nav.jsx:29 
    my-gatsby-site/src/components/Nav/Nav.jsx:29:42
  
  - extends.js:11 
    [my-gatsby-site]/[@babel]/runtime/helpers/extends.js:11:1
  
  - extends.js:14 
    [my-gatsby-site]/[@babel]/runtime/helpers/extends.js:14:1
  
  - extends.js:20 
    [my-gatsby-site]/[@babel]/runtime/helpers/extends.js:20:1
  
  - inheritsLoose.js:3 
    [my-gatsby-site]/[@babel]/runtime/helpers/inheritsLoose.js:3:1
  
  - static-entry.js:299 
    my-gatsby-site/.cache/static-entry.js:299:22
  
  - utils.js:37 
    [my-gatsby-site]/[@gatsbyjs]/reach-router/lib/utils.js:37:1
  

not finished Caching JavaScript and CSS webpack compilation - 12.443s
not finished Caching HTML renderer compilation - 0.360s

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy: `gatsby build --prefix-paths && gh-pages -d public`
npm ERR! Exit status 1```
**Desktop (please complete the following information):**
 - OS: PopOS
 - Browser chrome - latest

Support asymmetric transitions where one side has no transition

Is your feature request related to a problem? Please describe.
There is currently no straightforward way to specify a show transition with no hide transition, or vice versa.

Describe the solution you'd like
Passing in a showTransition without a hideTransition (or vice versa) and without a transition should do it.

Describe alternatives you've considered
Alternatively, or in addition, it might make sense to support a "none" keyword for showTransition and hideTransition.

Additional context
An example use case is if you need a transition for the initial appearance of something (eg, a status update), then need to replace it later with something new that has its own show transition (eg, a new status update). In these cases it might make sense to remove the first item instantly instead of using a hide transition, so the new item can being its initial show transition forthwith.

Require a ref param instead of returning a new ref?

Is your feature request related to a problem? Please describe.
The current hook API returns a ref that the consumer must attach to the element. If the consumer also has their own ref, they need to merge the refs manually, which can be unwieldy.

Describe the solution you'd like
An alternative approach is to require that the consumer create their own ref and pass it into the hook.

// defaults
const ref = useRef();
const [isMounted, show, hide] = useShowtime(ref);
// with settings
const ref = useRef();
const [isMounted, show, hide] = useShowtime(ref, "rise");

See https://twitter.com/buildsghost/status/1338951882052567041 for some discussion.

Additional context
Unclear if we should do this. We need to evaluate pros and cons.

Set up Netlify for CI and hosting

Set up a Netlify site and create a netlify.toml config to deploy the example subdirectory.

Additionally, we should establish a CHANGELOG to track releases for this library.

Related to resolution for azavea/operations#491.

Accept CSS strings in addition to CSS object literals

For those used to composing CSS, it can be cumbersome to compose object literals. We should consider accepting properly formed CSS strings for transition, showTransition, hideTransition, as an alternative to CSS object literals. The primary purpose is the same: to express the hidden CSS state of the item.

Some intertwining considerations:

  • Would it still be possible to provide per-property timings when passing a string instead of an object? How?
  • What happens if they include transition as one of the CSS properties in the string? Ignore it? Defer to it?
  • Should we also allow the string expression of the CSS transition property via a distinct setting (eg, CSSTransitionProperty), so they can author their own timings via a string rather than having it automatically assembled from our various symmetric, asymmetric, and per-property timing settings?

Overall this seems like too much complexity and ambiguity. But the pull of authoring CSS as… CSS, can be quite strong for those proficient in it.

Release 0.3.1

  • Start a new release branch:
$ git flow release start X.Y.Z
  • Bump version in package.json to X.Y.Z:
$ yarn version X.Y.Z
  • Rotate CHANGELOG.md (following Keep a Changelog principles)
  • Ensure outstanding changes are committed:
$ git status # Is the git staging area clean?
$ git add package.json CHANGELOG.md
$ git commit -m "X.Y.Z"
  • Publish the release branch:
$ git flow release publish X.Y.Z
  • Finish and publish the release branch:
    • When prompted, keep default commit messages
    • Use X.Y.Z as the tag message
$ git flow release finish -p X.Y.Z

Add CONTRIBUTING and CODE_OF_CONDUCT files

Since this project is intended as a general-purpose tool, it may receive some interest from community contributors. We should consider following GitHub's recommendation to add a CONTRIBUTING.md file to provide guidance for how external contributors can contribute to this project.

GitHub also recommends adding a CODE_OF_CONDUCT.md file to set expectations for respectful, constructive engagement and repository moderation. This practice also in line with recent positive trends in the OSS community as a whole. We should consider if there are commonly used codes of conduct that align well with our values and ability to moderate potential conflicts. The Contributor Covenant may be a good starting place, and has seen widespread adoption.

Release 0.3.3

  • Start a new release branch:
$ git flow release start X.Y.Z
  • Bump version in package.json to X.Y.Z:
$ yarn version X.Y.Z
  • Rotate CHANGELOG.md (following Keep a Changelog principles)
  • Ensure outstanding changes are committed:
$ git status # Is the git staging area clean?
$ git add package.json CHANGELOG.md
$ git commit -m "X.Y.Z"
  • Publish the release branch:
$ git flow release publish X.Y.Z
  • Finish and publish the release branch:
    • When prompted, keep default commit messages
    • Use X.Y.Z as the tag message
$ git flow release finish -p X.Y.Z

Release 0.3.0

  • Start a new release branch:
$ git flow release start X.Y.Z
  • Bump version in package.json to X.Y.Z:
$ yarn version X.Y.Z
  • Rotate CHANGELOG.md (following Keep a Changelog principles)
  • Ensure outstanding changes are committed:
$ git status # Is the git staging area clean?
$ git add package.json CHANGELOG.md
$ git commit -m "X.Y.Z"
  • Publish the release branch:
$ git flow release publish X.Y.Z
  • Finish and publish the release branch:
    • When prompted, keep default commit messages
    • Use X.Y.Z as the tag message
$ git flow release finish -p X.Y.Z

Add callbacks

Look into adding onHidden and onShowing callbacks to the hook.

Consider additional callbacks for both hook and component. Eg onWillShow, onWillHide.

Prepare for new release

  • Bump dependencies, including…
    • npx browserslist@latest --update-db
    • React Live, which appears to have a new version release
  • Consider a note in the readme about transfer from azavea to lederer and commitment to keep it public with the current license through at least Feb 2027.
  • Release 0.3.0 (TS support; dependency bumps)
    • Minor release because TS support adds functionality but is backward compatible

Release 0.3.4

  • Start a new release branch:
$ git flow release start X.Y.Z
  • Bump version in package.json to X.Y.Z:
$ yarn version X.Y.Z
  • Rotate CHANGELOG.md (following Keep a Changelog principles)
  • Ensure outstanding changes are committed:
$ git status # Is the git staging area clean?
$ git add package.json CHANGELOG.md
$ git commit -m "X.Y.Z"
  • Publish the release branch:
$ git flow release publish X.Y.Z
  • Finish and publish the release branch:
    • When prompted, keep default commit messages
    • Use X.Y.Z as the tag message
$ git flow release finish -p X.Y.Z

Decide on a public domain name

We need to decide on which domain we should use for the marketing / demo page for this library. We could just use a Netlify subdomain, we may want to establish it as an azavea.com subdomain, or we may want to purchase a domain. This is probably more of a marketing / branding question than a technical one.

In the short term, a netlify.com subdomain will get us up and running.

Accept functions for duration and delay

Consider accepting functions for duration and delay, including per-property. They would each receive the effective/inherited { duration, delay } values that would otherwise be used, so they could return a value based on them.

This way, slideFade's show transition could, say, delay the fade to the midpoint of the overall duration but have it complete at the same time, regardless of what custom duration or showDuration gets passed in.

slideFade ignores custom symmetric delay and easing during hide transition

If a custom delay or easing is provided with the slideFade transition, they will be ignored during the hide transition.

This is because slideFade includes its own hideDelay and hideEasing which, being more specific, override delay and easing.

The suggested workaround is to pass hideDelay and hideEasing. They will be honored.

Note this only affects the hide transition, not show. And duration is honored during hide, just not delay and easing.


No plans to fix this for now, because:

  1. delay and easing are not expected to be commonly used.
  2. There is an easy workaround.
  3. Forcing custom symmetric timings to override canned asymmetric timings may open its own can of worms.

Safari can exhibit odd easing behavior when delay is zero

Safari Mac/iOS sometimes exhibits strange easing behavior when delay is 0. Eg, the bounce behavior in the Extravaganza example on the demo site becomes more of a thud.

Setting delay to something greater than 0 seems to fix it. Thus the default delay is a nominal 16ms (about 1 frame at 60fps).

Beware of changing delay (or show/hideDelay) to 0 without testing across browsers.

Configure Dependabot

Create a dependabot.yml file to automatically bump npm dependencies with daily frequency. We may need to do this for / and /example separately.

Release 0.3.6

  • Start a new release branch:
$ git flow release start X.Y.Z
  • Bump version in package.json to X.Y.Z:
$ yarn version X.Y.Z
  • Rotate CHANGELOG.md (following Keep a Changelog principles)
  • Ensure outstanding changes are committed:
$ git status # Is the git staging area clean?
$ git add package.json CHANGELOG.md
$ git commit -m "X.Y.Z"
  • Publish the release branch:
$ git flow release publish X.Y.Z
  • Finish and publish the release branch:
    • When prompted, keep default commit messages
    • Use X.Y.Z as the tag message
$ git flow release finish -p X.Y.Z

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.