Skip to content

Commit b5a5e92

Browse files
committed
fix(tailwind): adjust config creation to avoid TypeScript issues
1 parent 86395a2 commit b5a5e92

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/tokens-dist/css/variables.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
--eds-spacing-size-1-and-half: 12; /* Pixels (px) - can convert to Relative EMs (rem) */
5050
--eds-spacing-size-quarter: 2; /* Pixels (px) - can convert to Relative EMs (rem) */
5151
--eds-spacing-size-half: 4; /* Pixels (px) - can convert to Relative EMs (rem) */
52-
--eds-spacing-size-7-and-half: 60; /* Pixels (px) - can convert to Relative EMs (rem) */
52+
--eds-spacing-size-7-and-half: 60; /* Pixels (px) - can convert to Relative EMs (rem) @deprecated This should not be used in code or design. It will be removed in a future version of EDS. */
5353
--eds-spacing-size-4-and-half: 36; /* Pixels (px) - can convert to Relative EMs (rem) */
5454
--eds-spacing-size-48: 384; /* Pixels (px) - can convert to Relative EMs (rem) */
5555
--eds-spacing-size-40: 320; /* Pixels (px) - can convert to Relative EMs (rem) */

tailwind.config.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
import type { Config } from 'tailwindcss';
22
import { eds as edsTokens } from './lib/tokens/json/tailwind-utility-config.json';
33

4-
/**
5-
* Convert a series of objects with one key-value pair into a combined object
6-
*
7-
* @param accumulate object each key/value pair is being written to
8-
* @param current current entry that is being put into the object
9-
* @returns object-ized version of the sequence of key value pairs
10-
*/
11-
function objArrayToObject(accumulate, current) {
12-
const entry = Object.entries(current)[0];
13-
accumulate[entry[0]] = entry[1];
14-
return accumulate;
15-
}
16-
174
/**
185
* Convert the token config values into a tailwind 3.x compatible format
196
*
@@ -49,15 +36,19 @@ export function applyTailwindConfig(
4936
.map((movement) => {
5037
return { [movement]: `${movements[movement]}s` };
5138
})
52-
.reduce(objArrayToObject, {}),
39+
.reduce((acc, cur) => {
40+
return Object.assign(acc, cur);
41+
}, {}),
5342
};
5443

5544
const spacingTokens = {
5645
...Object.keys(spacings)
5746
.map((spacing) => {
5847
return { [`spacing-size-${spacing}`]: `${spacings[spacing]}px` };
5948
})
60-
.reduce(objArrayToObject, {}),
49+
.reduce((acc, cur) => {
50+
return Object.assign(acc, cur);
51+
}, {}),
6152
};
6253

6354
return {

0 commit comments

Comments
 (0)