Skip to content

Commit

Permalink
fix: only generate classnames opacity short hand when JIT mode is ena…
Browse files Browse the repository at this point in the history
…bled
  • Loading branch information
muhammadsammy committed Jun 20, 2021
1 parent 38f27dd commit 75902d9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/cli/core/ClassnamesGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export class ClassnamesGenerator {
.replace('ringOffset', 'ring-offset')
.replace('background', 'bg');

const resultedClassnamesWithColors = propertyKeys
const classnamesWithColors = propertyKeys
// Exclude `DEFAULT` keys from the keys collection as they do not correspond to any classname.
.filter(k => k !== 'DEFAULT')
// Then, for every key of the property...
Expand All @@ -522,11 +522,17 @@ export class ClassnamesGenerator {
}
});

// Return the resulted classnames with thier opacity short hand syntax
return Object.keys(this._configParser.getTheme().opacity).flatMap(op =>
// Add the opacities short hand suffix `/{opacity}`: "bg-red-100/50"
resultedClassnamesWithColors.map(cls => cls + '/' + op),
);
// Add the opacities short hand suffix `/{opacity}`: "bg-red-100/50"
const classnamesWithColorsAndOpacitySuffix = Object.keys(
this._configParser.getTheme().opacity,
).flatMap(op => classnamesWithColors.map(cls => cls + '/' + op));

// Return the result classnames based on whether JIT mode is enabled or not
if (this.isJitModeEnabled()) {
return classnamesWithColorsAndOpacitySuffix;
} else {
return classnamesWithColors;
}
};

private getGeneratedClassesWithOpacities = (): ClassesWithOpacities => {
Expand Down

0 comments on commit 75902d9

Please sign in to comment.