codepunkt / css-spring

Generate physics based css-keyframe animations for the css-in-js solution of your choice or plain css.
MIT License
313 stars 15 forks source link

change API so that it accepts both css strings and style objects #17

Open codepunkt opened 6 years ago

codepunkt commented 6 years ago

Change API so that it accepts both css strings and style objects

javiercf commented 6 years ago

with this do you refer to the ability to pass both margin-left and marginLeft as valid arguments in the object?

codepunkt commented 6 years ago

@javiercf At the current state of the repository, i'm working on a major rewrite, which will lead to a new major version (v5) being published. The current documentation README.md is outdated and doesn't reflect what the current state of the code actually does.

At the moment, the API has 3 arguments startStyleString, endStyleString, options (optional):

spring(
  'border-bottom: 1px solid #f00;',
  'border-bottom: 25px solid #bada55;',
  { precision: 3 }
)

I would like an API that accepts 3 arguments startStyles, endStyles, options (optional), where start and endStyles can be one of strings (supported atm) or style objects like this:

spring(
  { borderBottom: '1px solid #f00' },
  { borderBottom: '25px solid #bada55' },
  { precision: 3 }
)

I assume that a package/module that converts one to the other exists in the css-in-js world (aphrodite, radium, styled-components, glamor, fela, glamorous, emotion, styletron etc) - i just don't know which one.

I would love to find out the best module suited for this task (small bytesize, does what we want), then check the parameter types on spring invocation and convert style objects to style strings if objects are give so that the business logic itself only has to deal with string styles.