Skip to content

Commit 1c36121

Browse files
committed
feat: improve transition property
1 parent 70efd73 commit 1c36121

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@pandacss/preset-base': minor
3+
---
4+
5+
Added new transition values and enhanced transition property utilities
6+
7+
- `size``width, height, min-width, max-width, min-height, max-height`
8+
- `position``left, right, top, bottom, inset, inset-inline, inset-block`
9+
- `background``background, background-color, background-image, background-position`
10+
11+
```tsx
12+
import { css } from 'styled-system/css'
13+
14+
// Transition shorthand values
15+
css({ transition: 'size' })
16+
17+
// Property groups
18+
css({ transitionProperty: 'size', transitionDuration: '300ms' })
19+
```

packages/generator/__tests__/generate-prop-types.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ describe('generate property types', () => {
154154
transitionTimingFunction: Tokens["easings"];
155155
transitionDelay: Tokens["durations"];
156156
transitionDuration: Tokens["durations"];
157-
transition: "all" | "common" | "background" | "colors" | "opacity" | "shadow" | "transform";
157+
transitionProperty: "common" | "colors" | "size" | "position" | "background";
158+
transition: "all" | "common" | "size" | "position" | "background" | "colors" | "opacity" | "shadow" | "transform";
158159
animation: Tokens["animations"];
159160
animationName: "spin" | "ping" | "pulse" | "bounce";
160161
animationTimingFunction: Tokens["easings"];

packages/generator/__tests__/generate-style-props.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5913,7 +5913,7 @@ describe('generate property types', () => {
59135913
*
59145914
* @see https://developer.mozilla.org/docs/Web/CSS/transition-property
59155915
*/
5916-
transitionProperty?: ConditionalValue<CssProperties["transitionProperty"] | AnyString>
5916+
transitionProperty?: ConditionalValue<UtilityValues["transitionProperty"] | CssVars | CssProperties["transitionProperty"] | AnyString>
59175917
/**
59185918
* The **\`transition-timing-function\`** CSS property sets how intermediate values are calculated for CSS properties being affected by a transition effect.
59195919
*
@@ -13421,7 +13421,7 @@ describe('generate property types', () => {
1342113421
*
1342213422
* @see https://developer.mozilla.org/docs/Web/CSS/transition-property
1342313423
*/
13424-
transitionProperty?: ConditionalValue<WithEscapeHatch<CssProperties["transitionProperty"]>>
13424+
transitionProperty?: ConditionalValue<WithEscapeHatch<UtilityValues["transitionProperty"] | CssVars>>
1342513425
/**
1342613426
* The **\`transition-timing-function\`** CSS property sets how intermediate values are calculated for CSS properties being affected by a transition effect.
1342713427
*

packages/preset-base/src/utilities/transitions.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,24 @@ const transitionMap: Record<string, any> = {
1111
common: createTransition(
1212
'color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
1313
),
14-
background: createTransition('background, background-color'),
14+
size: createTransition('width, height, min-width, max-width, min-height, max-height'),
15+
position: createTransition('left, right, top, bottom, inset, inset-inline, inset-block'),
16+
background: createTransition('background, background-color, background-image, background-position'),
1517
colors: createTransition('color, background-color, border-color, outline-color, text-decoration-color, fill, stroke'),
1618
opacity: createTransition('opacity'),
1719
shadow: createTransition('box-shadow'),
1820
transform: createTransition('transform'),
1921
}
2022

23+
const transitionPropertyMap: Record<string, string> = {
24+
common:
25+
'color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
26+
colors: 'color, background-color, border-color, outline-color, text-decoration-color, fill, stroke',
27+
size: 'width, height, min-width, max-width, min-height, max-height',
28+
position: 'left, right, top, bottom, inset, inset-inline, inset-block',
29+
background: 'background, background-color, background-image, background-position',
30+
}
31+
2132
export const transitions: UtilityConfig = {
2233
transitionTimingFunction: {
2334
className: 'trs-tmf',
@@ -49,6 +60,7 @@ export const transitions: UtilityConfig = {
4960
transitionProperty: {
5061
className: 'trs-prop',
5162
group: 'Transition',
63+
values: transitionPropertyMap,
5264
transform(value) {
5365
return {
5466
'--transition-prop': value,

packages/studio/styled-system/types/prop-type.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export interface UtilityValues {
150150
transitionTimingFunction: Tokens["easings"];
151151
transitionDelay: Tokens["durations"];
152152
transitionDuration: Tokens["durations"];
153-
transition: "all" | "common" | "background" | "colors" | "opacity" | "shadow" | "transform";
153+
transitionProperty: "common" | "colors" | "size" | "position" | "background";
154+
transition: "all" | "common" | "size" | "position" | "background" | "colors" | "opacity" | "shadow" | "transform";
154155
animation: Tokens["animations"];
155156
animationName: "spin" | "ping" | "pulse" | "bounce";
156157
animationTimingFunction: Tokens["easings"];

packages/studio/styled-system/types/style-props.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5907,7 +5907,7 @@ transitionDuration?: ConditionalValue<UtilityValues["transitionDuration"] | CssV
59075907
*
59085908
* @see https://developer.mozilla.org/docs/Web/CSS/transition-property
59095909
*/
5910-
transitionProperty?: ConditionalValue<CssProperties["transitionProperty"] | AnyString>
5910+
transitionProperty?: ConditionalValue<UtilityValues["transitionProperty"] | CssVars | CssProperties["transitionProperty"] | AnyString>
59115911
/**
59125912
* The **`transition-timing-function`** CSS property sets how intermediate values are calculated for CSS properties being affected by a transition effect.
59135913
*

0 commit comments

Comments
 (0)