Skip to content

Commit

Permalink
feat: add '.will-change-x' utility class (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
Techassi committed Dec 15, 2021
1 parent 14edb4c commit c10216c
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/config/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,5 @@ export enum pluginOrder {
'backdropOpacity' = 13900,
'backdropSaturate' = 14000,
'backdropSepia' = 14100,
'willChange' = 14200,
}
38 changes: 38 additions & 0 deletions src/lib/utilities/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3317,4 +3317,42 @@ export const staticUtilities: StaticUtility = {
'order': 2,
},
},

// https://windicss.org/utilities/behaviors.html#will-change
'will-change-auto': {
'utility': {
'will-change': 'auto',
},
'meta': {
'group': 'willChange',
'order': 1,
},
},
'will-change-scroll': {
'utility': {
'will-change': 'scroll',
},
'meta': {
'group': 'willChange',
'order': 2,
},
},
'will-change-contents': {
'utility': {
'will-change': 'contents',
},
'meta': {
'group': 'willChange',
'order': 3,
},
},
'will-change-transform': {
'utility': {
'will-change': 'transform',
},
'meta': {
'group': 'willChange',
'order': 4,
},
},
};
6 changes: 6 additions & 0 deletions src/utils/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,12 @@ const utilities: { [key:string]: string[]} = {
'blur-${float}',
'blur-${size}',
],
willChange: [
'will-change-auto',
'will-change-scroll',
'will-change-contents',
'will-change-transform',
],
};

const negative: { [key:string]: true} = {
Expand Down
6 changes: 4 additions & 2 deletions test/processor/__snapshots__/resolve.test.ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ Tools / get corePlugins / list / 0: |-
"backdropInvert",
"backdropOpacity",
"backdropSaturate",
"backdropSepia"
"backdropSepia",
"willChange"
]
Tools / get corePlugins / list2 / 1: |-
[
Expand Down Expand Up @@ -345,7 +346,8 @@ Tools / get corePlugins / list3 / 2: |-
"backdropInvert",
"backdropOpacity",
"backdropSaturate",
"backdropSepia"
"backdropSepia",
"willChange"
]
Tools / resolve dynamic utilities / with-plugins / 1: |-
[
Expand Down
13 changes: 13 additions & 0 deletions test/processor/__snapshots__/utilities.test.ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,19 @@ Tools / transition time handler / transition / 0: |-
-o-transition-delay: 2.5s;
transition-delay: 2.5s;
}
Tools / will-change / css / 0: |-
.will-change-auto {
will-change: auto;
}
.will-change-scroll {
will-change: scroll;
}
.will-change-contents {
will-change: contents;
}
.will-change-transform {
will-change: transform;
}
Tools / wrap container / small container / 0: |-
@media (min-width: 640px) {
.sm\:container {
Expand Down
4 changes: 2 additions & 2 deletions test/processor/resolve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ describe('Resolve Tests', () => {
});

it('resolve static utilities', () => {
expect(Object.keys(processor.resolveStaticUtilities(false)).length).toEqual(320);
expect(Object.keys(processor.resolveStaticUtilities(true)).length).toEqual(329);
expect(Object.keys(processor.resolveStaticUtilities(false)).length).toEqual(324);
expect(Object.keys(processor.resolveStaticUtilities(true)).length).toEqual(333);
});

it('resolve dynamic utilities', () => {
Expand Down
9 changes: 9 additions & 0 deletions test/processor/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,13 @@ describe('Utilities', () => {
it('fill-none and stroke-none is wrong', () => {
expect(processor.interpret('fill-none stroke-none').styleSheet.build()).toMatchSnapshot('css');
});

it('will-change', () => {
expect(processor.interpret(`
will-change-auto
will-change-scroll
will-change-contents
will-change-transform
`).styleSheet.build()).toMatchSnapshot('css');
});
});
6 changes: 5 additions & 1 deletion test/utils/__snapshots__/completions.test.ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7002,7 +7002,11 @@ Tools / completions / static / 0: |-
"blur-lg",
"blur-xl",
"blur-2xl",
"blur-3xl"
"blur-3xl",
"will-change-auto",
"will-change-scroll",
"will-change-contents",
"will-change-transform"
]
'Tools / custom theme properties #226 / css / 1': |-
.h-screen-px {
Expand Down

0 comments on commit c10216c

Please sign in to comment.