Skip to content

Commit

Permalink
chore: remove deprecated and experimental classes- related code
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadsammy committed Jan 2, 2021
1 parent 61913c0 commit fd1599a
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 119 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@types/node": "^14.11.2",
"@typescript-eslint/eslint-plugin": "^3.0.2",
"@typescript-eslint/parser": "^3.0.2",
"autoprefixer": "^10.0.2",
"dts-bundle": "^0.7.2",
"eslint": "^7.1.0",
"eslint-config-prettier": "^6.11.0",
Expand All @@ -89,7 +90,7 @@
"rollup-plugin-terser": "^5.3.0",
"semver": "^7.3.2",
"standard-version": "^8.0.0",
"tailwindcss": "^1.8.7",
"tailwindcss": "^2.0.1",
"ts-jest": "~23.10.0",
"typescript": "^3.1.4"
}
Expand Down
18 changes: 7 additions & 11 deletions src/cli/core/ClassesGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import {nonConfigurableClassNames} from '../lib/non-configurable';
import {AllClasses, Backgrounds, Layout, Borders, Tables, Effects,
Interactivity, TransitionsAndAnimations, Transforms, Accessibility, SVG,
FlexBox, Grid, Spacing, Sizing, Typography} from '../lib/types/classes';
import {TConfigTheme, TConfigFuture, TTailwindCSSConfig} from '../lib/types/config';
import {TConfigTheme, TTailwindCSSConfig} from '../lib/types/config';

export class ClassesGenerator implements IGenerator {
private readonly prefix: string;
private readonly separator: string;
private readonly theme: Omit<TConfigTheme, 'extend'>;
private readonly configScanner: ConfigScanner;
private readonly deprecations: TConfigFuture;
private readonly generatedRegularClasses: AllClasses;
private readonly generatedPseudoClasses: string[];

Expand All @@ -26,7 +25,6 @@ export class ClassesGenerator implements IGenerator {
this.separator = configScanner.getSeparator();
this.theme = configScanner.getTheme();
this.configScanner = configScanner;
this.deprecations = configScanner.getDeprecations();

this.generatedRegularClasses = {
Accessibility: this.accessibility(),
Expand Down Expand Up @@ -227,14 +225,12 @@ export class ClassesGenerator implements IGenerator {
gridRow: Object.keys(this.theme.gridRow).map(key => `row-${key}`),
gridRowStart: Object.keys(this.theme.gridRowStart).map(key => `row-start-${key}`),
gridRowEnd: Object.keys(this.theme.gridRowEnd).map(key => `row-end-${key}`),
gap: ['gap-', 'gap-y-', 'gap-x-']
.concat(this.deprecations.removeDeprecatedGapUtilities ? [] : ['row-gap-', 'col-gap-'])
.flatMap(x => {
// grid gap inherits its values from theme.spacing by default, but theme.gap overrides it.
return Object.keys(_.isEmpty(this.theme.gap) ? this.theme.spacing : this.theme.gap).map(
gapValue => x + gapValue,
);
}),
gap: ['gap-', 'gap-y-', 'gap-x-'].flatMap(x => {
// grid gap inherits its values from theme.spacing by default, but theme.gap overrides it.
return Object.keys(_.isEmpty(this.theme.gap) ? this.theme.spacing : this.theme.gap).map(
gapValue => x + gapValue,
);
}),
};
};

Expand Down
6 changes: 1 addition & 5 deletions src/cli/core/ConfigScanner.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import _ from 'lodash';
import {defaultTailwindConfig} from '../lib/defaultTailwindConfig';
import {TTailwindCSSConfig, TConfigVariants, TConfigFuture} from '../lib/types/config';
import {TTailwindCSSConfig, TConfigVariants} from '../lib/types/config';
import {TConfigTheme, TThemeItems} from '../lib/types/config';
/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-return */

export class ConfigScanner {
private readonly future: TConfigFuture;
private readonly prefix: string;
private readonly separator: string;
private themeConfig: TConfigTheme;
private readonly variantsConfig: TConfigVariants;

constructor(tailwindConfig: TTailwindCSSConfig) {
this.future = tailwindConfig?.future ?? {};
this.prefix = _.isEmpty(tailwindConfig?.prefix) ? '' : (tailwindConfig.prefix as string);
this.separator = _.isEmpty(tailwindConfig.separator)
? ':'
Expand All @@ -27,8 +25,6 @@ export class ConfigScanner {

public getSeparator = (): string => this.separator;

public getDeprecations = (): TConfigFuture => this.future;

public getTheme = (): TThemeItems => {
const evaluateCoreTheme = (): TThemeItems => {
const coreTheme = _.omit(this.themeConfig, 'extend');
Expand Down
8 changes: 3 additions & 5 deletions src/cli/lib/types/config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {defaultTailwindConfig} from '../defaultTailwindConfig';

export type TTailwindCSSConfig = Partial<typeof defaultTailwindConfig>;

export type TConfigFuture = {
removeDeprecatedGapUtilities?: boolean;
};
export type TTailwindCSSConfig = Partial<
typeof defaultTailwindConfig & Record<'separator' | 'prefix', string>
>;

export type TConfigTheme = TThemeItems & {extend?: TThemeItems};

Expand Down

0 comments on commit fd1599a

Please sign in to comment.