Skip to content

Commit 296bf49

Browse files
committed
refactor: rename arrToObj
1 parent 8cfb1e8 commit 296bf49

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/consts.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ export const LINE_WIDTHS = [
66
export const GRID_CELL_SIZE: number[] = [...Array(128)].map((_, i) => i + 1);
77
export const OFFSETS: number[] = [...Array(128 + 16)].map((_, i) => i + 1);
88

9-
export const arrToObj = (arr: number[], unit = "") => {
10-
const obj: Record<string, string> = {};
11-
12-
for (const val of arr) {
13-
obj[val] = val + unit;
14-
}
15-
16-
return obj;
17-
};
18-
199
export const DEFAULT_OPTS: IResolvedOpts = {
2010
prefix: "bg-",
2111
};

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import plugin from "tailwindcss/plugin";
2-
import { GRID_CELL_SIZE, LINE_WIDTHS, OFFSETS, arrToObj } from "./consts";
2+
import { GRID_CELL_SIZE, LINE_WIDTHS, OFFSETS } from "./consts";
33
import { generateCellSizes, matchCellSize } from "./lib/cellSizes";
44
import {
55
generateLineColors,
@@ -10,6 +10,7 @@ import { generateOffsets, matchOffsets } from "./lib/offsets";
1010
import { resolveOptions } from "./lib/resolveOptions";
1111
import { generateGridClass } from "./patterns/grid";
1212
import type { IOptions } from "./types";
13+
import { arrToTwConfig } from "./lib/arrToTwConfig";
1314

1415
export default plugin.withOptions<IOptions | undefined>(
1516
(options) => (api) => {
@@ -32,9 +33,9 @@ export default plugin.withOptions<IOptions | undefined>(
3233
},
3334
() => ({
3435
theme: {
35-
bgPatternLineWidth: arrToObj(LINE_WIDTHS),
36-
bgPatternCellSize: arrToObj(GRID_CELL_SIZE),
37-
bgPatternOffsets: arrToObj(OFFSETS, "px"),
36+
bgPatternLineWidth: arrToTwConfig(LINE_WIDTHS),
37+
bgPatternCellSize: arrToTwConfig(GRID_CELL_SIZE),
38+
bgPatternOffsets: arrToTwConfig(OFFSETS, "px"),
3839
},
3940
}),
4041
);

src/lib/arrToTwConfig.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const arrToTwConfig = (arr: number[], unit = "") => {
2+
const obj: Record<string, string> = {};
3+
4+
for (const val of arr) {
5+
obj[val] = val + unit;
6+
}
7+
8+
return obj;
9+
};

0 commit comments

Comments
 (0)