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: add per-side border color utilities for JIT mode enabled configs #245

Merged
merged 2 commits into from
Jun 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/cli/core/ClassnamesGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,26 @@ export class ClassnamesGenerator {
// If the value is a nested object of color shades...
if (typeof colorValue === 'object' && colorValue !== null) {
// Loop over the deep objects and return the result for each key of the object.
return Object.keys(colorValue).map(shade => `${utilName}-${colorName}-${shade}`);
return Object.keys(colorValue).flatMap(shade => {
if (utilName === 'border' && this.isJitModeEnabled()) {
return ['', 't', 'r', 'b', 'l'].map(
side => `${utilName}-${side}-${colorName}-${shade}`,
);
} else {
return `${utilName}-${colorName}-${shade}`;
}
});
}
// Otherwise...
else {
// Return the result of merging the utility name with color value
return `${utilName}-${colorName}`;
if (utilName === 'border' && this.isJitModeEnabled()) {
return ['', 't', 'r', 'b', 'l'].map(
side => `${utilName}-${side.length > 0 ? side + '-' : ''}${colorName}`,
);
} else {
return `${utilName}-${colorName}`;
}
}
});

Expand All @@ -529,7 +543,7 @@ export class ClassnamesGenerator {

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