unocss / unocss

The instant on-demand atomic CSS engine.
https://unocss.dev
MIT License
16.57k stars 833 forks source link

[Feature Proposal] duration class should apply default duration theme value when no value is specified #3540

Open AndrewBogdanovTSS opened 9 months ago

AndrewBogdanovTSS commented 9 months ago

Clear and concise description of the problem

Similarly to how it was working inside WindiCSS and to be better aligned with other utilities I suggest applying default theme duration value when no value was provided, so instead of duration-DEFAULT I could just write duration

Suggested solution

[
    /^(?:transition-)?duration(?:-(.+))$/,
    ([, d], { theme }) => ({ 'transition-duration': theme.duration?.[d || 'DEFAULT'] ?? h.bracket.cssvar.time(d) }),
    { autocomplete: ['transition-duration-$duration', 'duration-$duration'] },
  ],

Alternative

No response

Additional context

No response

Validations

henrikvilhelmberglund commented 8 months ago

Could you explain further what you mean, including a playground link? When using for example transition-all the default duration (from the theme) is already included so there is no need to add duration- unless you want something other than the default duration.

AndrewBogdanovTSS commented 7 months ago

I think it's quite straightforward even with no playground link. transition-all is a different property that cannot serve as a replacement for what is requested here. Just check how it works in WindiCSS. duration class applies default duration

henrikvilhelmberglund commented 7 months ago

I think it's quite straightforward even with no playground link. transition-all is a different property that cannot serve as a replacement for what is requested here. Just check how it works in WindiCSS. duration class applies default duration

If you use a transition class in UnoCSS you get your duration for free so I don't see the point of adding it, the only time you should want to use duration-x is when you don't want the default duration.

The playground link isn't for you, it's to make me or anyone else who might implement the feature see how this feature would improve things. And if it doesn't improve things it's unlikely to be added as a feature.

AndrewBogdanovTSS commented 7 months ago

If you use a transition class in UnoCSS you get your duration for free

If you use flex-1 class you get flex-grow for free. Why then we have flex-grow inside UnoCSS? Do you think we should remove it?

I don't see the point of adding it

It's your absolute right. I didn't ask you to look into this issue, leave any comments, or do any implementation about it. Just ignore this issue if you don't see a point in it.

It's to make me or anyone else who might implement the feature see how this feature would improve things.

What kind of playground do you need to understand that duration class should generate transition-duration: .15s; ? You can go to WindiCSS docs https://windicss.org/utilities/animations/transitions.html#transition-duration , remove 150 from duration and see how it works image

Moreover, I provided a complete implementation in my initial message. This is a 5-minute change but for some reason, you are trying to make this request look way more significant than it really is.