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: motion styles and better keyframe defaults #2701

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

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 Jul 4, 2024 4:44pm
panda-playground ✅ Ready (Inspect) Visit Preview Jul 4, 2024 4:44pm
panda-studio ✅ Ready (Inspect) Visit Preview Jul 4, 2024 4:44pm

Copy link

changeset-bot bot commented Jun 27, 2024

🦋 Changeset detected

Latest commit: deda74a

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 🔥

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.

2 participants