-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Style engine: export util to compile CSS custom var from preset string (
#64490) Remove `compileStyleValue` in favour of pre-existing `getCSSValueFromRawStyle()` from the style engine package. Update style engine tests to cover bugfix in #43116 Moves style engine utils tests into correct directory Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: kevin940726 <kevin940726@git.wordpress.org>
- Loading branch information
1 parent
454129b
commit add79ad
Showing
9 changed files
with
96 additions
and
101 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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { camelCaseJoin, getCSSValueFromRawStyle, upperFirst } from '../utils'; | ||
|
||
describe( 'utils', () => { | ||
describe( 'upperFirst()', () => { | ||
it( 'should return an string with a capitalized first letter', () => { | ||
expect( upperFirst( 'toontown' ) ).toEqual( 'Toontown' ); | ||
} ); | ||
} ); | ||
|
||
describe( 'camelCaseJoin()', () => { | ||
it( 'should return a camelCase string', () => { | ||
expect( camelCaseJoin( [ 'toon', 'town' ] ) ).toEqual( 'toonTown' ); | ||
} ); | ||
} ); | ||
|
||
describe( 'getCSSValueFromRawStyle()', () => { | ||
it.each( [ | ||
[ 'min(40%, 400px)', 'min(40%, 400px)' ], | ||
[ | ||
'var(--wp--preset--color--yellow-bun)', | ||
'var:preset|color|yellow-bun', | ||
], | ||
[ 'var(--wp--preset--font-size--h-1)', 'var:preset|font-size|h1' ], | ||
[ | ||
'var(--wp--preset--font-size--1-px)', | ||
'var:preset|font-size|1px', | ||
], | ||
[ | ||
'var(--wp--preset--color--orange-11-orange)', | ||
'var:preset|color|orange11orange', | ||
], | ||
[ | ||
'var(--wp--preset--color--heavenly-blue)', | ||
'var:preset|color|heavenlyBlue', | ||
], | ||
[ | ||
'var(--wp--preset--background--dark-secrets-100)', | ||
'var:preset|background|dark_Secrets_100', | ||
], | ||
[ null, null ], | ||
[ false, false ], | ||
[ 1000, 1000 ], | ||
[ undefined, undefined ], | ||
] )( | ||
'should return %s using an incoming value of %s', | ||
( expected, value ) => { | ||
expect( getCSSValueFromRawStyle( value ) ).toEqual( expected ); | ||
} | ||
); | ||
} ); | ||
} ); |
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 was deleted.
Oops, something went wrong.
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