-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
- Loading branch information
1 parent
0382a71
commit 56cf74a
Showing
9 changed files
with
49 additions
and
58 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
27 changes: 27 additions & 0 deletions
27
...es/next/src/client/components/react-dev-overlay/_experimental/internal/helpers/cx.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,27 @@ | ||
import { cx } from './cx' | ||
|
||
describe('cx', () => { | ||
it('should return an empty string for no arguments', () => { | ||
expect(cx()).toBe('') | ||
}) | ||
|
||
it('should join multiple string arguments with spaces', () => { | ||
expect(cx('foo', 'bar', 'baz')).toBe('foo bar baz') | ||
}) | ||
|
||
it('should filter out falsy values', () => { | ||
expect(cx('foo', null, 'bar', undefined, 'baz', false)).toBe('foo bar baz') | ||
}) | ||
|
||
it('should handle single string argument', () => { | ||
expect(cx('foo')).toBe('foo') | ||
}) | ||
|
||
it('should not add extra spaces when falsy values are between strings', () => { | ||
expect(cx('foo', null, 'bar')).toBe('foo bar') | ||
}) | ||
|
||
it('should handle all falsy values', () => { | ||
expect(cx(null, undefined, false)).toBe('') | ||
}) | ||
}) |
9 changes: 9 additions & 0 deletions
9
packages/next/src/client/components/react-dev-overlay/_experimental/internal/helpers/cx.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,9 @@ | ||
/** | ||
* Merge multiple args to a single string with spaces. Useful for merging class names. | ||
* @example | ||
* cx('foo', 'bar') // 'foo bar' | ||
* cx('foo', null, 'bar', undefined, 'baz', false) // 'foo bar baz' | ||
*/ | ||
export function cx(...args: (string | undefined | null | false)[]): string { | ||
return args.filter(Boolean).join(' ') | ||
} |
29 changes: 0 additions & 29 deletions
29
...ent/components/react-dev-overlay/_experimental/internal/helpers/merge-class-names.test.ts
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...c/client/components/react-dev-overlay/_experimental/internal/helpers/merge-class-names.ts
This file was deleted.
Oops, something went wrong.