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 starting: variant for @starting-style and transition-discrete, transition-normal rules #3621

Merged
4 changes: 4 additions & 0 deletions packages/preset-mini/src/_rules/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ export const transitions: Rule<Theme>[] = [
// none
['transition-none', { transition: 'none' }],
...makeGlobalStaticRules('transition'),

// behavior
['transition-discrete', { 'transition-behavior': 'allow discrete' }],
['transition-normal', { 'transition-behavior': 'normal' }],
]
2 changes: 2 additions & 0 deletions packages/preset-mini/src/_variants/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { variantPartClasses, variantPseudoClassFunctions, variantPseudoClassesAn
import { variantAria } from './aria'
import { variantDataAttribute, variantTaggedDataAttributes } from './data'
import { variantContainerQuery } from './container'
import { variantStartingStyle } from './startingstyle'

export function variants(options: PresetMiniOptions): Variant<Theme>[] {
return [
Expand All @@ -24,6 +25,7 @@ export function variants(options: PresetMiniOptions): Variant<Theme>[] {
variantSelector,
variantInternalLayer,
variantNegative,
variantStartingStyle,
variantImportant(),
variantSupports,
variantPrint,
Expand Down
1 change: 1 addition & 0 deletions packages/preset-mini/src/_variants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export * from './misc'
export * from './negative'
export * from './pseudo'
export * from './supports'
export * from './startingstyle'
17 changes: 17 additions & 0 deletions packages/preset-mini/src/_variants/startingstyle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Variant } from '@unocss/core'

export const variantStartingStyle: Variant = {
name: 'start',
henrikvilhelmberglund marked this conversation as resolved.
Show resolved Hide resolved
match(matcher) {
if (!matcher.startsWith('start:'))
return

return {
matcher: matcher.slice(6),
handle: (input, next) => next({
...input,
parent: `@starting-style`,
}),
}
},
}
2 changes: 1 addition & 1 deletion test/__snapshots__/autocomplete.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ exports[`autocomplete > should provide autocomplete 1`] = `
"transform-scale-z-": "transform-scale-z-0 transform-scale-z-10 transform-scale-z-20 transform-scale-z-30 transform-scale-z-40 transform-scale-z-50 transform-scale-z-60 transform-scale-z-70 transform-scale-z-80 transform-scale-z-90",
"transform-skew-x-": "transform-skew-x-0 transform-skew-x-10 transform-skew-x-20 transform-skew-x-30 transform-skew-x-40 transform-skew-x-50 transform-skew-x-60 transform-skew-x-70 transform-skew-x-80 transform-skew-x-90",
"transform-skew-y-": "transform-skew-y-0 transform-skew-y-10 transform-skew-y-20 transform-skew-y-30 transform-skew-y-40 transform-skew-y-50 transform-skew-y-60 transform-skew-y-70 transform-skew-y-80 transform-skew-y-90",
"transition-": "transition-all transition-colors transition-inherit transition-initial transition-none transition-opacity transition-revert transition-revert-layer transition-shadow transition-transform",
"transition-": "transition-all transition-colors transition-discrete transition-inherit transition-initial transition-none transition-normal transition-opacity transition-revert transition-revert-layer",
"translate-": "translate-0 translate-10 translate-20 translate-30 translate-40 translate-50 translate-60 translate-70 translate-80 translate-90",
"translate-x-": "translate-x-0 translate-x-10 translate-x-20 translate-x-30 translate-x-40 translate-x-50 translate-x-60 translate-x-70 translate-x-80 translate-x-90",
"v-": "v-base v-baseline v-bottom v-btm v-end v-inherit v-initial v-mid v-middle v-revert",
Expand Down
Loading