@@ -13,7 +13,7 @@ import { Link } from '../link/index.js';
1313import { Row } from '../row/index.js' ;
1414import { Section } from '../section/index.js' ;
1515import type { TailwindConfig } from './tailwind.js' ;
16- import { Tailwind } from './tailwind.js' ;
16+ import { pixelBasedPreset , Tailwind } from './tailwind.js' ;
1717
1818describe ( 'Tailwind component' , ( ) => {
1919 const headMissingError =
@@ -1695,4 +1695,53 @@ describe('Tailwind component', () => {
16951695 ` ) ;
16961696 } ) ;
16971697 } ) ;
1698+
1699+ describe ( 'with pixelBasedPreset' , ( ) => {
1700+ const styleFor = async ( className : string ) => {
1701+ const html = await render (
1702+ < Tailwind config = { { presets : [ pixelBasedPreset ] } } >
1703+ < div className = { className } />
1704+ </ Tailwind > ,
1705+ ) ;
1706+ return html . match ( / s t y l e = " ( [ ^ " ] * ) " / ) ?. [ 1 ] ;
1707+ } ;
1708+
1709+ it . each ( [
1710+ [ 'rounded' , 'border-radius:4px' ] ,
1711+ [ 'rounded-sm' , 'border-radius:4px' ] ,
1712+ [ 'rounded-md' , 'border-radius:6px' ] ,
1713+ [ 'rounded-lg' , 'border-radius:8px' ] ,
1714+ [ 'rounded-4xl' , 'border-radius:32px' ] ,
1715+ [ 'max-w-md' , 'max-width:448px' ] ,
1716+ [ 'max-w-7xl' , 'max-width:1280px' ] ,
1717+ ] ) ( 'converts %s to pixels' , async ( className , expected ) => {
1718+ expect ( await styleFor ( className ) ) . toBe ( expected ) ;
1719+ } ) ;
1720+
1721+ it ( 'does not leave rem in the radius or max-width scales' , async ( ) => {
1722+ const classes = [
1723+ ...[ 'xs' , 'sm' , 'md' , 'lg' , 'xl' , '2xl' , '3xl' , '4xl' ] . map (
1724+ ( size ) => `rounded-${ size } ` ,
1725+ ) ,
1726+ ...[
1727+ '3xs' ,
1728+ '2xs' ,
1729+ 'xs' ,
1730+ 'sm' ,
1731+ 'md' ,
1732+ 'lg' ,
1733+ 'xl' ,
1734+ '2xl' ,
1735+ '3xl' ,
1736+ '4xl' ,
1737+ '5xl' ,
1738+ '6xl' ,
1739+ '7xl' ,
1740+ ] . map ( ( size ) => `max-w-${ size } ` ) ,
1741+ ] ;
1742+ for ( const className of classes ) {
1743+ expect ( await styleFor ( className ) , className ) . not . toContain ( 'rem' ) ;
1744+ }
1745+ } ) ;
1746+ } ) ;
16981747} ) ;
0 commit comments