Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support animation classes #24

Open
ameerthehacker opened this issue Dec 6, 2020 · 5 comments
Open

Support animation classes #24

ameerthehacker opened this issue Dec 6, 2020 · 5 comments

Comments

@ameerthehacker
Copy link
Member

Right now we are not supporting animation classes from tailwind, if we can get this through we would be a step more closer for react native support.

@jyash97
Copy link
Contributor

jyash97 commented Dec 6, 2020

Adding my thoughts on different approaches:

Adding simple animation class support like:

Usage

.animate-spin 

Generated

animation: spin 1s linear infinite; 
 @keyframes spin {   
    from {     
       transform: rotate(0deg);  
    }  to {     
       transform: rotate(360deg);   
   } 
}

In the CSS generator, we could add the respective keyframes and animation property to be added in styled-components. One problem that I think is we may add the keyframes multiple times if used in different components.

For Custom animation support -> We may just need to read the theme config and update the string.


Another approach could be:

Defining animation keyframes in styled-components and exporting them through lib. For eg:

export const spin = styled.keyframes`
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
`;


// Usage:

import {spin} from 'styled-wind/animations'
styled.div`
  animation: ${spin} 1s;
`

The benefit is the user gets more control over different properties.

@devevignesh
Copy link
Contributor

Hey @jyash97, RN doesn't support keyframes. Instead, we supposed to use RN Animated API. From my understanding, we shouldn't directly import styled-wind animation class it may throw an error. Please correct me if I'm wrong.

@ameerthehacker
Copy link
Member Author

@devevignesh you are right, react native not supporting key frames is a huge road block, we need to find a work around for that. If that is not possible the last resort is that we can continue to generate keyframes in react native also and styled-components will warn the developer that keyframes are not supported in react native https://styled-components.com/docs/basics#react-native

@ameerthehacker
Copy link
Member Author

Adding my thoughts on different approaches:

Adding simple animation class support like:

Usage

.animate-spin 

Generated

animation: spin 1s linear infinite; 
 @keyframes spin {   
    from {     
       transform: rotate(0deg);  
    }  to {     
       transform: rotate(360deg);   
   } 
}

In the CSS generator, we could add the respective keyframes and animation property to be added in styled-components. One problem that I think is we may add the keyframes multiple times if used in different components.

For Custom animation support -> We may just need to read the theme config and update the string.

Another approach could be:

Defining animation keyframes in styled-components and exporting them through lib. For eg:

export const spin = styled.keyframes`
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
`;


// Usage:

import {spin} from 'styled-wind/animations'
styled.div`
  animation: ${spin} 1s;
`

The benefit is the user gets more control over different properties.

@jyash97 the first approach seems to be more scalable (has more edge cases though). If we use the second case then we may need to define a lot of animation type like spin, bounce etc which is less flexible and hard to maintain.

@sudharsangs
Copy link
Contributor

Hi, @ameerthehacker is this issue still relevant? If so I can try to pick this up

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

No branches or pull requests

4 participants