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(preset-mini): add start variant for @starting-style and transition-discrete, transition-normal rules #3621

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

Conversation

henrikvilhelmberglund
Copy link
Contributor

@henrikvilhelmberglund henrikvilhelmberglund commented Mar 14, 2024

This PR:

Adds a start: variant to support @starting-style which can be used to set initial values for popover CSS transitions. Used for fade in effects.

This allows for three states in popover transitions:

Adds transition-discrete and transition-normal rules.

transition-discrete can be needed for popover transitions (the End part) and transition-normal is the default behavior
https://developer.mozilla.org/en-US/docs/Web/CSS/transition-behavior

Example:

<button popovertarget="my-styled-popover">Open styled Popover</button>

<div class="m-0 transition-all top-20 p-4 mx-auto
  start:popover-open:translate-y-0
  transition-all
  transition-discrete
  start:popover-open:opacity-0
  popover-open:translate-y-40
  start:popover-open:opacity-0
  popover-open:opacity-100
  opacity-0
  duration-1000
  backdrop:duration-1000
  
  start:popover-open:backdrop:bg-black
  popover-open:backdrop:bg-blue-300
  backdrop:transition-all
  backdrop:transition-discrete
  " 
  popover id="my-styled-popover">Greetings, one and all! (styled popover)</div>

start-discrete

Copy link

netlify bot commented Mar 14, 2024

Deploy Preview for unocss ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit cee80b6
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/65f4721edb667d0009b7d4f9
😎 Deploy Preview https://deploy-preview-3621--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

import type { Variant } from '@unocss/core'

export const variantStartingStyle: Variant = {
name: 'start',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not so sure about this variant; the name feels a bit too general and can be confusing. Since the feature is still experimental, I guess it might be better for you do it in-house at this moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is experimental but already in Chrome/Chrome for Android and Edge. https://caniuse.com/?search=%40starting-style
Webkit support coming soon: WebKit/WebKit@1544606

start could be starting instead (saw this in Tailwind, also not merged yet) but starting-style is what it's called basically.

No rush to merge (might as well wait for Tailwind PR review) but this will be useful for popovers using transitions instead of animations so could be nice to have if/when those become popular later.

@henrikvilhelmberglund henrikvilhelmberglund marked this pull request as draft March 14, 2024 20:58
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.

None yet

2 participants