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

feat: support animationStyle composition #2701

Merged
merged 6 commits into from
Dec 8, 2024
Merged

Conversation

segunadebayo
Copy link
Member

📝 Description

This is a spin-off from my work on Chakra. Let's introduce a new "mixin" called motion styles. The idea is to pair them with text styles and layer styles to create this three-part mixin that can make your styles a lot cleaner.

Motion styles focus solely on animations, allowing you to orchestrate animation properties.

Here's a good example of this:

import { defineMotionStyles } from "@pandacss/dev"

export const motionStyles = defineMotionStyles({
  "slide-fade-in": {
    value: {
      transformOrigin: "var(--transform-origin)",
      animationDuration: "fast",
      "&[data-placement^=top]": {
        animationName: "slide-from-top, fade-in",
      },
      "&[data-placement^=bottom]": {
        animationName: "slide-from-bottom, fade-in",
      },
      "&[data-placement^=left]": {
        animationName: "slide-from-left, fade-in",
      },
      "&[data-placement^=right]": {
        animationName: "slide-from-right, fade-in",
      },
    },
  },
})

With that defined, I can use it in my recipe or css like so:

export const popoverSlotRecipe = defineSlotRecipe({
  slots: anatomy.keys(),
  base: {
    content: {
      _open: {
        motionStyle: "scale-fade-in",
      },
      _closed: {
        motionStyle: "scale-fade-out",
      },
    },
  },
})

This feature will allow us to lean in towards CSS for animations rather than JS. Composing animation names is a powerful feature we should encourage consumers to use.

Copy link

vercel bot commented Jun 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
panda-docs ✅ Ready (Inspect) Visit Preview Dec 8, 2024 6:04pm
panda-playground ✅ Ready (Inspect) Visit Preview Dec 8, 2024 6:04pm
panda-studio ✅ Ready (Inspect) Visit Preview Dec 8, 2024 6:04pm

Copy link

changeset-bot bot commented Jun 27, 2024

🦋 Changeset detected

Latest commit: 8adfb42

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
@pandacss/preset-panda Minor
@pandacss/generator Minor
@pandacss/types Minor
@pandacss/core Minor
@pandacss/dev Minor
@pandacss/config Minor
@pandacss/node Minor
@pandacss/parser Minor
@pandacss/logger Minor
@pandacss/preset-atlaskit Minor
@pandacss/preset-base Minor
@pandacss/preset-open-props Minor
@pandacss/studio Minor
@pandacss/token-dictionary Minor
@pandacss/astro-plugin-studio Minor
@pandacss/postcss Minor
@pandacss/extractor Minor
@pandacss/is-valid-prop Minor
@pandacss/shared Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@caseybaggz
Copy link

LFG! I'm ready to use this 🔥

@segunadebayo segunadebayo changed the title feat: motion styles and better keyframe defaults feat: support animotion styles Dec 8, 2024
@segunadebayo segunadebayo changed the title feat: support animotion styles feat: support animation styles Dec 8, 2024
@segunadebayo segunadebayo changed the title feat: support animation styles feat: support animationStyle mixin Dec 8, 2024
@segunadebayo segunadebayo marked this pull request as ready for review December 8, 2024 17:55
@segunadebayo segunadebayo added the enhancement New feature or request label Dec 8, 2024
@segunadebayo segunadebayo changed the title feat: support animationStyle mixin feat: support animationStyle composition Dec 8, 2024
@segunadebayo segunadebayo merged commit 97a0e4d into main Dec 8, 2024
7 checks passed
@segunadebayo segunadebayo deleted the feat/motion-styles branch December 8, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants