-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🩹 fix(patch): tailwindcss theme mutations (#1740)
Prevents mutations to tailwind theme when using theme.json generators - adds unit tests for transformers - adds integration tests confirming `.text-${key}` css is generated for transformed values - adds integration tests confirming that `extendOnly` filter limits generated values refers: - none ## Type of change **PATCH: backwards compatible change** This PR includes breaking changes to the following core packages: - none This PR includes breaking changes to the follow extensions: - none ## Dependencies ### Adds - none ### Removes - none
- Loading branch information
1 parent
59a239a
commit 6b3fc48
Showing
19 changed files
with
396 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
body { | ||
@apply font-sans; | ||
@apply font-sans text-custom; | ||
} | ||
|
||
#root { | ||
@apply text-3xl font-medium text-indigo-500; | ||
@apply font-medium text-indigo-500 text-xl; | ||
|
||
background: url('~@images/image.jpeg'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
sources/@roots/sage/src/wp-theme-json/tailwind/fontFamily.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {describe, expect, it} from '@jest/globals' | ||
|
||
import {fontFamily} from './index' | ||
|
||
const mockFontFamily: fontFamily.TailwindFontFamily = { | ||
sans: [`mOCK-SANS`, `SANS-MOCK`], | ||
serif: `mock-serif`, | ||
} | ||
|
||
describe(`themeJson tailwind adapter`, () => { | ||
it(`transforms fontFamily`, () => { | ||
const mockfontFamilyRef = {...mockFontFamily} | ||
|
||
expect(fontFamily.transform(mockFontFamily)).toStrictEqual([ | ||
{ | ||
name: `MOCK-SANS`, | ||
slug: `sans`, | ||
fontFamily: `mOCK-SANS,SANS-MOCK`, | ||
}, | ||
{ | ||
name: `Mock-serif`, | ||
slug: `serif`, | ||
fontFamily: `mock-serif`, | ||
}, | ||
]) | ||
|
||
expect(mockFontFamily).toStrictEqual(mockfontFamilyRef) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
sources/@roots/sage/src/wp-theme-json/tailwind/fontSize.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {describe, expect, it} from '@jest/globals' | ||
|
||
import {fontSize} from './index' | ||
|
||
const mockFontSize: fontSize.TailwindSize = { | ||
lg: `1.25rem`, | ||
xl: [`1.5rem`, `2rem`], | ||
} | ||
|
||
describe(`themeJson tailwind adapter`, () => { | ||
it(`transforms fontSize`, () => { | ||
const mockfontSizeRef = {...mockFontSize} | ||
|
||
expect(fontSize.transform(mockFontSize)).toStrictEqual([ | ||
{ | ||
name: `lg`, | ||
slug: `lg`, | ||
size: `1.25rem`, | ||
}, | ||
{ | ||
name: `xl`, | ||
slug: `xl`, | ||
size: `1.5rem`, | ||
}, | ||
]) | ||
|
||
expect(mockFontSize).toStrictEqual(mockfontSizeRef) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
sources/@roots/sage/src/wp-theme-json/tailwind/palette.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {describe, expect, it} from '@jest/globals' | ||
|
||
import {palette} from './index' | ||
|
||
const mockPalette: palette.TailwindColors = { | ||
blue: { | ||
shade: { | ||
hue: { | ||
'50': `#add8e6`, | ||
}, | ||
}, | ||
group: { | ||
sky: `#87ceeb`, | ||
}, | ||
}, | ||
tomato: `#ff4500`, | ||
} | ||
|
||
describe(`themeJson tailwind adapter`, () => { | ||
it(`transformsPalette`, () => { | ||
const mockPaletteRef = {...mockPalette} | ||
|
||
expect(palette.transform(mockPalette)).toStrictEqual([ | ||
{ | ||
name: `Blue Shade Hue 50`, | ||
slug: `blue-shade-hue-50`, | ||
color: `#add8e6`, | ||
}, | ||
{ | ||
name: `Blue Group Sky`, | ||
slug: `blue-group-sky`, | ||
color: `#87ceeb`, | ||
}, | ||
{ | ||
name: `Tomato`, | ||
slug: `tomato`, | ||
color: `#ff4500`, | ||
}, | ||
]) | ||
|
||
expect(mockPalette).toEqual(mockPaletteRef) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.